From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from CWXP265CU010.outbound.protection.outlook.com (mail-ukwestazon11022079.outbound.protection.outlook.com [52.101.101.79]) (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 97A2646F4AA for ; Tue, 4 Aug 2026 15:54:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.101.79 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785858859; cv=fail; b=VawPiL57rCFRriuUkiSR7qDoCyQjNWCmXtZNcuDhN77SEMI7RKp0aPZTbRb4k/VQ9fk9ZsG048Gbqs753dIYvi6tRzmCe1L15LwE3rJ4xKnb0UgfWkXSqyR+cTnyFp0p5x2BjZmvvN5CsAS0Y5+x5idijklpp1z7nXu7Zxy22eI= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785858859; c=relaxed/simple; bh=+UyEUZ+HfgL7NeC9TKtGEWQd+xOQSkiM2So4PORYnAM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=IpOKoi4dN/HLmDdJvMddk1GCOsMwBbgjhjtuH4hviMnlGSldJmDnVgIvAa8et9KA+mZyT1+912g9clHfYQ5zNPX5vvwtBMToT8jCT+gpedvureC7e+nUT+7d+3uuAjCkvS9LT9KlOgGxsUs/YNskWWR0tpSXeqs3rKIyc4KYlmY= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com; spf=pass smtp.mailfrom=atomlin.com; arc=fail smtp.client-ip=52.101.101.79 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=atomlin.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WL7Qr76rA2fR5fqZpsUNxA5v1SUVmPkW5IN05hNQomNupOwfz70NejMgnWM+2fvbkKECfaA+qf0DUAtVwpGH18qfXz1zFumYkyq/NIlmTIw0oQJ/rkNOEA7T+cpAOMMCQsyTXI77rYIljSspmKH2wvBEaCoSYiGW7L6Ppydu76zuPpxg4eR0k8dJeEldHvNXZLK73cRQesW1950kKWSHhEX+SX3O7MKHxFfJECH8dLr8ZPGdFlxf/m4/jaomuF5lqogy22tDq/0LY+gkhefQ7LmIVsFv6gRSuYHlC3JjfoJQ+XgfoQIsy9eAGbXZ5YSRAv+TWTdztYxo/gb95YcYEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:MIME-Version; bh=iVHdnt8bDHOobLJD3bdHPVcueB1HJIGTgT5UamZPyRo=; b=fXDcbpGgNQp48Eazvjj5BPnKo7xJKuXY35ii/eW10tBcwXF/AyZPur32pItZNeg7y0cYM4IkGJMgoaGMLnPPyHCt3qvuDh5t9QcyDwRhisw5VI6v6plN95bx6P/UVVkrNT64qEQEnHnW/F8+txRjYmzBj46JRIUzXOg51VfzJ0A08xMRQm0FoiFgbupDXCH58lzJ5G6UmTeJli4vd5qSPDg7bUHffAyChI0Sw9SkyuxiUaaY0XnMs9jU4iWICQWSAOwdvIg/3KflbwH9OireyTkF3bjsCEMnNoCfXx0q4oq+ZEgQOa7QVydJfeqp/uXeZ15ubIDaW6AhDPNq3jri8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=atomlin.com; dmarc=pass action=none header.from=atomlin.com; dkim=pass header.d=atomlin.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=atomlin.com; Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) by LO3P123MB3532.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:10c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.19; Tue, 4 Aug 2026 15:54:13 +0000 Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230]) by CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230%4]) with mapi id 15.21.0292.013; Tue, 4 Aug 2026 15:54:13 +0000 From: Aaron Tomlin To: akpm@linux-foundation.org, lance.yang@linux.dev, mhiramat@kernel.org, pmladek@suse.com Cc: linux-kernel@vger.kernel.org, david.laight.linux@gmail.com, atomlin@atomlin.com, neelx@suse.com, sean@ashe.io, chjohnst@gmail.com, steve@abita.co, mproche@gmail.com, nick.lange@gmail.com Subject: [PATCH v7 1/2] hung_task: Reset warning budget when problem gets resolved Date: Tue, 4 Aug 2026 11:54:05 -0400 Message-ID: <20260804155406.254810-2-atomlin@atomlin.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260804155406.254810-1-atomlin@atomlin.com> References: <20260804155406.254810-1-atomlin@atomlin.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BL1PR13CA0193.namprd13.prod.outlook.com (2603:10b6:208:2be::18) To CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLP123MB6607:EE_|LO3P123MB3532:EE_ X-MS-Office365-Filtering-Correlation-Id: 57f0bf0f-d256-4505-ba39-08def240a19f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|23010399003|7416014|366016|1800799024|10067099003|56012099006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: EVb9Hacm2nla3u5Z7j6hO5Lg0kdTNFZDKf62aGBa9uaGWpaeXEBIhxXckPUzrNbmQ9kaRcrdEiZknhvwVGtraqBFMriEtywzxLOFApE/0bmgI4/wO6cGD5FNM477FgR3oIK+RAsGcDFzyCltgv2cZWpcc1EjD5vbBxna0upSyAdBWgOWbefa9f2WSo+K/F4cIAnS+4dViMvjFiD6QieBOAgIIH2EOs83tgne6accXCbp3jwh1JDSDO5L4wtUoz4K1WMjZwZSC8WUfBp1PI/SgiB6hOIKOZehHRU8Wkt2MoAWExrQ9bX+qMIqbbKY8XtrcFdSxsPZuB6MXbi2ht8sJ35AaO12U30t7Rt7BPHMp7FDtF6ZNMQ2RWP5ENkCKfM93oKUUBc8qAwpnvtOe1odU4TbgbjsqtDeqTkFL8lPjllp+n56FW/ovwDz7eT933JPeP84sbbN2xOfWa9J7Dl2rBO0l1GQZqftHjeSGuKotoIAxP7iN0ccoSknDScY2IEMPv2Hh+hd1bgSuSDbDb0zq06H5W+JHCCOHgCjQTlB9z4NQZ009RipWRWSeK7pvdWfRiHoJgk3A1LZhwsByYrKTN4I2WeUlby3+0SjyIYCN3C5FlKik6zpHUqt+ui4qo436q39ZCfA+weHE1Nk1d5NtXUTtYA8nRWXl7QRybt9p+8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(376014)(23010399003)(7416014)(366016)(1800799024)(10067099003)(56012099006)(22082099003)(18002099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?3+ixhEKeZWS7HNwVwK2FnFB76laCTWmbtNxa1EYPw0nvaaAGvzImkyGaURmd?= =?us-ascii?Q?801fT099/LnKfQLyxeopowmC1TZ9I695D3vtK62F1brRbbYHbOZj8JJzHvc/?= =?us-ascii?Q?Xd5ldONQDuUoPaCRPr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lr1?= =?us-ascii?Q?fBaIpJTcS1JV3vMMVAdZ/4UhDPw94tekTqsMuRYuMvTtBRoDakcprMhGPcXn?= =?us-ascii?Q?UZENlUtMnqTf/rgmPHaw61rF62jASyRclL9w89as1bb5qdhXXvTQgT5AV3x6?= =?us-ascii?Q?VitWqHzENiq5Q+YlPkAFM71VOz3XXlOiqKC/Gq4JjKyvlBy9uDT4RXMtYZUD?= =?us-ascii?Q?AIxoxEhGSzUbDMzv7g9P+/XcuV2K2kRd8mP+D+cdX17gU5b7PJ1MVD9FEEN0?= =?us-ascii?Q?PzFumvtNXD5C3gCzJNd8jLviFP/AlVY84yQnRhKlIkB5AxpdetaZh7zpKZCE?= =?us-ascii?Q?PXBptrqfjHJRAmsUe+zU+riyVUpDxwe08LvN402zrvYJ9ut7yZ+thysX0yg3?= =?us-ascii?Q?4QWoKI7LXdfMmhyp8XvHQqvi+ZqDuol+6/sGJ84RVEnaV64b28JiR7oJwkHt?= =?us-ascii?Q?3DjjC60ORs0zz5P4CSPkTrODqWS47km1JnySOcburZIYSzybt20D15YxifsF?= =?us-ascii?Q?1f+jLU7/eDg7jL/xNHN0XKTxmIJnxu4S07ME+BDEycMIoluCFAkjWbaUSwk4?= =?us-ascii?Q?F2CNc9fmQgfJf+rl1b3CW08X2jlEZ3DoYKCi+/HqWvQBbxW8VwRTNKsepFDP?= =?us-ascii?Q?1+QszNpexbYrRymhRmFKoIcSmj9te8pKn/8356ExrebCPCcQzm0j3uqxCR9J?= =?us-ascii?Q?bo0MnABpvItj80sF5kVN6gnzrYJBVk24urjsMBf4+FMSX74uYWVaCbmEGANL?= =?us-ascii?Q?/gifHwZsxQ=3D=3D?= X-OriginatorOrg: atomlin.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57f0bf0f-d256-4505-ba39-08def240a19f X-MS-Exchange-CrossTenant-AuthSource: CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2026 15:54:13.8226 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e6a32402-7d7b-4830-9a2b-76945bbbcb57 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pVdH8E1N3ZHUzgWIF6WOpkpGHqd6ndKpjzMVl4PjFb/cIMSyd5gqI2RPu3Dy9yair/VuFehn6ULS741RuwwUXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LO3P123MB3532 From: Petr Mladek sysctl_hung_task_warnings counts how many hung tasks are reported. The watchdog does not report anything once the limit is reached. Currently, this budget is decremented permanently, meaning the kernel is left blind to subsequent hung tasks even after the original issue resolves. Keep the global sysctl_hung_task_warnings intact, and instead decrement a copy (hung_task_warnings_printed) when warnings are printed. Reset the copy back to the configured sysctl_hung_task_warnings limit once the problem on the system gets resolved and check_hung_uninterruptible_tasks() detects no hung tasks in a check interval. Also keep the copy updated when the global sysctl_hung_task_warnings value is updated via sysctl, and update documentation to reflect the new behavior. Assisted-by: gemini-3.5-flash Suggested-by: Petr Mladek Reviewed-by: Lance Yang Tested-by: Lance Yang Signed-off-by: Aaron Tomlin --- Documentation/admin-guide/sysctl/kernel.rst | 5 +-- kernel/hung_task.c | 34 ++++++++++++++++----- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst index c6994e55d141..b0f8e55efc1a 100644 --- a/Documentation/admin-guide/sysctl/kernel.rst +++ b/Documentation/admin-guide/sysctl/kernel.rst @@ -459,8 +459,9 @@ hung_task_warnings ================== The maximum number of warnings to report. During a check interval -if a hung task is detected, this value is decreased by 1. -When this value reaches 0, no more warnings will be reported. +if a hung task is detected, the internal warning budget is decreased by 1. +When this budget reaches 0, no more detailed warnings will be reported. The +warning budget is reset to the configured limit when no hung task is found. This file shows up if ``CONFIG_DETECT_HUNG_TASK`` is enabled. -1: report an infinite number of warnings. diff --git a/kernel/hung_task.c b/kernel/hung_task.c index 6fcc94ce4ca9..4e1fb0db79d1 100644 --- a/kernel/hung_task.c +++ b/kernel/hung_task.c @@ -59,6 +59,8 @@ static unsigned long __read_mostly sysctl_hung_task_check_interval_secs; static int __read_mostly sysctl_hung_task_warnings = 10; +static int hung_task_warnings_printed = 10; + static int __read_mostly did_panic; static bool hung_task_call_panic; @@ -247,9 +249,9 @@ static void hung_task_info(struct task_struct *t, unsigned long timeout, * CONFIG_DEFAULT_HUNG_TASK_TIMEOUT. Therefore, complain * accordingly */ - if (sysctl_hung_task_warnings || hung_task_call_panic) { - if (sysctl_hung_task_warnings > 0) - sysctl_hung_task_warnings--; + if (hung_task_warnings_printed || hung_task_call_panic) { + if (hung_task_warnings_printed > 0) + hung_task_warnings_printed--; pr_err("INFO: task %s:%d blocked%s for more than %ld seconds.\n", t->comm, t->pid, t->in_iowait ? " in I/O wait" : "", (jiffies - t->last_switch_time) / HZ); @@ -264,7 +266,7 @@ static void hung_task_info(struct task_struct *t, unsigned long timeout, sched_show_task(t); debug_show_blocker(t, timeout); - if (!sysctl_hung_task_warnings) + if (!hung_task_warnings_printed) pr_info("Future hung task reports are suppressed, see sysctl kernel.hung_task_warnings\n"); } @@ -304,7 +306,7 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout) unsigned long last_break = jiffies; struct task_struct *g, *t; unsigned long this_round_count; - int need_warning = sysctl_hung_task_warnings; + int need_warning = hung_task_warnings_printed; unsigned long si_mask = hung_task_si_mask; /* @@ -340,8 +342,10 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout) unlock: rcu_read_unlock(); - if (!this_round_count) + if (!this_round_count) { + hung_task_warnings_printed = sysctl_hung_task_warnings; return; + } if (need_warning || hung_task_call_panic) { si_mask |= SYS_INFO_LOCKS; @@ -425,6 +429,22 @@ static int proc_dohung_task_timeout_secs(const struct ctl_table *table, int writ return ret; } +static int proc_dohung_task_warnings(const struct ctl_table *table, int write, + void *buffer, + size_t *lenp, loff_t *ppos) +{ + int ret; + + ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); + + if (ret || !write) + return ret; + + hung_task_warnings_printed = sysctl_hung_task_warnings; + + return 0; +} + /* * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs * and hung_task_check_interval_secs @@ -480,7 +500,7 @@ static const struct ctl_table hung_task_sysctls[] = { .data = &sysctl_hung_task_warnings, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec_minmax, + .proc_handler = proc_dohung_task_warnings, .extra1 = SYSCTL_NEG_ONE, }, { -- 2.55.0