projects
/
openwrt
/
staging
/
blogic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
36ce988
)
sched: Add missing rcu protection to wake_up_all_idle_cpus
author
Andy Lutomirski
<
[email protected]
>
Sat, 29 Nov 2014 16:13:51 +0000
(08:13 -0800)
committer
Ingo Molnar
<
[email protected]
>
Mon, 8 Dec 2014 10:44:19 +0000
(11:44 +0100)
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 <
[email protected]
>
Reviewed-by: Chuansheng Liu <
[email protected]
>
Cc: Peter Zijlstra <
[email protected]
>
Link:
http://lkml.kernel.org/r/729365dddca178506dfd0a9451006344cd6808bc.1417277372.git.luto@amacapital.net
Signed-off-by: Ingo Molnar <
[email protected]
>
kernel/sched/core.c
patch
|
blob
|
history
diff --git
a/kernel/sched/core.c
b/kernel/sched/core.c
index d44d0c59122bb90c1ead871c24b26f8073d21995..88f49bc935ed3e519892eefe9bcff536d810d4df 100644
(file)
--- a/
kernel/sched/core.c
+++ b/
kernel/sched/core.c
@@
-1628,8
+1628,10
@@
void wake_up_if_idle(int cpu)
struct rq *rq = cpu_rq(cpu);
unsigned long flags;
- if (!is_idle_task(rq->curr))
- return;
+ rcu_read_lock();
+
+ if (!is_idle_task(rcu_dereference(rq->curr)))
+ goto out;
if (set_nr_if_polling(rq->idle)) {
trace_sched_wake_idle_without_ipi(cpu);
@@
-1640,6
+1642,9
@@
void wake_up_if_idle(int cpu)
/* Else cpu is not in idle, do nothing here */
raw_spin_unlock_irqrestore(&rq->lock, flags);
}
+
+out:
+ rcu_read_unlock();
}
bool cpus_share_cache(int this_cpu, int that_cpu)