提交 067491b7 编写于 作者: P Peter Zijlstra 提交者: Ingo Molnar

sched, nohz: Fix missing RCU read lock

Yong Zhang reported:

 > [ INFO: suspicious RCU usage. ]
 > kernel/sched/fair.c:5091 suspicious rcu_dereference_check() usage!

This is due to the sched_domain stuff being RCU protected and
commit 0b005cf5 ("sched, nohz: Implement sched group, domain
aware nohz idle load balancing") overlooking this fact.

The sd variable only lives inside the for_each_domain() block,
so we only need to wrap that.
Reported-by: NYong Zhang <yong.zhang0@gmail.com>
Tested-by: NYong Zhang <yong.zhang0@gmail.com>
Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>
Link: http://lkml.kernel.org/r/1323264728.32012.107.camel@twinsSigned-off-by: NIngo Molnar <mingo@elte.hu>
上级 cd490c5b
...@@ -5088,23 +5088,28 @@ static inline int nohz_kick_needed(struct rq *rq, int cpu) ...@@ -5088,23 +5088,28 @@ static inline int nohz_kick_needed(struct rq *rq, int cpu)
if (rq->nr_running >= 2) if (rq->nr_running >= 2)
goto need_kick; goto need_kick;
rcu_read_lock();
for_each_domain(cpu, sd) { for_each_domain(cpu, sd) {
struct sched_group *sg = sd->groups; struct sched_group *sg = sd->groups;
struct sched_group_power *sgp = sg->sgp; struct sched_group_power *sgp = sg->sgp;
int nr_busy = atomic_read(&sgp->nr_busy_cpus); int nr_busy = atomic_read(&sgp->nr_busy_cpus);
if (sd->flags & SD_SHARE_PKG_RESOURCES && nr_busy > 1) if (sd->flags & SD_SHARE_PKG_RESOURCES && nr_busy > 1)
goto need_kick; goto need_kick_unlock;
if (sd->flags & SD_ASYM_PACKING && nr_busy != sg->group_weight if (sd->flags & SD_ASYM_PACKING && nr_busy != sg->group_weight
&& (cpumask_first_and(nohz.idle_cpus_mask, && (cpumask_first_and(nohz.idle_cpus_mask,
sched_domain_span(sd)) < cpu)) sched_domain_span(sd)) < cpu))
goto need_kick; goto need_kick_unlock;
if (!(sd->flags & (SD_SHARE_PKG_RESOURCES | SD_ASYM_PACKING))) if (!(sd->flags & (SD_SHARE_PKG_RESOURCES | SD_ASYM_PACKING)))
break; break;
} }
rcu_read_unlock();
return 0; return 0;
need_kick_unlock:
rcu_read_unlock();
need_kick: need_kick:
return 1; return 1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册