[RFC PATCH 3/4] lockdep: split lockdep_init_map()

From: Yong Zhang
Date: Fri Nov 04 2011 - 05:28:50 EST


A new one __lockdep_init_map() is introduced which only initialize
the struct. It will be call in later patch in __lock_set_class()
to reduce recursive call to register_lock_class().

Signed-off-by: Yong Zhang <yong.zhang0@xxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
---
kernel/lockdep.c | 25 ++++++++++++++++++-------
1 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index e7d38fa..3af87ad 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -2949,8 +2949,9 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
/*
* Initialize a lock instance's lock-class mapping info:
*/
-void lockdep_init_map(struct lockdep_map *lock, const char *name,
- struct lock_class_key *key, int subclass)
+static inline int
+__lockdep_init_map(struct lockdep_map *lock, const char *name,
+ struct lock_class_key *key, int subclass)
{
memset(lock, 0, sizeof(*lock));

@@ -2963,7 +2964,7 @@ void lockdep_init_map(struct lockdep_map *lock, const char *name,
*/
if (DEBUG_LOCKS_WARN_ON(!name)) {
lock->name = "NULL";
- return;
+ return 0;
}

lock->name = name;
@@ -2972,7 +2973,7 @@ void lockdep_init_map(struct lockdep_map *lock, const char *name,
* No key, no joy, we need to hash something.
*/
if (DEBUG_LOCKS_WARN_ON(!key))
- return;
+ return 0;
/*
* Sanity check, the lock-class key must be persistent:
*/
@@ -2982,15 +2983,25 @@ void lockdep_init_map(struct lockdep_map *lock, const char *name,
* What it says above ^^^^^, I suggest you read it.
*/
DEBUG_LOCKS_WARN_ON(1);
- return;
+ return 0;
}
lock->key = key;

if (unlikely(!debug_locks))
- return;
+ return 0;
+
+ return 1;
+}
+
+void lockdep_init_map(struct lockdep_map *lock, const char *name,
+ struct lock_class_key *key, int subclass)
+{
+ int ret;

- if (subclass)
+ ret = __lockdep_init_map(lock, name, key, subclass);
+ if (ret && subclass)
register_lock_class(lock, subclass, 1, 0);
+
}
EXPORT_SYMBOL_GPL(lockdep_init_map);

--
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/