[PATCH 1/1] lockdep: Remove console_verbose when disable lock debugging

From: Elliot Berman
Date: Wed Jun 23 2021 - 00:56:49 EST


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 <eberman@xxxxxxxxxxxxxx>
---
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);
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project