Skip to contentSkip to conversation

rcu: Make RCU lockdep check the lockdep_recursion variable

PATCH In review Paul E. McKenney 1 participant 2 messages Apr 15, 2010 – Apr 19, 2010 RCU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rcu: Make RCU lockdep check the lockdep_recursion variable

The lockdep facility temporarily disables lockdep checking by incrementing the current->lockdep_recursion variable. Such disabling happens in NMIs and in other situations where lockdep might expect to recurse on itself. This patch therefore checks current->lockdep_recursion, disabling RCU lockdep splats when this variable is non-zero. In addition, this patch removes the "likely()", as suggested by Lai Jiangshan.

---

 include/linux/rcupdate.h |    5 +----
 kernel/rcupdate.c        |    7 +++++++
 2 files changed, 8 insertions(+), 4 deletions(-)
include/linux/rcupdate.h +1 -4
index 9f1ddfe..07db2fe 100644
@@ -101,10 +101,7 @@ extern struct lockdep_map rcu_sched_lock_map;
 # define rcu_read_release_sched() \
 		lock_release(&rcu_sched_lock_map, 1, _THIS_IP_)
 
-static inline int debug_lockdep_rcu_enabled(void)
-{
-	return likely(rcu_scheduler_active && debug_locks);
-}
+extern int debug_lockdep_rcu_enabled(void);
 
 /**
  * rcu_read_lock_held - might we be in RCU read-side critical section?
kernel/rcupdate.c +7 -0
index 63fe254..03a7ea1 100644
@@ -69,6 +69,13 @@ EXPORT_SYMBOL_GPL(rcu_scheduler_active);
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 
+int debug_lockdep_rcu_enabled(void)
+{
+	return rcu_scheduler_active && debug_locks &&
+	       current->lockdep_recursion == 0;
+}
+EXPORT_SYMBOL_GPL(debug_lockdep_rcu_enabled);
+
 /**
  * rcu_read_lock_bh_held - might we be in RCU-bh read-side critical section?
  *
#1 lore raw
Commit-ID:  bc293d62b26ec590afc90a9e0a31c45d355b7bd8
Gitweb:     http://git.kernel.org/tip/bc293d62b26ec590afc90a9e0a31c45d355b7bd8
Author:     Paul E. McKenney <[email protected]>
AuthorDate: Thu, 15 Apr 2010 12:50:39 -0700
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 19 Apr 2010 08:37:19 +0200

rcu: Make RCU lockdep check the lockdep_recursion variable

The lockdep facility temporarily disables lockdep checking by incrementing the current->lockdep_recursion variable. Such disabling happens in NMIs and in other situations where lockdep might expect to recurse on itself.

This patch therefore checks current->lockdep_recursion, disabling RCU lockdep splats when this variable is non-zero. In addition, this patch removes the "likely()", as suggested by Lai Jiangshan.

LKML-Reference: <[email protected]>

---
 include/linux/rcupdate.h |    5 +----
 kernel/rcupdate.c        |    7 +++++++
 2 files changed, 8 insertions(+), 4 deletions(-)
include/linux/rcupdate.h +1 -4
index 9f1ddfe..07db2fe 100644
@@ -101,10 +101,7 @@ extern struct lockdep_map rcu_sched_lock_map;
 # define rcu_read_release_sched() \
 		lock_release(&rcu_sched_lock_map, 1, _THIS_IP_)
 
-static inline int debug_lockdep_rcu_enabled(void)
-{
-	return likely(rcu_scheduler_active && debug_locks);
-}
+extern int debug_lockdep_rcu_enabled(void);
 
 /**
  * rcu_read_lock_held - might we be in RCU read-side critical section?
kernel/rcupdate.c +7 -0
index 63fe254..03a7ea1 100644
@@ -69,6 +69,13 @@ EXPORT_SYMBOL_GPL(rcu_scheduler_active);
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 
+int debug_lockdep_rcu_enabled(void)
+{
+	return rcu_scheduler_active && debug_locks &&
+	       current->lockdep_recursion == 0;
+}
+EXPORT_SYMBOL_GPL(debug_lockdep_rcu_enabled);
+
 /**
  * rcu_read_lock_bh_held - might we be in RCU-bh read-side critical section?
  *