diff options
author | Andy Lutomirski <luto@amacapital.net> | 2014-11-29 11:13:51 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2014-12-08 05:44:19 -0500 |
commit | fd7de1e8d5b2b2b35e71332fafb899f584597150 (patch) | |
tree | 7b0ff7aad0d8c984748557dfec52fad02b54a045 /kernel/sched/core.c | |
parent | 36ce98818a4df66c8134c31fd6e768b4119c7a90 (diff) |
sched: Add missing rcu protection to wake_up_all_idle_cpus
Locklessly doing is_idle_task(rq->curr) is only okay because of
RCU protection. The older variant of the broken code checked
rq->curr == rq->idle instead and therefore didn't need RCU.
Fixes: f6be8af1c95d ("sched: Add new API wake_up_if_idle() to wake up the idle cpu")
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Reviewed-by: Chuansheng Liu <chuansheng.liu@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/729365dddca178506dfd0a9451006344cd6808bc.1417277372.git.luto@amacapital.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/sched/core.c')
-rw-r--r-- | kernel/sched/core.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index d44d0c59122b..88f49bc935ed 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -1628,8 +1628,10 @@ void wake_up_if_idle(int cpu) | |||
1628 | struct rq *rq = cpu_rq(cpu); | 1628 | struct rq *rq = cpu_rq(cpu); |
1629 | unsigned long flags; | 1629 | unsigned long flags; |
1630 | 1630 | ||
1631 | if (!is_idle_task(rq->curr)) | 1631 | rcu_read_lock(); |
1632 | return; | 1632 | |
1633 | if (!is_idle_task(rcu_dereference(rq->curr))) | ||
1634 | goto out; | ||
1633 | 1635 | ||
1634 | if (set_nr_if_polling(rq->idle)) { | 1636 | if (set_nr_if_polling(rq->idle)) { |
1635 | trace_sched_wake_idle_without_ipi(cpu); | 1637 | trace_sched_wake_idle_without_ipi(cpu); |
@@ -1640,6 +1642,9 @@ void wake_up_if_idle(int cpu) | |||
1640 | /* Else cpu is not in idle, do nothing here */ | 1642 | /* Else cpu is not in idle, do nothing here */ |
1641 | raw_spin_unlock_irqrestore(&rq->lock, flags); | 1643 | raw_spin_unlock_irqrestore(&rq->lock, flags); |
1642 | } | 1644 | } |
1645 | |||
1646 | out: | ||
1647 | rcu_read_unlock(); | ||
1643 | } | 1648 | } |
1644 | 1649 | ||
1645 | bool cpus_share_cache(int this_cpu, int that_cpu) | 1650 | bool cpus_share_cache(int this_cpu, int that_cpu) |