Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

printk, lockdep: Disable lock debugging on zap_locks()

zap_locks() is used by printk() in a last ditch effort to get data
out, clearly we cannot trust lock state after this so make it disable
lock debugging.

Also don't treat printk recursion through lockdep as a normal
recursion bug but try hard to get the lockdep splat out.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-kqxwmo4xz37e1s8w0xopvr0q@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by

Peter Zijlstra and committed by
Ingo Molnar
94d24fc4 7f80850d

+6 -1
+4
include/linux/lockdep.h
··· 343 343 344 344 #define lockdep_assert_held(l) WARN_ON(debug_locks && !lockdep_is_held(l)) 345 345 346 + #define lockdep_recursing(tsk) ((tsk)->lockdep_recursion) 347 + 346 348 #else /* !LOCKDEP */ 347 349 348 350 static inline void lockdep_off(void) ··· 393 391 #define lockdep_depth(tsk) (0) 394 392 395 393 #define lockdep_assert_held(l) do { } while (0) 394 + 395 + #define lockdep_recursing(tsk) (0) 396 396 397 397 #endif /* !LOCKDEP */ 398 398
+2 -1
kernel/printk.c
··· 688 688 689 689 oops_timestamp = jiffies; 690 690 691 + debug_locks_off(); 691 692 /* If a crash is occurring, make sure we can't deadlock */ 692 693 raw_spin_lock_init(&logbuf_lock); 693 694 /* And make sure that we print immediately */ ··· 857 856 * recursion and return - but flag the recursion so that 858 857 * it can be printed at the next appropriate moment: 859 858 */ 860 - if (!oops_in_progress) { 859 + if (!oops_in_progress && !lockdep_recursing(current)) { 861 860 recursion_bug = 1; 862 861 goto out_restore_irqs; 863 862 }