rcu: Add debug check for too many rcu_read_unlock()
authorPaul E. McKenney <[email protected]>
Tue, 5 Jan 2010 00:04:01 +0000 (16:04 -0800)
committerIngo Molnar <[email protected]>
Wed, 13 Jan 2010 08:06:06 +0000 (09:06 +0100)
TREE_PREEMPT_RCU maintains an rcu_read_lock_nesting counter in
the task structure, which happens to be a signed int.  So this
patch adds a check for this counter being negative at the end of
__rcu_read_unlock(). This check is under CONFIG_PROVE_LOCKING,
so can be thought of as being part of lockdep.

Signed-off-by: Paul E. McKenney <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
LKML-Reference: <12626498423064-git-send-email->
Signed-off-by: Ingo Molnar <[email protected]>
kernel/rcutree_plugin.h

index f11ebd44b454e36e98cd1d82588dbffedea831fa..e77cdf321e13ebbbe910dc92fca4d8483c633408 100644 (file)
@@ -304,6 +304,9 @@ void __rcu_read_unlock(void)
        if (--ACCESS_ONCE(t->rcu_read_lock_nesting) == 0 &&
            unlikely(ACCESS_ONCE(t->rcu_read_unlock_special)))
                rcu_read_unlock_special(t);
+#ifdef CONFIG_PROVE_LOCKING
+       WARN_ON_ONCE(ACCESS_ONCE(t->rcu_read_lock_nesting) < 0);
+#endif /* #ifdef CONFIG_PROVE_LOCKING */
 }
 EXPORT_SYMBOL_GPL(__rcu_read_unlock);