diff options
author | Paul E. McKenney <paul.mckenney@linaro.org> | 2011-10-03 14:38:52 -0400 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2011-12-11 13:31:27 -0500 |
commit | 34240697d619c439c55f21989680024dcb604aab (patch) | |
tree | 5fa80ddb82706121520677e8e700e5081f5edaa1 /kernel/rcutree.c | |
parent | 2c01531f08f8ba663a20d8472a3032f6df133b6e (diff) |
rcu: Disable preemption in rcu_is_cpu_idle()
Because rcu_is_cpu_idle() is to be used to check for extended quiescent
states in RCU-preempt read-side critical sections, it cannot assume that
preemption is disabled. And preemption must be disabled when accessing
the dyntick-idle state, because otherwise the following sequence of events
could occur:
1. Task A on CPU 1 enters rcu_is_cpu_idle() and picks up the pointer
to CPU 1's per-CPU variables.
2. Task B preempts Task A and starts running on CPU 1.
3. Task A migrates to CPU 2.
4. Task B blocks, leaving CPU 1 idle.
5. Task A continues execution on CPU 2, accessing CPU 1's dyntick-idle
information using the pointer fetched in step 1 above, and finds
that CPU 1 is idle.
6. Task A therefore incorrectly concludes that it is executing in
an extended quiescent state, possibly issuing a spurious splat.
Therefore, this commit disables preemption within the rcu_is_cpu_idle()
function.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Diffstat (limited to 'kernel/rcutree.c')
-rw-r--r-- | kernel/rcutree.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/kernel/rcutree.c b/kernel/rcutree.c index 1c40326724f6..69b6cdd4f944 100644 --- a/kernel/rcutree.c +++ b/kernel/rcutree.c | |||
@@ -556,12 +556,16 @@ void rcu_nmi_exit(void) | |||
556 | * rcu_is_cpu_idle - see if RCU thinks that the current CPU is idle | 556 | * rcu_is_cpu_idle - see if RCU thinks that the current CPU is idle |
557 | * | 557 | * |
558 | * If the current CPU is in its idle loop and is neither in an interrupt | 558 | * If the current CPU is in its idle loop and is neither in an interrupt |
559 | * or NMI handler, return true. The caller must have at least disabled | 559 | * or NMI handler, return true. |
560 | * preemption. | ||
561 | */ | 560 | */ |
562 | int rcu_is_cpu_idle(void) | 561 | int rcu_is_cpu_idle(void) |
563 | { | 562 | { |
564 | return (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0; | 563 | int ret; |
564 | |||
565 | preempt_disable(); | ||
566 | ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0; | ||
567 | preempt_enable(); | ||
568 | return ret; | ||
565 | } | 569 | } |
566 | 570 | ||
567 | #endif /* #ifdef CONFIG_PROVE_RCU */ | 571 | #endif /* #ifdef CONFIG_PROVE_RCU */ |