sched: fix active load balance
PATCH 1/1 sched: fix active load balance
Recent changes to active load balance (sched2-fix-smt-scheduling-problems.patch in -mm) is not resulting in any task movement from busiest to target_cpu. Attached patch(ontop of -mm) fixes this issue.
kernel/sched.c +3 -6
@@ -2131,7 +2131,7 @@*/ static void active_load_balance (runqueue_t *busiest_rq,int busiest_cpu) { -struct sched_domain *tmp =NULL , *sd; +struct sched_domain *sd;runqueue_t *target_rq;int target_cpu = busiest_rq->push_cpu;
@@ -2152,13 +2152,10 @@double_lock_balance (busiest_rq, target_rq);/* Search for an sd spanning us and the target CPU. */ -for_each_domain (target_cpu, sd) { +for_each_domain (target_cpu, sd)if ((sd->flags &SD_LOAD_BALANCE ) && -cpu_isset (busiest_cpu, sd->span)) { - sd = tmp; +cpu_isset (busiest_cpu, sd->span))break ; - } - }if (unlikely (sd ==NULL )) goto out;
kernel/sched.c line 2161
Quoted 9 lines · Siddha, Suresh B
kernel/sched.c +2
-5-for_each_domain (target_cpu, sd) { +for_each_domain (target_cpu, sd)if ((sd->flags &SD_LOAD_BALANCE ) && -cpu_isset (busiest_cpu, sd->span)) { - sd = tmp; +cpu_isset (busiest_cpu, sd->span))break ; - } - }
hm, the right fix i think is to do:
for_each_domain(target_cpu, tmp) {
if ((tmp->flags & SD_LOAD_BALANCE) &&
cpu_isset(busiest_cpu, tmp->span)) {
sd = tmp;
break;
}
}
because when balancing we want to match the widest-scope domain, not the first one. The s/tmp/sd thing was a typo i suspect.
Ingo
Quoted 15 lines · Ingo Molnar
kernel/sched.c line 2161
Quoted 9 lines · Siddha, Suresh B
kernel/sched.c +2
-5-for_each_domain (target_cpu, sd) { +for_each_domain (target_cpu, sd)if ((sd->flags &SD_LOAD_BALANCE ) && -cpu_isset (busiest_cpu, sd->span)) { - sd = tmp; +cpu_isset (busiest_cpu, sd->span))break ; - } - }hm, the right fix i think is to do:
Review
Quoted 7 lines
(quoted diff) +0
-0for_each_domain(target_cpu, tmp) { if ((tmp->flags & SD_LOAD_BALANCE) && cpu_isset(busiest_cpu, tmp->span)) { sd = tmp; break; } }
Your suggestion also looks similar to my patch. You are also breaking on the first one.
Quoted 2 lines
because when balancing we want to match the widest-scope domain, not the first one.
We want the first domain spanning both the cpu's. That is the domain where normal load balance failed and we restore to active load balance.
thanks,
suresh
Quoted 5 lines · Suresh B
Quoted 3 lines · Ingo Molnar
* Siddha, Suresh B <[email protected]> wrote:
Quoted 10 lines
Quoted 10 lines
kernel/sched.c line 2161
Quoted 9 lines
kernel/sched.c +1
-1-for_each_domain (target_cpu, sd) { +for_each_domain (target_cpu, sd)if ((sd->flags & SD_LOAD_BALANCE) &&kernel/sched.c +1
-2- cpu_isset(busiest_cpu, sd->span)) { - sd = tmp; + cpu_isset(busiest_cpu, sd->span))break;kernel/sched.c +0
-2- } - }
Yep that was broken :(
Thanks for picking that up Suresh.
Quoted 11 lines
Quoted 9 lines
hm, the right fix i think is to do:
for_each_domain(target_cpu, tmp) { if ((tmp->flags & SD_LOAD_BALANCE) && cpu_isset(busiest_cpu, tmp->span)) { sd = tmp; break; } }
Quoted 9 lines
Your suggestion also looks similar to my patch. You are also breaking on the first one.
Quoted 1 line
because when balancing we want to match the widest-scope domain, not the first one.
We want the first domain spanning both the cpu's. That is the domain where normal load balance failed and we restore to active load balance.
Yes, that's right.
Signature · 1 line
SUSE Labs, Novell Inc.
Ingo Molnar
Acked-byQuoted 2 lines · Siddha, Suresh B
Your suggestion also looks similar to my patch. You are also breaking on the first one.
yeah.
Quoted 3 lines
We want the first domain spanning both the cpu's. That is the domain where normal load balance failed and we restore to active load balance.
indeed.
Ingo