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

sched/core: Adjusting the order of scanning CPU

When select_idle_capacity() starts scanning for an idle CPU, it starts
with target CPU that has already been checked in select_idle_sibling().
So we start checking from the next CPU and try the target CPU at the end.
Similarly for task_numa_assign(), we have just checked numa_migrate_on
of dst_cpu, so start from the next CPU. This also works for
steal_cookie_task(), the first scan must fail and start directly
from the next one.

Signed-off-by: Hao Jia <jiahao.os@bytedance.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Acked-by: Mel Gorman <mgorman@techsingularity.net>
Link: https://lore.kernel.org/r/20221216062406.7812-3-jiahao.os@bytedance.com

authored by

Hao Jia and committed by
Peter Zijlstra
8589018a feaed763

+3 -3
+1 -1
kernel/sched/core.c
··· 6209 6209 { 6210 6210 int i; 6211 6211 6212 - for_each_cpu_wrap(i, sched_domain_span(sd), cpu) { 6212 + for_each_cpu_wrap(i, sched_domain_span(sd), cpu + 1) { 6213 6213 if (i == cpu) 6214 6214 continue; 6215 6215
+2 -2
kernel/sched/fair.c
··· 1836 1836 int start = env->dst_cpu; 1837 1837 1838 1838 /* Find alternative idle CPU. */ 1839 - for_each_cpu_wrap(cpu, cpumask_of_node(env->dst_nid), start) { 1839 + for_each_cpu_wrap(cpu, cpumask_of_node(env->dst_nid), start + 1) { 1840 1840 if (cpu == env->best_cpu || !idle_cpu(cpu) || 1841 1841 !cpumask_test_cpu(cpu, env->p->cpus_ptr)) { 1842 1842 continue; ··· 6935 6935 util_min = uclamp_eff_value(p, UCLAMP_MIN); 6936 6936 util_max = uclamp_eff_value(p, UCLAMP_MAX); 6937 6937 6938 - for_each_cpu_wrap(cpu, cpus, target) { 6938 + for_each_cpu_wrap(cpu, cpus, target + 1) { 6939 6939 unsigned long cpu_cap = capacity_of(cpu); 6940 6940 6941 6941 if (!available_idle_cpu(cpu) && !sched_idle_cpu(cpu))