Re: [PATCH] locking/lockdep: add debug_show_all_lock_holders()

From: Tetsuo Handa
Date: Fri Aug 12 2022 - 07:51:03 EST


On 2022/08/11 20:32, Tetsuo Handa wrote:
> I wish that lockdep continues tracking locks even after something went
> wrong (i.e. debug_locks remains 1), for recently I sometimes encounter
> problems that disable lockdep during boot stage.
>
> It would be noisy to report possibility of e.g. circular locking dependency
> every time due to keeping debug_locks enabled. But tracking locks even
> after something went wrong will help debug_show_all_lock_holders() to
> survive problems during boot stage.

I forgot to write. I'm not expecting lockdep to report the same problem forever.
Reporting possibility of each problem pattern (e.g. circular locking dependency)
up to once, by using cmpxchg() inside reporting functions that call printk(),
would be enough.

I'm expecting lockdep to continue working without calling printk() even after
one of problem patterns (e.g. circular locking dependency) was printk()ed, so that
debug_show_all_locks()/debug_show_all_lock_holders() can call printk() when needed.

>
> Changing debug_locks behavior is a future patch. For now, this patch alone
> will help debugging Greg's usb.git#usb-testing tree which is generating
> many "INFO: task hung in" reports.
>



On 2022/08/12 4:00, Waiman Long wrote:
>
> BTW, this function will produce much more verbose output. Typically how many line
> of debug outputs are going to be dumped to the console by calling this function?

Regarding amount of output, I can't estimate lines printed because it depends on how
many threads are holding locks. Thus, here are some examples obtained by this patch.

https://syzkaller.appspot.com/text?tag=CrashReport&x=17c78aba080000
https://syzkaller.appspot.com/text?tag=CrashReport&x=13219e6b080000
https://syzkaller.appspot.com/text?tag=CrashReport&x=166c402d080000
https://syzkaller.appspot.com/text?tag=CrashReport&x=15c6ff73080000

We can introduce flags like panic_printk variable in kernel/panic.c if amount of
output (or latency by output) turns out to be a problem.

I guess that the most significant switch would be console_verbose() in
check_hung_task() which forces synchronous output (causing latency problem
if there are many lines to output). If printk() messages are not printed to
consoles, latency by debug_show_all_lock_holders() will be negligible.