Skip to content

Commit 7a0590a

Browse files
committed
sched: rotate the cpu search window for better spread
Rotate the cpu search window for better spread of threads. This will ensure an idle cpu will quickly be found if one exists. Orabug: 28482695 Signed-off-by: subhra mazumdar <[email protected]> Reviewed-by: Rohit Jain <[email protected]>
1 parent 91787b1 commit 7a0590a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

kernel/sched/fair.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5764,7 +5764,7 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t
57645764
u64 avg_cost, avg_idle;
57655765
u64 time, cost;
57665766
s64 delta;
5767-
int cpu, limit, floor, nr = INT_MAX;
5767+
int cpu, limit, floor, target_tmp, nr = INT_MAX;
57685768

57695769
this_sd = rcu_dereference(*this_cpu_ptr(&sd_llc));
57705770
if (!this_sd)
@@ -5795,9 +5795,15 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t
57955795
}
57965796
}
57975797

5798+
if (per_cpu(next_cpu, target) != -1)
5799+
target_tmp = per_cpu(next_cpu, target);
5800+
else
5801+
target_tmp = target;
5802+
57985803
time = local_clock();
57995804

5800-
for_each_cpu_wrap(cpu, sched_domain_span(sd), target) {
5805+
for_each_cpu_wrap(cpu, sched_domain_span(sd), target_tmp) {
5806+
per_cpu(next_cpu, target) = cpu;
58015807
if (!--nr)
58025808
return -1;
58035809
if (!cpumask_test_cpu(cpu, &p->cpus_allowed))

0 commit comments

Comments
 (0)