From nobody Thu Oct 2 03:27:37 2025 Received: from baidu.com (mx24.baidu.com [111.206.215.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2917926E717; Tue, 23 Sep 2025 07:03:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=111.206.215.185 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758611026; cv=none; b=nmVmrF4Cqn33RB50z8gFn0BJMjtYVR2V9xK7ZyhW7K7UhXCkz12qq2Kz5i25H0UWbdOOpSXHOlsGRtKn5q2RsFKAw3vwy1dMvbQ4EtNLiLWvJzW1qW5+qkcFTmH4t/AOMbBESFBTompWZ/FNYOICvemUPMdD74O24KK7/JFBGG0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758611026; c=relaxed/simple; bh=e9Vg2dzIeDuuObcmwsRBRncNjaaipGCZqDw3uwGilp8=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=uohSoXYebzpAge9yt2YUrR46NjX3kjjnu8C+bO6Fo0Q/ttZHxEyrfuoxkR3wq81ecEMMVWmYOQk9e+QZPyJ+8A9PayERKMdJPzWMMFbLAh0uwqxSbjWciA8PT6q7lpcl1jHwoFccPaXNX0x1qp6LkQ/8xXk4P08CqljyNLi1NnE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=baidu.com; spf=pass smtp.mailfrom=baidu.com; arc=none smtp.client-ip=111.206.215.185 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=baidu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baidu.com From: "Li,Rongqing" To: "paulmck@kernel.org" CC: Andrew Morton , "corbet@lwn.net" , "lance.yang@linux.dev" , "mhiramat@kernel.org" , "pawan.kumar.gupta@linux.intel.com" , "mingo@kernel.org" , "dave.hansen@linux.intel.com" , "rostedt@goodmis.org" , "kees@kernel.org" , "arnd@arndb.de" , "feng.tang@linux.alibaba.com" , "pauld@redhat.com" , "joel.granados@kernel.org" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: =?utf-8?B?UkU6IFvlpJbpg6jpgq7ku7ZdIFJlOiBbPz8/P10gUmU6IFtQQVRDSF1bUkZD?= =?utf-8?B?XSBodW5nX3Rhc2s6IFN1cHBvcnQgdG8gcGFuaWMgd2hlbiB0aGUgbWF4aW11?= =?utf-8?Q?m_number_of_hung_task_warnings_is_reached?= Thread-Topic: =?utf-8?B?W+WklumDqOmCruS7tl0gUmU6IFs/Pz8/XSBSZTogW1BBVENIXVtSRkNdIGh1?= =?utf-8?B?bmdfdGFzazogU3VwcG9ydCB0byBwYW5pYyB3aGVuIHRoZSBtYXhpbXVtIG51?= =?utf-8?Q?mber_of_hung_task_warnings_is_reached?= Thread-Index: AQHcLDttVizJ2u6zwEeKMgiwnSexq7SfmowAgACJIFD//51tAIAAlYrw Date: Tue, 23 Sep 2025 07:01:47 +0000 Message-ID: References: <20250923033740.2696-1-lirongqing@baidu.com> <20250922204554.55dd890090b0f56ad10a61f5@linux-foundation.org> <36db2f10-ebbe-4ecd-b27f-e02d9e1569c2@paulmck-laptop> In-Reply-To: <36db2f10-ebbe-4ecd-b27f-e02d9e1569c2@paulmck-laptop> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FEAS-Client-IP: 172.31.50.45 X-FE-Policy-ID: 52:10:53:SYSTEM > There are the panic_on_rcu_stall and max_rcu_stall_to_panic sysctls, which > together allow you to panic after (say) three RCU CPU stall warnings. > Does those do what you need? >=20 > Thanx, Paul >=20 inspired by dfe564045c653d "(rcu: Panic after fixed number of stalls)", add= a new knod for hung task, how about? diff --git a/kernel/hung_task.c b/kernel/hung_task.c index 8708a12..b93592d 100644 --- a/kernel/hung_task.c +++ b/kernel/hung_task.c @@ -83,6 +83,8 @@ static unsigned int __read_mostly sysctl_hung_task_all_cp= u_backtrace; static unsigned int __read_mostly sysctl_hung_task_panic =3D IS_ENABLED(CONFIG_BOOTPARAM_HUNG_TASK_PANIC); +static unsigned int __read_mostly sysctl_hung_task_panic_count; + static int hung_task_panic(struct notifier_block *this, unsigned long event, void *pt= r) { @@ -219,7 +221,9 @@ static void check_hung_task(struct task_struct *t, unsi= gned long timeout) trace_sched_process_hang(t); - if (sysctl_hung_task_panic) { + if (sysctl_hung_task_panic || + (sysctl_hung_task_panic_count && + (sysctl_hung_task_detect_count > sysctl_hung_task_panic_co= unt))) { console_verbose(); hung_task_show_lock =3D true; hung_task_call_panic =3D true; @@ -388,6 +392,14 @@ static const struct ctl_table hung_task_sysctls[] =3D { .extra2 =3D SYSCTL_ONE, }, { + .procname =3D "hung_task_panic_count", + .data =3D &sysctl_hung_task_panic_count, + .maxlen =3D sizeof(int), + .mode =3D 0644, + .proc_handler =3D proc_dointvec_minmax, + .extra1 =3D SYSCTL_ZERO, + }, + { .procname =3D "hung_task_check_count", .data =3D &sysctl_hung_task_check_count, .maxlen =3D sizeof(int),