Skip to content

Commit

Permalink
sched: More sched_domain iterations fixes
Browse files Browse the repository at this point in the history
sched_domain iterations needs to be protected by rcu_read_lock() now,
this patch adds another two places which needs the rcu lock, which is
spotted by following suspicious rcu_dereference_check() usage warnings.

kernel/sched_rt.c:1244 invoked rcu_dereference_check() without protection!
kernel/sched_stats.h:41 invoked rcu_dereference_check() without protection!

Signed-off-by: Xiaotian Feng <dfeng@redhat.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1303469634-11678-1-git-send-email-dfeng@redhat.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Xiaotian Feng authored and Ingo Molnar committed May 28, 2011
1 parent dc7acbb commit cd4ae6a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions kernel/sched_rt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,7 @@ static int find_lowest_rq(struct task_struct *task)
if (!cpumask_test_cpu(this_cpu, lowest_mask))
this_cpu = -1; /* Skip this_cpu opt if not among lowest */

rcu_read_lock();
for_each_domain(cpu, sd) {
if (sd->flags & SD_WAKE_AFFINE) {
int best_cpu;
Expand All @@ -1272,15 +1273,20 @@ static int find_lowest_rq(struct task_struct *task)
* remote processor.
*/
if (this_cpu != -1 &&
cpumask_test_cpu(this_cpu, sched_domain_span(sd)))
cpumask_test_cpu(this_cpu, sched_domain_span(sd))) {
rcu_read_unlock();
return this_cpu;
}

best_cpu = cpumask_first_and(lowest_mask,
sched_domain_span(sd));
if (best_cpu < nr_cpu_ids)
if (best_cpu < nr_cpu_ids) {
rcu_read_unlock();
return best_cpu;
}
}
}
rcu_read_unlock();

/*
* And finally, if there were no matches within the domains
Expand Down
4 changes: 2 additions & 2 deletions kernel/sched_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static int show_schedstat(struct seq_file *seq, void *v)

#ifdef CONFIG_SMP
/* domain-specific stats */
preempt_disable();
rcu_read_lock();
for_each_domain(cpu, sd) {
enum cpu_idle_type itype;

Expand All @@ -64,7 +64,7 @@ static int show_schedstat(struct seq_file *seq, void *v)
sd->ttwu_wake_remote, sd->ttwu_move_affine,
sd->ttwu_move_balance);
}
preempt_enable();
rcu_read_unlock();
#endif
}
kfree(mask_str);
Expand Down

0 comments on commit cd4ae6a

Please sign in to comment.