]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
rcu: Make rcu_sleep_check() also check rcu_lock_map
authorPaul E. McKenney <paul.mckenney@linaro.org>
Thu, 12 Jan 2012 21:49:19 +0000 (13:49 -0800)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Tue, 21 Feb 2012 17:03:46 +0000 (09:03 -0800)
Although it is OK to be preempted in an RCU read-side critical section
for TREE_PREEMPT_RCU, it is definitely not OK to be preempted, block,
or might_sleep() within an RCU read-side critical section for TREE_RCU.
Unfortunately, rcu_might_sleep() currently only checks for RCU-bh and
RCU-sched read-side critical sections.  This commit therefore makes
rcu_might_sleep() check for RCU read-side critical sections, but only
in TREE_RCU builds.

Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
include/linux/rcupdate.h

index a67d5f1072eaee5dd8d7635cde7553b1b60bdc07..6df0ae19781097b323c56eff1e3fb8f44ade4e86 100644 (file)
@@ -381,8 +381,22 @@ extern int rcu_my_thread_group_empty(void);
                }                                                       \
        } while (0)
 
+#if defined(CONFIG_PROVE_RCU) && !defined(CONFIG_PREEMPT_RCU)
+static inline void rcu_preempt_sleep_check(void)
+{
+       rcu_lockdep_assert(!lock_is_held(&rcu_lock_map),
+                          "Illegal context switch in RCU read-side "
+                          "critical section");
+}
+#else /* #ifdef CONFIG_PROVE_RCU */
+static inline void rcu_preempt_sleep_check(void)
+{
+}
+#endif /* #else #ifdef CONFIG_PROVE_RCU */
+
 #define rcu_sleep_check()                                              \
        do {                                                            \
+               rcu_preempt_sleep_check();                              \
                rcu_lockdep_assert(!lock_is_held(&rcu_bh_lock_map),     \
                                   "Illegal context switch in RCU-bh"   \
                                   " read-side critical section");      \