netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Li,Rongqing" <lirongqing@baidu.com>
To: Paul Menzel <pmenzel@molgen.mpg.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Lance Yang <lance.yang@linux.dev>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-aspeed@lists.ozlabs.org" <linux-aspeed@lists.ozlabs.org>,
	"wireguard@lists.zx2c4.com" <wireguard@lists.zx2c4.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kselftest@vger.kernel.org"
	<linux-kselftest@vger.kernel.org>,
	Andrew Jeffery <andrew@codeconstruct.com.au>,
	Anshuman Khandual <anshuman.khandual@arm.com>,
	Arnd Bergmann <arnd@arndb.de>,
	David Hildenbrand <david@redhat.com>,
	"Florian Wesphal" <fw@strlen.de>,
	Jakub Kacinski <kuba@kernel.org>,
	"Jason A . Donenfeld" <jason@zx2c4.com>,
	Joel Granados <joel.granados@kernel.org>,
	"Joel Stanley" <joel@jms.id.au>, Jonathan Corbet <corbet@lwn.net>,
	Kees Cook <kees@kernel.org>,
	Liam Howlett <liam.howlett@oracle.com>,
	Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
	"Paul E . McKenney" <paulmck@kernel.org>,
	"Pawan Gupta" <pawan.kumar.gupta@linux.intel.com>,
	Petr Mladek <pmladek@suse.com>, Phil Auld <pauld@redhat.com>,
	Randy Dunlap <rdunlap@infradead.org>,
	"Russell King" <linux@armlinux.org.uk>,
	Shuah Khan <shuah@kernel.org>, Simon Horman <horms@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: RE: [外部邮件] Re: [PATCH][v4] hung_task: Panic when there are more than N hung tasks at the same time
Date: Fri, 17 Oct 2025 02:09:10 +0000	[thread overview]
Message-ID: <d492d12e4e5441a2b51c3415e865fa99@baidu.com> (raw)
In-Reply-To: <906dd11d-26db-4570-840a-e4797748c05c@molgen.mpg.de>


