Re: [PATCH v2] hung_task: Dump blocker task if it is not hung

From: Sergey Senozhatsky
Date: Wed Jul 30 2025 - 22:54:09 EST


On (25/07/31 07:11), Masami Hiramatsu (Google) wrote:
> From: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
>
> Dump the lock blocker task if it is not hung because if the blocker
> task is also hung, it should be dumped by the detector. This will
> de-duplicate the same stackdumps if the blocker task is also blocked
> by another task (and hung).
>
> Suggested-by: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
> Acked-by: Lance Yang <lance.yang@xxxxxxxxx>

Tested-by: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>


Wrote a simple 3 tasks circular lock test (same that I had in real
life). The output looks good:

[ 90.985431] [ T140] INFO: task T1:525 blocked for more than 30 seconds.
[ 90.990981] [ T140] Not tainted 6.16.0-next-20250730-00003-g5865c79d6085-dirty #261
[ 90.996912] [ T140] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 91.001617] [ T140] task:T1 state:D stack:0 pid:525 tgid:525 ppid:2 task_flags:0x208040 flags:0x00004000
[ 91.007564] [ T140] Call Trace:
[ 91.008767] [ T140] <TASK>
[ 91.009872] [ T140] __schedule+0x137f/0x20c0
[ 91.011606] [ T140] schedule+0xdc/0x280
[ 91.013115] [ T140] schedule_preempt_disabled+0x10/0x20
[ 91.015200] [ T140] __mutex_lock+0x721/0x1590
[ 91.016817] [ T140] ? __mutex_lock+0x500/0x1590
[ 91.018074] [ T140] mutex_lock+0x81/0x90
[ 91.019169] [ T140] t1+0x62/0x70
[ 91.020061] [ T140] kthread+0x583/0x6e0
[ 91.021140] [ T140] ? drop_caches_sysctl_handler+0x130/0x130
[ 91.022729] [ T140] ? kthread_blkcg+0xa0/0xa0
[ 91.023921] [ T140] ret_from_fork+0xc8/0x160
[ 91.025091] [ T140] ? kthread_blkcg+0xa0/0xa0
[ 91.026309] [ T140] ret_from_fork_asm+0x11/0x20
[ 91.027577] [ T140] </TASK>
[ 91.028326] [ T140] INFO: task T1:525 is blocked on a mutex likely owned by task T2:526.
[ 91.030404] [ T140] INFO: task T2:526 blocked for more than 30 seconds.
[ 91.031978] [ T140] Not tainted 6.16.0-next-20250730-00003-g5865c79d6085-dirty #261
[ 91.034069] [ T140] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 91.036215] [ T140] task:T2 state:D stack:0 pid:526 tgid:526 ppid:2 task_flags:0x208040 flags:0x00004000
[ 91.039233] [ T140] Call Trace:
[ 91.040084] [ T140] <TASK>
[ 91.040810] [ T140] __schedule+0x137f/0x20c0
[ 91.041954] [ T140] schedule+0xdc/0x280
[ 91.042984] [ T140] schedule_preempt_disabled+0x10/0x20
[ 91.044329] [ T140] __mutex_lock+0x721/0x1590
[ 91.045464] [ T140] ? __mutex_lock+0x500/0x1590
[ 91.046624] [ T140] mutex_lock+0x81/0x90
[ 91.047632] [ T140] t2+0x69/0x70
[ 91.048473] [ T140] kthread+0x583/0x6e0
[ 91.049453] [ T140] ? drop_pagecache_sb+0x200/0x200
[ 91.050686] [ T140] ? kthread_blkcg+0xa0/0xa0
[ 91.051808] [ T140] ret_from_fork+0xc8/0x160
[ 91.052886] [ T140] ? kthread_blkcg+0xa0/0xa0
[ 91.054036] [ T140] ret_from_fork_asm+0x11/0x20
[ 91.055205] [ T140] </TASK>
[ 91.056011] [ T140] INFO: task T2:526 is blocked on a mutex likely owned by task T3:527.
[ 91.058014] [ T140] INFO: task T3:527 blocked for more than 30 seconds.
[ 91.059682] [ T140] Not tainted 6.16.0-next-20250730-00003-g5865c79d6085-dirty #261
[ 91.061708] [ T140] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 91.063825] [ T140] task:T3 state:D stack:0 pid:527 tgid:527 ppid:2 task_flags:0x208040 flags:0x00004000
[ 91.066668] [ T140] Call Trace:
[ 91.067462] [ T140] <TASK>
[ 91.068121] [ T140] __schedule+0x137f/0x20c0
[ 91.069244] [ T140] schedule+0xdc/0x280
[ 91.070264] [ T140] schedule_preempt_disabled+0x10/0x20
[ 91.071723] [ T140] __mutex_lock+0x721/0x1590
[ 91.072848] [ T140] ? __mutex_lock+0x500/0x1590
[ 91.074032] [ T140] mutex_lock+0x81/0x90
[ 91.075054] [ T140] t3+0x23/0x30
[ 91.075932] [ T140] kthread+0x583/0x6e0
[ 91.076953] [ T140] ? t2+0x70/0x70
[ 91.077865] [ T140] ? kthread_blkcg+0xa0/0xa0
[ 91.078974] [ T140] ret_from_fork+0xc8/0x160
[ 91.080109] [ T140] ? kthread_blkcg+0xa0/0xa0
[ 91.081250] [ T140] ret_from_fork_asm+0x11/0x20
[ 91.082530] [ T140] </TASK>
[ 91.083248] [ T140] INFO: task T3:527 is blocked on a mutex likely owned by task T1:525.