Skip to contentSkip to conversation

lockdep: show held locks when showing a stackdump

PATCH In review Ingo Molnar 1 participant 2 messages Nov 16, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lockdep: show held locks when showing a stackdump

Subject: [patch] lockdep: show held locks when showing a stackdump
From: Ingo Molnar <[email protected]>

lockdep can be used to print held locks when printing a backtrace. This can be useful when debugging things like 'scheduling while atomic' asserts.

---
 arch/i386/kernel/traps.c   |    1 +
 arch/x86_64/kernel/traps.c |    1 +
 2 files changed, 2 insertions(+)
arch/i386/kernel/traps.c +1 -0
Index: linux/arch/i386/kernel/traps.c
===================================================================
@@ -318,6 +318,7 @@ static void show_stack_log_lvl(struct ta
 	}
 	printk("\n%sCall Trace:\n", log_lvl);
 	show_trace_log_lvl(task, regs, esp, log_lvl);
+	debug_show_held_locks(task);
 }
 
 void show_stack(struct task_struct *task, unsigned long *esp)
arch/x86_64/kernel/traps.c +1 -0
Index: linux/arch/x86_64/kernel/traps.c
===================================================================
@@ -405,6 +405,7 @@ show_trace(struct task_struct *tsk, stru
 	printk("\nCall Trace:\n");
 	dump_trace(tsk, regs, stack, &print_trace_ops, NULL);
 	printk("\n");
+	debug_show_held_locks(tsk);
 }
 
 static void
#1 lore raw
Quoted 6 lines · Ingo Molnar

Subject: [patch] lockdep: show held locks when showing a stackdump
From: Ingo Molnar <[email protected]>

lockdep can be used to print held locks when printing a backtrace. This can be useful when debugging things like 'scheduling while atomic' asserts.

on x86_64 this also needs the patch below - NULL means 'current'.

Ingo

kernel/lockdep.c +5 -1
Index: linux/kernel/lockdep.c
===================================================================
@@ -395,7 +395,11 @@ static void print_lock(struct held_lock 
 
 static void lockdep_print_held_locks(struct task_struct *curr)
 {
-	int i, depth = curr->lockdep_depth;
+	int i, depth;
+
+	if (!curr)
+		curr = current;
+	depth = curr->lockdep_depth;
 
 	if (!depth) {
 		printk("no locks held by %s/%d.\n", curr->comm, curr->pid);