Skip to content

Commit

Permalink
sched: for_each_domain() vs RCU
Browse files Browse the repository at this point in the history
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 <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Sep 15, 2009
1 parent ae154be commit 83f5496
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions kernel/sched_fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 83f5496

Please sign in to comment.