RE: [外部邮件] Re: [PATCH][v4] hung_task: Panic when there are more than N hung tasks at the same time

Li,Rongqing
2025-11-19T15:56:25Z

> LGTM. It works as expected, thanks!
>
> On 2025/10/15 14:36, lirongqing wrote:
> > From: Li RongQing <lirongqing@baidu.com>
>
> For the commit message, I'd suggest the following for better clarity:
>
> ```
> The hung_task_panic sysctl is currently a blunt instrument: it's all or nothing.
>
> Panicking on a single hung task can be an overreaction to a transient glitch. A
> more reliable indicator of a systemic problem is when multiple tasks hang
> simultaneously.
>
> Extend hung_task_panic to accept an integer threshold, allowing the kernel
> to panic only when N hung tasks are detected in a single scan. This provides
> finer control to distinguish between isolated incidents and system-wide
> failures.
>
> The accepted values are:
> - 0: Don't panic (unchanged)
> - 1: Panic on the first hung task (unchanged)
> - N > 1: Panic after N hung tasks are detected in a single scan
>
> The original behavior is preserved for values 0 and 1, maintaining full
> backward compatibility.
> ```
>
> If you agree, likely no need to resend - Andrew could pick it up directly when
> applying :)
>

This is better;

Andrew, could you pick it up directly

Thanks

-Li

> >
> > Currently, when 'hung_task_panic' is enabled, the kernel panics
> > immediately upon detecting the first hung task. However, some hung
> > tasks are transient and allow system recovery, while persistent hangs
> > should trigger a panic when accumulating beyond a threshold.
> >
> > Extend the 'hung_task_panic' sysctl to accept a threshold value
> > specifying the number of hung tasks that must be detected before
> > triggering a kernel panic. This provides finer control for
> > environments where transient hangs may occur but persistent hangs
> should be fatal.
> >
> > The sysctl now accepts:
> > - 0: don't panic (maintains original behavior)
> > - 1: panic on first hung task (maintains original behavior)
> > - N > 1: panic after N hung tasks are detected in a single scan
> >
> > This maintains backward compatibility while providing flexibility for
> > different hang scenarios.
> >
> > Signed-off-by: Li RongQing <lirongqing@baidu.com>
> > Cc: Andrew Jeffery <andrew@codeconstruct.com.au>
> > Cc: Anshuman Khandual <anshuman.khandual@arm.com>
> > Cc: Arnd Bergmann <arnd@arndb.de>
> > Cc: David Hildenbrand <david@redhat.com>
> > Cc: Florian Wesphal <fw@strlen.de>
> > Cc: Jakub Kacinski <kuba@kernel.org>
> > Cc: Jason A. Donenfeld <jason@zx2c4.com>
> > Cc: Joel Granados <joel.granados@kernel.org>
> > Cc: Joel Stanley <joel@jms.id.au>
> > Cc: Jonathan Corbet <corbet@lwn.net>
> > Cc: Kees Cook <kees@kernel.org>
> > Cc: Lance Yang <lance.yang@linux.dev>
> > Cc: Liam Howlett <liam.howlett@oracle.com>
> > Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> > Cc: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
> > Cc: "Paul E . McKenney" <paulmck@kernel.org>
> > Cc: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
> > Cc: Petr Mladek <pmladek@suse.com>
> > Cc: Phil Auld <pauld@redhat.com>
> > Cc: Randy Dunlap <rdunlap@infradead.org>
> > Cc: Russell King <linux@armlinux.org.uk>
> > Cc: Shuah Khan <shuah@kernel.org>
> > Cc: Simon Horman <horms@kernel.org>
> > Cc: Stanislav Fomichev <sdf@fomichev.me>
> > Cc: Steven Rostedt <rostedt@goodmis.org>
> > ---
>
> So:
>
> Reviewed-by: Lance Yang <lance.yang@linux.dev>
> Tested-by: Lance Yang <lance.yang@linux.dev>
>
> Cheers,
> Lance