From d160019213b3b0bf3a0b85975af65df11e483c33 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 10 Nov 2011 13:01:10 +0100 Subject: [PATCH] --- yaml --- r: 276367 b: refs/heads/master c: 4dcfe1025b513c2c1da5bf5586adb0e80148f612 h: refs/heads/master i: 276365: a8d4bcb7093c6054cbb6e102989aefa44c4abc34 276363: db3ecf224d747435f2d3a059bf2fafa1e8147361 276359: e62e5fc51623141f728b3117d7079affdc357fb8 276351: 95f01ca704fa6d750e105340195aa0fc79084027 v: v3 --- [refs] | 2 +- trunk/kernel/sched_fair.c | 42 ++++++++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/[refs] b/[refs] index 4331f074d8e7..135ddc2ef9fb 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: f1c6f1a7eed963ed233ba4c8b6fa8addb86c6ddc +refs/heads/master: 4dcfe1025b513c2c1da5bf5586adb0e80148f612 diff --git a/trunk/kernel/sched_fair.c b/trunk/kernel/sched_fair.c index 7e51b5bb27cc..ba0e1f49a22f 100644 --- a/trunk/kernel/sched_fair.c +++ b/trunk/kernel/sched_fair.c @@ -2326,7 +2326,8 @@ static int select_idle_sibling(struct task_struct *p, int target) int cpu = smp_processor_id(); int prev_cpu = task_cpu(p); struct sched_domain *sd; - int i; + struct sched_group *sg; + int i, smt = 0; /* * If the task is going to be woken-up on this cpu and if it is @@ -2346,25 +2347,38 @@ static int select_idle_sibling(struct task_struct *p, int target) * Otherwise, iterate the domains and find an elegible idle cpu. */ rcu_read_lock(); +again: for_each_domain(target, sd) { - if (!(sd->flags & SD_SHARE_PKG_RESOURCES)) - break; + if (!smt && (sd->flags & SD_SHARE_CPUPOWER)) + continue; - for_each_cpu_and(i, sched_domain_span(sd), tsk_cpus_allowed(p)) { - if (idle_cpu(i)) { - target = i; - break; + if (!(sd->flags & SD_SHARE_PKG_RESOURCES)) { + if (!smt) { + smt = 1; + goto again; } + break; } - /* - * Lets stop looking for an idle sibling when we reached - * the domain that spans the current cpu and prev_cpu. - */ - if (cpumask_test_cpu(cpu, sched_domain_span(sd)) && - cpumask_test_cpu(prev_cpu, sched_domain_span(sd))) - break; + sg = sd->groups; + do { + if (!cpumask_intersects(sched_group_cpus(sg), + tsk_cpus_allowed(p))) + goto next; + + for_each_cpu(i, sched_group_cpus(sg)) { + if (!idle_cpu(i)) + goto next; + } + + target = cpumask_first_and(sched_group_cpus(sg), + tsk_cpus_allowed(p)); + goto done; +next: + sg = sg->next; + } while (sg != sd->groups); } +done: rcu_read_unlock(); return target;