aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-11-12 09:55:29 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-13 04:09:59 -0500
commitfe3bcfe1f6c1fc4ea7706ac2d05e579fd9092682 (patch)
tree2de57bbb385face039f7e6c0da38f86e545076a0 /kernel
parenta50bde5130f65733142b32975616427d0ea50856 (diff)
sched: More generic WAKE_AFFINE vs select_idle_sibling()
Instead of only considering SD_WAKE_AFFINE | SD_PREFER_SIBLING domains also allow all SD_PREFER_SIBLING domains below a SD_WAKE_AFFINE domain to change the affinity target. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Galbraith <efault@gmx.de> LKML-Reference: <20091112145610.909723612@chello.nl> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sched_fair.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index a32df1524746..f28a2671a1a6 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -1333,20 +1333,16 @@ select_idle_sibling(struct task_struct *p, struct sched_domain *sd, int target)
1333 * test in select_task_rq_fair) and the prev_cpu is idle then that's 1333 * test in select_task_rq_fair) and the prev_cpu is idle then that's
1334 * always a better target than the current cpu. 1334 * always a better target than the current cpu.
1335 */ 1335 */
1336 if (target == cpu) { 1336 if (target == cpu && !cpu_rq(prev_cpu)->cfs.nr_running)
1337 if (!cpu_rq(prev_cpu)->cfs.nr_running) 1337 return prev_cpu;
1338 target = prev_cpu;
1339 }
1340 1338
1341 /* 1339 /*
1342 * Otherwise, iterate the domain and find an elegible idle cpu. 1340 * Otherwise, iterate the domain and find an elegible idle cpu.
1343 */ 1341 */
1344 if (target == -1 || target == cpu) { 1342 for_each_cpu_and(i, sched_domain_span(sd), &p->cpus_allowed) {
1345 for_each_cpu_and(i, sched_domain_span(sd), &p->cpus_allowed) { 1343 if (!cpu_rq(i)->cfs.nr_running) {
1346 if (!cpu_rq(i)->cfs.nr_running) { 1344 target = i;
1347 target = i; 1345 break;
1348 break;
1349 }
1350 } 1346 }
1351 } 1347 }
1352 1348
@@ -1407,7 +1403,12 @@ static int select_task_rq_fair(struct task_struct *p, int sd_flag, int wake_flag
1407 want_sd = 0; 1403 want_sd = 0;
1408 } 1404 }
1409 1405
1410 if (want_affine && (tmp->flags & SD_WAKE_AFFINE)) { 1406 /*
1407 * While iterating the domains looking for a spanning
1408 * WAKE_AFFINE domain, adjust the affine target to any idle cpu
1409 * in cache sharing domains along the way.
1410 */
1411 if (want_affine) {
1411 int target = -1; 1412 int target = -1;
1412 1413
1413 /* 1414 /*
@@ -1420,17 +1421,15 @@ static int select_task_rq_fair(struct task_struct *p, int sd_flag, int wake_flag
1420 /* 1421 /*
1421 * If there's an idle sibling in this domain, make that 1422 * If there's an idle sibling in this domain, make that
1422 * the wake_affine target instead of the current cpu. 1423 * the wake_affine target instead of the current cpu.
1423 *
1424 * XXX: should we possibly do this outside of
1425 * WAKE_AFFINE, in case the shared cache domain is
1426 * smaller than the WAKE_AFFINE domain?
1427 */ 1424 */
1428 if (tmp->flags & SD_PREFER_SIBLING) 1425 if (tmp->flags & SD_PREFER_SIBLING)
1429 target = select_idle_sibling(p, tmp, target); 1426 target = select_idle_sibling(p, tmp, target);
1430 1427
1431 if (target >= 0) { 1428 if (target >= 0) {
1432 affine_sd = tmp; 1429 if (tmp->flags & SD_WAKE_AFFINE) {
1433 want_affine = 0; 1430 affine_sd = tmp;
1431 want_affine = 0;
1432 }
1434 cpu = target; 1433 cpu = target;
1435 } 1434 }
1436 } 1435 }