Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched_ext: idle: Explicitly pass allowed cpumask to scx_select_cpu_dfl()

Modify scx_select_cpu_dfl() to take the allowed cpumask as an explicit
argument, instead of implicitly using @p->cpus_ptr.

This prepares for future changes where arbitrary cpumasks may be passed
to the built-in idle CPU selection policy.

This is a pure refactoring with no functional changes.

Signed-off-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Andrea Righi and committed by
Tejun Heo
23c63a96 29f512f5

+14 -11
+1 -1
kernel/sched/ext.c
··· 3392 3392 } else { 3393 3393 s32 cpu; 3394 3394 3395 - cpu = scx_select_cpu_dfl(p, prev_cpu, wake_flags, 0); 3395 + cpu = scx_select_cpu_dfl(p, prev_cpu, wake_flags, NULL, 0); 3396 3396 if (cpu >= 0) { 3397 3397 p->scx.slice = SCX_SLICE_DFL; 3398 3398 p->scx.ddsp_dsq_id = SCX_DSQ_LOCAL;
+11 -9
kernel/sched/ext_idle.c
··· 438 438 * NOTE: tasks that can only run on 1 CPU are excluded by this logic, because 439 439 * we never call ops.select_cpu() for them, see select_task_rq(). 440 440 */ 441 - s32 scx_select_cpu_dfl(struct task_struct *p, s32 prev_cpu, u64 wake_flags, u64 flags) 441 + s32 scx_select_cpu_dfl(struct task_struct *p, s32 prev_cpu, u64 wake_flags, 442 + const struct cpumask *cpus_allowed, u64 flags) 442 443 { 443 444 const struct cpumask *llc_cpus = NULL, *numa_cpus = NULL; 445 + const struct cpumask *allowed = cpus_allowed ?: p->cpus_ptr; 444 446 int node = scx_cpu_node_if_enabled(prev_cpu); 445 447 s32 cpu; 446 448 ··· 462 460 struct cpumask *local_cpus = this_cpu_cpumask_var_ptr(local_numa_idle_cpumask); 463 461 const struct cpumask *cpus = numa_span(prev_cpu); 464 462 465 - if (task_affinity_all(p)) 463 + if (allowed == p->cpus_ptr && task_affinity_all(p)) 466 464 numa_cpus = cpus; 467 - else if (cpus && cpumask_and(local_cpus, p->cpus_ptr, cpus)) 465 + else if (cpus && cpumask_and(local_cpus, allowed, cpus)) 468 466 numa_cpus = local_cpus; 469 467 } 470 468 ··· 472 470 struct cpumask *local_cpus = this_cpu_cpumask_var_ptr(local_llc_idle_cpumask); 473 471 const struct cpumask *cpus = llc_span(prev_cpu); 474 472 475 - if (task_affinity_all(p)) 473 + if (allowed == p->cpus_ptr && task_affinity_all(p)) 476 474 llc_cpus = cpus; 477 - else if (cpus && cpumask_and(local_cpus, p->cpus_ptr, cpus)) 475 + else if (cpus && cpumask_and(local_cpus, allowed, cpus)) 478 476 llc_cpus = local_cpus; 479 477 } 480 478 ··· 513 511 cpu_rq(cpu)->scx.local_dsq.nr == 0 && 514 512 (!(flags & SCX_PICK_IDLE_IN_NODE) || (waker_node == node)) && 515 513 !cpumask_empty(idle_cpumask(waker_node)->cpu)) { 516 - if (cpumask_test_cpu(cpu, p->cpus_ptr)) 514 + if (cpumask_test_cpu(cpu, allowed)) 517 515 goto out_unlock; 518 516 } 519 517 } ··· 558 556 * begin in prev_cpu's node and proceed to other nodes in 559 557 * order of increasing distance. 560 558 */ 561 - cpu = scx_pick_idle_cpu(p->cpus_ptr, node, flags | SCX_PICK_IDLE_CORE); 559 + cpu = scx_pick_idle_cpu(allowed, node, flags | SCX_PICK_IDLE_CORE); 562 560 if (cpu >= 0) 563 561 goto out_unlock; 564 562 ··· 606 604 * in prev_cpu's node and proceed to other nodes in order of 607 605 * increasing distance. 608 606 */ 609 - cpu = scx_pick_idle_cpu(p->cpus_ptr, node, flags); 607 + cpu = scx_pick_idle_cpu(allowed, node, flags); 610 608 611 609 out_unlock: 612 610 rcu_read_unlock(); ··· 860 858 goto prev_cpu; 861 859 862 860 #ifdef CONFIG_SMP 863 - cpu = scx_select_cpu_dfl(p, prev_cpu, wake_flags, 0); 861 + cpu = scx_select_cpu_dfl(p, prev_cpu, wake_flags, NULL, 0); 864 862 if (cpu >= 0) { 865 863 *is_idle = true; 866 864 return cpu;
+2 -1
kernel/sched/ext_idle.h
··· 27 27 } 28 28 #endif /* CONFIG_SMP */ 29 29 30 - s32 scx_select_cpu_dfl(struct task_struct *p, s32 prev_cpu, u64 wake_flags, u64 flags); 30 + s32 scx_select_cpu_dfl(struct task_struct *p, s32 prev_cpu, u64 wake_flags, 31 + const struct cpumask *cpus_allowed, u64 flags); 31 32 void scx_idle_enable(struct sched_ext_ops *ops); 32 33 void scx_idle_disable(void); 33 34 int scx_idle_init(void);