diff options
author | Paul E. McKenney <paul.mckenney@linaro.org> | 2012-01-23 15:41:26 -0500 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2012-02-21 12:06:03 -0500 |
commit | c0d6d01bffdce19fa19baad6cb8cc3eed7bfd6f5 (patch) | |
tree | ea4c20ddc87b94d7bef2402fe6dbe3186be263c2 /kernel/rcupdate.c | |
parent | 24cd7fd0eaa0d9f5e197ff77a83b006a86696068 (diff) |
rcu: Check for illegal use of RCU from offlined CPUs
Although it is legal to use RCU during early boot, it is anything
but legal to use RCU at runtime from an offlined CPU. After all, RCU
explicitly ignores offlined CPUs. This commit therefore adds checks
for runtime use of RCU from offlined CPUs.
These checks are not perfect, in particular, they can be subverted
through use of things like rcu_dereference_raw(). Note that it is not
possible to put checks in rcu_read_lock() and friends due to the fact
that these primitives are used in code that might be used under either
RCU or lock-based protection, which means that checking rcu_read_lock()
gets you fat piles of false positives.
Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Diffstat (limited to 'kernel/rcupdate.c')
-rw-r--r-- | kernel/rcupdate.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c index 2bc4e135ff23..a86f1741cc27 100644 --- a/kernel/rcupdate.c +++ b/kernel/rcupdate.c | |||
@@ -88,6 +88,9 @@ EXPORT_SYMBOL_GPL(debug_lockdep_rcu_enabled); | |||
88 | * section. | 88 | * section. |
89 | * | 89 | * |
90 | * Check debug_lockdep_rcu_enabled() to prevent false positives during boot. | 90 | * Check debug_lockdep_rcu_enabled() to prevent false positives during boot. |
91 | * | ||
92 | * Note that rcu_read_lock() is disallowed if the CPU is either idle or | ||
93 | * offline from an RCU perspective, so check for those as well. | ||
91 | */ | 94 | */ |
92 | int rcu_read_lock_bh_held(void) | 95 | int rcu_read_lock_bh_held(void) |
93 | { | 96 | { |
@@ -95,6 +98,8 @@ int rcu_read_lock_bh_held(void) | |||
95 | return 1; | 98 | return 1; |
96 | if (rcu_is_cpu_idle()) | 99 | if (rcu_is_cpu_idle()) |
97 | return 0; | 100 | return 0; |
101 | if (!rcu_lockdep_current_cpu_online()) | ||
102 | return 0; | ||
98 | return in_softirq() || irqs_disabled(); | 103 | return in_softirq() || irqs_disabled(); |
99 | } | 104 | } |
100 | EXPORT_SYMBOL_GPL(rcu_read_lock_bh_held); | 105 | EXPORT_SYMBOL_GPL(rcu_read_lock_bh_held); |