From: Ingo Molnar show held locks when printing a backtrace. Signed-off-by: Ingo Molnar Signed-off-by: Andrew Morton --- arch/i386/kernel/traps.c | 1 + arch/x86_64/kernel/traps.c | 1 + kernel/lockdep.c | 9 +++++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff -puN arch/i386/kernel/traps.c~lockdep-show-held-locks-when-showing-a-stackdump arch/i386/kernel/traps.c --- a/arch/i386/kernel/traps.c~lockdep-show-held-locks-when-showing-a-stackdump +++ a/arch/i386/kernel/traps.c @@ -267,6 +267,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) diff -puN arch/x86_64/kernel/traps.c~lockdep-show-held-locks-when-showing-a-stackdump arch/x86_64/kernel/traps.c --- a/arch/x86_64/kernel/traps.c~lockdep-show-held-locks-when-showing-a-stackdump +++ a/arch/x86_64/kernel/traps.c @@ -362,6 +362,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 diff -puN kernel/lockdep.c~lockdep-show-held-locks-when-showing-a-stackdump kernel/lockdep.c --- a/kernel/lockdep.c~lockdep-show-held-locks-when-showing-a-stackdump +++ a/kernel/lockdep.c @@ -422,7 +422,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); @@ -2784,7 +2788,8 @@ EXPORT_SYMBOL_GPL(debug_show_all_locks); void debug_show_held_locks(struct task_struct *task) { - lockdep_print_held_locks(task); + if (task == current) + lockdep_print_held_locks(task); } EXPORT_SYMBOL_GPL(debug_show_held_locks); _