From: Peter Zijlstra Date: Thu, 10 Sep 2009 16:18:47 +0000 (+0200) Subject: sched: for_each_domain() vs RCU X-Git-Tag: v2.6.32-rc1~652^2~26 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=83f54960c11a14942ab00b54c51e91906b9d8235;p=~shefty%2Frdma-dev.git sched: for_each_domain() vs RCU for_each_domain() uses RCU to serialize the sched_domains, except it doesn't actually use rcu_read_lock() and instead relies on disabling preemption -> FAIL. XXX: audit other sched_domain code. Signed-off-by: Peter Zijlstra LKML-Reference: Signed-off-by: Ingo Molnar --- diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c index eaa00014b49..43dc6d1d9e8 100644 --- a/kernel/sched_fair.c +++ b/kernel/sched_fair.c @@ -1331,6 +1331,7 @@ static int select_task_rq_fair(struct task_struct *p, int flag, int sync) new_cpu = prev_cpu; } + rcu_read_lock(); for_each_domain(cpu, tmp) { /* * If power savings logic is enabled for a domain, see if we @@ -1369,8 +1370,10 @@ static int select_task_rq_fair(struct task_struct *p, int flag, int sync) if (want_affine && (tmp->flags & SD_WAKE_AFFINE) && cpumask_test_cpu(prev_cpu, sched_domain_span(tmp))) { - if (wake_affine(tmp, p, sync)) - return cpu; + if (wake_affine(tmp, p, sync)) { + new_cpu = cpu; + goto out; + } want_affine = 0; } @@ -1416,6 +1419,8 @@ static int select_task_rq_fair(struct task_struct *p, int flag, int sync) /* while loop will break here if sd == NULL */ } +out: + rcu_read_unlock(); return new_cpu; } #endif /* CONFIG_SMP */