From 52ccdf90b9ce19602252b169f59c0bb4e141bee6 Mon Sep 17 00:00:00 2001 From: Elliot Berman Date: Thu, 17 Jun 2021 12:51:25 -0700 Subject: [PATCH] FROMLIST: lockdep: Remove console_verbose when disable lock debugging debug_locks_off can be called in scenarios where the kernel doesn't immediately panic. For instance, debug_locks_off is called with a mismatched preempt_count or when registering an improper lockdep map and fails the sanity check for lock-class key [1]. Both of these issues were discovered in vendor kernel code and were fixed. When console_verbose is enabled, we have found that kernel tends to be unstable because it is spending much of its time printing to the serial log, so the system may miss watchdog pats. We explicitly set our system to reduce the loglevel in order to prevent such scenarios, however lockdep can circumvent the commandline setting. Thus, when we ran into the kernel bugs, we first ended up trying to debug why the kernel wasn't able to respond to watchdog pets and why it was spending all of its time flushing the console, which did not quickly lead us to the "real" lock dependency issue. Remove the console_verbose when turning off lock debugging. Other debug facilities, such as KASAN, KFENCE, SPINLOCK_DEBUG, and DEBUG_OBJECTS don't set console_verbose when issues are detected. Current other uses for console_verbose are in situations where kernel is in a panic path. [1]: kernel/locking/lockdep.c:lockdep_init_map_waits:4617 Signed-off-by: Elliot Berman Link: https://lore.kernel.org/lkml/20210623045559.15750-1-eberman@codeaurora.org/ Bug: 191903062 Change-Id: If33587c49d316155a1745c9e0ef1a9ce23410a2b Signed-off-by: Elliot Berman --- lib/debug_locks.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/debug_locks.c b/lib/debug_locks.c index 06d3135bd184..f91b5d31f63c 100644 --- a/lib/debug_locks.c +++ b/lib/debug_locks.c @@ -38,12 +38,8 @@ EXPORT_SYMBOL_GPL(debug_locks_silent); */ noinstr int debug_locks_off(void) { - if (debug_locks && __debug_locks_off()) { - if (!debug_locks_silent) { - console_verbose(); - return 1; - } - } + if (debug_locks && __debug_locks_off() && !debug_locks_silent) + return 1; return 0; } EXPORT_SYMBOL_GPL(debug_locks_off);