Commit 057f3fad authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

sched: Fix sched_domain iterations vs. RCU

Vladis Kletnieks reported a new RCU debug warning in the scheduler.

Since commit dce840a0 ("sched: Dynamically allocate sched_domain/
sched_group data-structures") the sched_domain trees are protected by
RCU instead of RCU-sched.

This means that we need to include rcu_read_lock() protection when we
iterate them since disabling preemption doesn't suffice anymore.

Reported-by: Valdis.Kletnieks@vt.edu
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1302882741.2388.241.camel@twinsSigned-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 2f36825b
...@@ -1208,11 +1208,17 @@ int get_nohz_timer_target(void) ...@@ -1208,11 +1208,17 @@ int get_nohz_timer_target(void)
int i; int i;
struct sched_domain *sd; struct sched_domain *sd;
rcu_read_lock();
for_each_domain(cpu, sd) { for_each_domain(cpu, sd) {
for_each_cpu(i, sched_domain_span(sd)) for_each_cpu(i, sched_domain_span(sd)) {
if (!idle_cpu(i)) if (!idle_cpu(i)) {
return i; cpu = i;
goto unlock;
}
}
} }
unlock:
rcu_read_unlock();
return cpu; return cpu;
} }
/* /*
...@@ -2415,12 +2421,14 @@ ttwu_stat(struct task_struct *p, int cpu, int wake_flags) ...@@ -2415,12 +2421,14 @@ ttwu_stat(struct task_struct *p, int cpu, int wake_flags)
struct sched_domain *sd; struct sched_domain *sd;
schedstat_inc(p, se.statistics.nr_wakeups_remote); schedstat_inc(p, se.statistics.nr_wakeups_remote);
rcu_read_lock();
for_each_domain(this_cpu, sd) { for_each_domain(this_cpu, sd) {
if (cpumask_test_cpu(cpu, sched_domain_span(sd))) { if (cpumask_test_cpu(cpu, sched_domain_span(sd))) {
schedstat_inc(sd, ttwu_wake_remote); schedstat_inc(sd, ttwu_wake_remote);
break; break;
} }
} }
rcu_read_unlock();
} }
#endif /* CONFIG_SMP */ #endif /* CONFIG_SMP */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment