[PATCH] lockdep debugging: give stacktrace for init_error

From: Johannes Berg
Date: Fri Jul 06 2007 - 06:36:17 EST


When I started adding support for lockdep to 64-bit powerpc, I got a
lockdep_init_error and with this patch was able to pinpoint why and
where to put lockdep_init(). Let's support this generally for others
adding lockdep support to their architecture.

Signed-off-by: Johannes Berg <johannes@xxxxxxxxxxxxxxxx>

---
kernel/lockdep.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

--- linux-2.6-git.orig/kernel/lockdep.c 2007-07-05 15:48:17.390241118 +0200
+++ linux-2.6-git/kernel/lockdep.c 2007-07-05 15:58:20.334168396 +0200
@@ -291,6 +291,11 @@ unsigned int max_recursion_depth;
* about it later on, in lockdep_info().
*/
static int lockdep_init_error;
+static unsigned long lockdep_init_trace_data[20];
+static struct stack_trace lockdep_init_trace = {
+ .max_entries = ARRAY_SIZE(lockdep_init_trace_data),
+ .entries = lockdep_init_trace_data,
+};

/*
* Various lockdep statistics:
@@ -1170,6 +1175,7 @@ look_up_lock_class(struct lockdep_map *l
if (unlikely(!lockdep_initialized)) {
lockdep_init();
lockdep_init_error = 1;
+ save_stack_trace(&lockdep_init_trace);
}
#endif

@@ -2636,8 +2642,11 @@ void __init lockdep_info(void)
sizeof(struct held_lock) * MAX_LOCK_DEPTH);

#ifdef CONFIG_DEBUG_LOCKDEP
- if (lockdep_init_error)
- printk("WARNING: lockdep init error! Arch code didnt call lockdep_init() early enough?\n");
+ if (lockdep_init_error) {
+ printk("WARNING: lockdep init error! Arch code didn't call lockdep_init() early enough?\n");
+ printk("Call stack leading to lockdep invocation was:\n");
+ print_stack_trace(&lockdep_init_trace, 0);
+ }
#endif
}



-
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/