diff options
author | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2011-11-17 19:55:56 -0500 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2012-02-21 12:06:12 -0500 |
commit | 29e37d814188ac8d60f2120583704d3ef6d634b4 (patch) | |
tree | 1619796097a7aead2c9bec3ba10a8b84f2643013 /kernel/rcutiny.c | |
parent | ce5df97be530e4746bf9a4ac14589a1cfdfd8efc (diff) |
rcu: Allow nesting of rcu_idle_enter() and rcu_idle_exit()
Use of RCU in the idle loop is incorrect, quite a few instances of
just that have made their way into mainline, primarily event tracing.
The problem with RCU read-side critical sections on CPUs that RCU believes
to be idle is that RCU is completely ignoring the CPU, along with any
attempts and RCU read-side critical sections.
The approaches of eliminating the offending uses and of pushing the
definition of idle down beyond the offending uses have both proved
impractical. The new approach is to encapsulate offending uses of RCU
with rcu_idle_exit() and rcu_idle_enter(), but this requires nesting
for code that is invoked both during idle and and during normal execution.
Therefore, this commit modifies rcu_idle_enter() and rcu_idle_exit() to
permit nesting.
Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Acked-by: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>
Diffstat (limited to 'kernel/rcutiny.c')
-rw-r--r-- | kernel/rcutiny.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c index 4eb34fcc2a75..c8b0e1582c04 100644 --- a/kernel/rcutiny.c +++ b/kernel/rcutiny.c | |||
@@ -53,7 +53,7 @@ static void __call_rcu(struct rcu_head *head, | |||
53 | 53 | ||
54 | #include "rcutiny_plugin.h" | 54 | #include "rcutiny_plugin.h" |
55 | 55 | ||
56 | static long long rcu_dynticks_nesting = DYNTICK_TASK_NESTING; | 56 | static long long rcu_dynticks_nesting = DYNTICK_TASK_EXIT_IDLE; |
57 | 57 | ||
58 | /* Common code for rcu_idle_enter() and rcu_irq_exit(), see kernel/rcutree.c. */ | 58 | /* Common code for rcu_idle_enter() and rcu_irq_exit(), see kernel/rcutree.c. */ |
59 | static void rcu_idle_enter_common(long long oldval) | 59 | static void rcu_idle_enter_common(long long oldval) |
@@ -88,7 +88,12 @@ void rcu_idle_enter(void) | |||
88 | 88 | ||
89 | local_irq_save(flags); | 89 | local_irq_save(flags); |
90 | oldval = rcu_dynticks_nesting; | 90 | oldval = rcu_dynticks_nesting; |
91 | rcu_dynticks_nesting = 0; | 91 | WARN_ON_ONCE((rcu_dynticks_nesting & DYNTICK_TASK_NEST_MASK) == 0); |
92 | if ((rcu_dynticks_nesting & DYNTICK_TASK_NEST_MASK) == | ||
93 | DYNTICK_TASK_NEST_VALUE) | ||
94 | rcu_dynticks_nesting = 0; | ||
95 | else | ||
96 | rcu_dynticks_nesting -= DYNTICK_TASK_NEST_VALUE; | ||
92 | rcu_idle_enter_common(oldval); | 97 | rcu_idle_enter_common(oldval); |
93 | local_irq_restore(flags); | 98 | local_irq_restore(flags); |
94 | } | 99 | } |
@@ -140,8 +145,11 @@ void rcu_idle_exit(void) | |||
140 | 145 | ||
141 | local_irq_save(flags); | 146 | local_irq_save(flags); |
142 | oldval = rcu_dynticks_nesting; | 147 | oldval = rcu_dynticks_nesting; |
143 | WARN_ON_ONCE(oldval != 0); | 148 | WARN_ON_ONCE(rcu_dynticks_nesting < 0); |
144 | rcu_dynticks_nesting = DYNTICK_TASK_NESTING; | 149 | if (rcu_dynticks_nesting & DYNTICK_TASK_NEST_MASK) |
150 | rcu_dynticks_nesting += DYNTICK_TASK_NEST_VALUE; | ||
151 | else | ||
152 | rcu_dynticks_nesting = DYNTICK_TASK_EXIT_IDLE; | ||
145 | rcu_idle_exit_common(oldval); | 153 | rcu_idle_exit_common(oldval); |
146 | local_irq_restore(flags); | 154 | local_irq_restore(flags); |
147 | } | 155 | } |