RCU, RCU-bh, and RCU-sched read-side critical sections are forbidden in the inner idle loop, that is, between the rcu_idle_enter() and the rcu_idle_exit() -- RCU will happily ignore any such read-side critical sections. However, things like powertop need tracepoints in the inner idle loop. This commit therefore provides an RCU_NONIDLE() macro that can be used to wrap code in the idle loop that requires RCU read-side critical sections.
Unified · Split
| @@ -190,6 +190,33 @@ extern void rcu_idle_exit(void); · 189 unmodified lines | ||
| 190 | 190 | extern void rcu_irq_enter(void); |
| 191 | 191 | extern void rcu_irq_exit(void); |
| 192 | 192 | |
| 193 | +/** | |
| 194 | + * RCU_NONIDLE - Indicate idle-loop code that needs RCU readers | |
| 195 | + * @a: Code that RCU needs to pay attention to. | |
| 196 | + * | |
| 197 | + * RCU, RCU-bh, and RCU-sched read-side critical sections are forbidden | |
| 198 | + * in the inner idle loop, that is, between the rcu_idle_enter() and | |
| 199 | + * the rcu_idle_exit() -- RCU will happily ignore any such read-side | |
| 200 | + * critical sections. However, things like powertop need tracepoints | |
| 201 | + * in the inner idle loop. | |
| 202 | + * | |
| 203 | + * This macro provides the way out: RCU_NONIDLE(do_something_with_RCU()) | |
| 204 | + * will tell RCU that it needs to pay attending, invoke its argument | |
| 205 | + * (in this example, a call to the do_something_with_RCU() function), | |
| 206 | + * and then tell RCU to go back to ignoring this CPU. It is permissible | |
| 207 | + * to nest RCU_NONIDLE() wrappers, but the nesting level is currently | |
| 208 | + * quite limited. If deeper nesting is required, it will be necessary | |
| 209 | + * to adjust DYNTICK_TASK_NESTING_VALUE accordingly. | |
| 210 | + * | |
| 211 | + * This macro may be used from process-level code only. | |
| 212 | + */ | |
| 213 | +#define RCU_NONIDLE(a) \ | |
| 214 | + do { \ | |
| 215 | + rcu_idle_exit(); \ | |
| 216 | + do { a; } while (0); \ | |
| 217 | + rcu_idle_enter(); \ | |
| 218 | + } while (0) | |
| 219 | + | |
| 193 | 220 | /* |
| 194 | 221 | * Infrastructure to implement the synchronize_() primitives in |
| 195 | 222 | * TREE_RCU and rcu_barrier_() primitives in TINY_RCU. |
| @@ -97,6 +97,7 @@ void rcu_idle_enter(void) · 96 unmodified lines | ||
| 97 | 97 | rcu_idle_enter_common(oldval); |
| 98 | 98 | local_irq_restore(flags); |
| 99 | 99 | } |
| 100 | +EXPORT_SYMBOL_GPL(rcu_idle_enter); | |
| 100 | 101 | |
| 101 | 102 | /* |
| 102 | 103 | * Exit an interrupt handler towards idle. |
| @@ -153,6 +154,7 @@ void rcu_idle_exit(void) · 50 unmodified lines | ||
| 153 | 154 | rcu_idle_exit_common(oldval); |
| 154 | 155 | local_irq_restore(flags); |
| 155 | 156 | } |
| 157 | +EXPORT_SYMBOL_GPL(rcu_idle_exit); | |
| 156 | 158 | |
| 157 | 159 | /* |
| 158 | 160 | * Enter an interrupt handler, moving away from idle. |
| @@ -402,6 +402,7 @@ void rcu_idle_enter(void) · 401 unmodified lines | ||
| 402 | 402 | rcu_idle_enter_common(rdtp, oldval); |
| 403 | 403 | local_irq_restore(flags); |
| 404 | 404 | } |
| 405 | +EXPORT_SYMBOL_GPL(rcu_idle_enter); | |
| 405 | 406 | |
| 406 | 407 | /** |
| 407 | 408 | * rcu_irq_exit - inform RCU that current CPU is exiting irq towards idle |
| @@ -493,6 +494,7 @@ void rcu_idle_exit(void) · 85 unmodified lines | ||
| 493 | 494 | rcu_idle_exit_common(rdtp, oldval); |
| 494 | 495 | local_irq_restore(flags); |
| 495 | 496 | } |
| 497 | +EXPORT_SYMBOL_GPL(rcu_idle_exit); | |
| 496 | 498 | |
| 497 | 499 | /** |
| 498 | 500 | * rcu_irq_enter - inform RCU that current CPU is entering irq away from idle |