> 
> Am 15.10.25 um 08:36 schrieb lirongqing:
> > From: Li RongQing <lirongqing@baidu.com>
> >
> > 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>
> > ---
> > diff with v3: comments modification, suggested by Lance, Masami, Randy
> > and Petr diff with v2: do not add a new sysctl, extend
> > hung_task_panic, suggested by Kees Cook
> >
> >   Documentation/admin-guide/kernel-parameters.txt      | 20
> +++++++++++++-------
> >   Documentation/admin-guide/sysctl/kernel.rst          |  9 +++++----
> >   arch/arm/configs/aspeed_g5_defconfig                 |  2 +-
> >   kernel/configs/debug.config                          |  2 +-
> >   kernel/hung_task.c                                   | 15
> ++++++++++-----
> >   lib/Kconfig.debug                                    |  9
> +++++----
> >   tools/testing/selftests/wireguard/qemu/kernel.config |  2 +-
> >   7 files changed, 36 insertions(+), 23 deletions(-)
> >
> > diff --git a/Documentation/admin-guide/kernel-parameters.txt
> > b/Documentation/admin-guide/kernel-parameters.txt
> > index a51ab46..492f0bc 100644
> > --- a/Documentation/admin-guide/kernel-parameters.txt
> > +++ b/Documentation/admin-guide/kernel-parameters.txt
> > @@ -1992,14 +1992,20 @@
> >   			the added memory block itself do not be affected.
> >
> >   	hung_task_panic=
> > -			[KNL] Should the hung task detector generate panics.
> > -			Format: 0 | 1
> > +			[KNL] Number of hung tasks to trigger kernel panic.
> > +			Format: <int>
> > +
> > +			When set to a non-zero value, a kernel panic will be triggered
> if
> > +			the number of detected hung tasks reaches this value.
> > +
> > +			0: don't panic
> > +			1: panic immediately on first hung task
> > +			N: panic after N hung tasks are detected in a single scan
> >
> > -			A value of 1 instructs the kernel to panic when a
> > -			hung task is detected. The default value is controlled
> > -			by the CONFIG_BOOTPARAM_HUNG_TASK_PANIC build-time
> > -			option. The value selected by this boot parameter can
> > -			be changed later by the kernel.hung_task_panic sysctl.
> > +			The default value is controlled by the
> > +			CONFIG_BOOTPARAM_HUNG_TASK_PANIC build-time option.
> The value
> > +			selected by this boot parameter can be changed later by the
> > +			kernel.hung_task_panic sysctl.
> >
> >   	hvc_iucv=	[S390]	Number of z/VM IUCV hypervisor console
> (HVC)
> >   				terminal devices. Valid values: 0..8 diff --git
> > a/Documentation/admin-guide/sysctl/kernel.rst
> > b/Documentation/admin-guide/sysctl/kernel.rst
> > index f3ee807..0065a55 100644
> > --- a/Documentation/admin-guide/sysctl/kernel.rst
> > +++ b/Documentation/admin-guide/sysctl/kernel.rst
> > @@ -397,13 +397,14 @@ a hung task is detected.
> >   hung_task_panic
> >   ===============
> >
> > -Controls the kernel's behavior when a hung task is detected.
> > +When set to a non-zero value, a kernel panic will be triggered if the
> > +number of hung tasks found during a single scan reaches this value.
> >   This file shows up if ``CONFIG_DETECT_HUNG_TASK`` is enabled.
> >
> > -= =================================================
> > += =======================================================
> >   0 Continue operation. This is the default behavior.
> > -1 Panic immediately.
> > -= =================================================
> > +N Panic when N hung tasks are found during a single scan.
> > += =======================================================
> >
> >
> >   hung_task_check_count
> 
> […]
> 
> > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index
> > 3034e294..3976c90 100644
> > --- a/lib/Kconfig.debug
> > +++ b/lib/Kconfig.debug
> > @@ -1258,12 +1258,13 @@ config DEFAULT_HUNG_TASK_TIMEOUT
> >   	  Keeping the default should be fine in most cases.
> >
> >   config BOOTPARAM_HUNG_TASK_PANIC
> > -	bool "Panic (Reboot) On Hung Tasks"
> > +	int "Number of hung tasks to trigger kernel panic"
> >   	depends on DETECT_HUNG_TASK
> > +	default 0
> >   	help
> > -	  Say Y here to enable the kernel to panic on "hung tasks",
> > -	  which are bugs that cause the kernel to leave a task stuck
> > -	  in uninterruptible "D" state.
> > +	  When set to a non-zero value, a kernel panic will be triggered
> > +	  if the number of hung tasks found during a single scan reaches
> > +	  this value.
> >
> >   	  The panic can be used in combination with panic_timeout,
> >   	  to cause the system to reboot automatically after a
> Why not leave the sentence about the uninterruptible "D" state in there?
> 
This seem to say a kernel bug to cause hung task, but it maybe hardware failure(or virtio backend bug); so I do not keep it

> Also, it sounds like, some are actually using this in production. Maybe it
> should be moved out of `Kconfig.debug` too?
> 

I think hung task panic is a useful feature, it should move out of Kconfig.debug

Thanks

-Li

> 
> Kind regards,
> 
> Paul

  reply	other threads:[~2025-10-17  2:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-15  6:36 [PATCH][v4] hung_task: Panic when there are more than N hung tasks at the same time lirongqing
2025-10-16  5:07 ` Lance Yang
2025-10-16  5:57   ` [外部邮件] " Li,Rongqing
2025-10-16 20:50     ` Andrew Morton
2025-10-16  8:02 ` Masami Hiramatsu
2025-10-16 12:47 ` Paul Menzel
2025-10-17  2:09   ` Li,Rongqing [this message]
2025-10-17  5:17 ` Andrew Jeffery

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d492d12e4e5441a2b51c3415e865fa99@baidu.com \
    --to=lirongqing@baidu.com \
    --cc=akpm@linux-foundation.org \
    --cc=andrew@codeconstruct.com.au \
    --cc=anshuman.khandual@arm.com \
    --cc=arnd@arndb.de \
    --cc=corbet@lwn.net \
    --cc=david@redhat.com \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=jason@zx2c4.com \
    --cc=joel.granados@kernel.org \
    --cc=joel@jms.id.au \
    --cc=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=lance.yang@linux.dev \
    --cc=liam.howlett@oracle.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-aspeed@lists.ozlabs.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=mhiramat@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pauld@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=pmenzel@molgen.mpg.de \
    --cc=pmladek@suse.com \
    --cc=rdunlap@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=wireguard@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).