From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from CWXP265CU009.outbound.protection.outlook.com (mail-ukwestazon11021119.outbound.protection.outlook.com [52.101.100.119]) (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 BA17842B756 for ; Tue, 4 Aug 2026 20:20:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.100.119 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785874863; cv=fail; b=RiHKY3nUAh8C+pqx0/Z3GUuDeoyh+mfXdPdWIbUFj1pSxBI6yqvtWPvt6/ZIzcLOVPXSNPzr5thJWKlYAm9EPQMxFdyL5X4eMruNfmxT0Zx4dQ9rrTeFSGjMV6LgQJlbWkQXV3bCGcFuJb31dZLn51k0LoEUcO6oNUiCfEHAsiY= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785874863; c=relaxed/simple; bh=Qe/ctew/W25dqbyFEjEoDWZ1KELs3NJ3e/+1wOpGkSc=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=Ue5r2LFNtcvN3zCMP0Z60Aqu1B5vtKNWeUWb9YJKif4n1RvC6dkzdgR4I8UAMkxWzTtspPvA3WGE8HE2sIrMqnMu0JltRo9DShvEGbU7IjQgkN6qwD87z9sE5n7Y5y/3bVnxG9U+SN50fJFT1CULoDdgJ5vJj2CBOpwZ+9xA0+I= 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.100.119 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=Bh2FFWKN/2DXFoRybVfO8r3/3tdcLAfWZMeWlIH2qHuEB/vY46nW2jFcwa2KzGuI6RHyxsCGNwayvRvaGDzAVM+houEVG2JgqWIOiwd7C12HiRcs/Mgqvc3s6m8rGUa5SBhxaw6deQQiAca7sT5FQrEZZjEu+84n9Lu+0D4C72Dr9LZ5n1OXsIS/rM4/H7SuQ56EOeU6qWvz4xzSLzJIVT2wD9YkoK106YkpgwPrCtSVTCPpRtB4hfQaFoECbiBrYOH1wcxScOiji6zfDMAFoi8l63WZBqIhs35dLypaFmI4ANAN35lOapVZLYaJWqwPhl+DLebevQomR+sE+wJiEw== 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=YBUpqID9cUbjgsHqGSfM22QoO3FopV1QN66xzgJPrLg=; b=h6/EIpvsjSHmCGAZstednJ2HYOC0O1q3PoWV0jX8usScOH7mXaTXEH/X8WaBD4YGTmslKGIQ2DsmM8ztZWldRgfsHt5KQ+eGs5xcnA7KozMh36W6bFEBkkUVtoS1BQwIJv9xTGR2gmzAhLhCzFQUvGrQp4pC6Mi/jQA7bBSFNLQ/IZDpQVAh7xSJw4bM6oUhfnSlnnvR2UmuDauJpdU33uH8334oT+zKsWtxzSVJsf3+PJEqnbCWX6tUSkBtt5g4qjxnpbshoZCZjy7vdTKM1w/hz112YZA/PWidHK0i0kHajwoMRUTlCJ9w3xejz7oGwIM3DJ6lUq6r6sWA7HG6Bw== 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 CWLP123MB3665.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:91::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.292.15; Tue, 4 Aug 2026 20:20:55 +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 20:20:54 +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 v8 0/2] hung_task: Improve warning budget handling and task reporting Date: Tue, 4 Aug 2026 16:20:48 -0400 Message-ID: <20260804202050.262427-1-atomlin@atomlin.com> X-Mailer: git-send-email 2.55.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MN0PR02CA0018.namprd02.prod.outlook.com (2603:10b6:208:530::13) 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_|CWLP123MB3665:EE_ X-MS-Office365-Filtering-Correlation-Id: a66640c0-0c61-4d7a-33e6-08def265e2c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|23010399003|7416014|376014|56012099006|10067099003|6133799003|18002099003|3023799007; X-Microsoft-Antispam-Message-Info: 57IYppwVNcOxeUWSOM4aP7eyF8arzKsLORcFuS4nrgwV9QL+WrRuOEvjmUlLcRKs8P3vSQrwsgPVspgv/q6J/C+gsCQzw2QTEY/cZtRCNXpzvIkMz/DQ93wNz6uUQAnDiCIWA3TheuQvasBxsYRcow7IdjyTaKWgTCqtDECGWg1Ydx75GjXi8VFgCyLdf3/n/ZkdN4iaWTSpG9KGkNy9Cxg/DyARvwCE4YIM0syZS8FlP8koRWMIf6b9A1rH5B76LDrAlKABD5wjzgUcSirA/Bkb9MGsly8nD/SxPpCOm4+4EQjUrfLhejLWihfYvZviTIRQ/Loy53qS90KTsOxeiz8Zp11hrBSgl4bzkiwsenH9BW+6HSGCTtF9OdppaqK/kkwPFHdMca3rLvTHMS/1X/eDer9hn+qjWSoN6brYCegY4kGWJSHmdQssx2661Q6xsidjl6ETJVyVA2dKmeNno6Q6HBuoSVKN3dHCgLcIy7zjc5Lbi79RRkAiYDDL3tHRtdunAeM8yEu81EdOUyucBnQO1VIVRNxcgZcQQVLpV34V0ncvsp2FZGi2cA/r53ew3ZLoAYPRsu7gL26rMfsOwJZiEliKbjcHnvjYUxuKVs/MXpxhF9LNcihACPQuUc7TIj+eMC/RBVd6iaTaA/W8ZsF60PonnAjZu/hN9y8Qx8g= 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)(366016)(1800799024)(23010399003)(7416014)(376014)(56012099006)(10067099003)(6133799003)(18002099003)(3023799007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?+8Hi54DmjIruDjeS18oqCvcFqlxVIXaO89xiS/5kK8A9LENZxTP+NAouwTYI?= =?us-ascii?Q?O+zs5ewmzJaAK9SHpWXTIHy6Q6GQxatsW0Ad+vDwukyXMZu37Jqc8M47RV9I?= =?us-ascii?Q?QshVHKoyN2+eyuI6cEQsPxTI/Pf96LNYIku5nCANGTgg0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LGt+U/OttNcUGMkrLKYE15IzGnvre63Dxwh05H0?= =?us-ascii?Q?Dz1FCaOmPYEPLRhC7tAtYOpuqBqWHs4ko7rPmUCatm/Dv0DhSci+9/LfGZGF?= =?us-ascii?Q?Z4EPpLH5+vlhCIh+vVKo5fsK6IGfyD2jyuwUtiKOligKbxxsty6+UOJUYBSm?= =?us-ascii?Q?1JvQRgbALQ6i6QGMpwONOfTvkiEkshqxmq+H+goyL/wQRv5n5At0obZG/baD?= =?us-ascii?Q?+j10DIfTxPRs5U0cXuWexN37Ei0jMM8FLA8qf3ExR7+UcK8xQLTV670gLwbd?= =?us-ascii?Q?hG+TTr45q0/PP1RpD/bmKaeiON9rHQgy4X4mRm8R6wVW+oXTWzAw6+1JOHcx?= =?us-ascii?Q?VLjgf0zTVv+FZ4hatSP35+BoUV4J58TDVPejlVKDw/njA5RyHYGH1bSfRLq1?= =?us-ascii?Q?nZWZUWcXD7wNtiSFbAwlTkNNyaIllJMkI6OWcnK584CbKtfECvR9PeQi9S+c?= =?us-ascii?Q?1q37k6YK3YvRjgczXSqr/7JoLQR7WIKQ4bzAzQXOpFhg72JetMyIrnkWGWQJ?= =?us-ascii?Q?Rt8MyJHp+PSHAeVnR8/3TgZSrTdYpCjJOWPAsUB5aQ5wial9ZYO7pDK/qw0d?= =?us-ascii?Q?d7HCPBhjic01CB2lccLuWnQ9nIYx5reOUnUFtkksUWRYZUioxOqQQF34v+xe?= =?us-ascii?Q?SxM4s9SRMpyrx7xMOAbLWY8zfT5w+6NWVixIy2DOh65e61HznQ6eGjpLCPp7?= =?us-ascii?Q?QnEdZD68DQ=3D=3D?= X-OriginatorOrg: atomlin.com X-MS-Exchange-CrossTenant-Network-Message-Id: a66640c0-0c61-4d7a-33e6-08def265e2c2 X-MS-Exchange-CrossTenant-AuthSource: CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2026 20:20:54.6583 (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: gxf+nzvp44iV6qjbnQWW/tcttL73zrKocNUEp3yK9Mr5hGyR6REGn7LsEkjCIpl3pdDJeuOPrjOV1rO+cb8WGw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWLP123MB3665 The hung_task watchdog detects tasks stuck in TASK_UNINTERRUPTIBLE (D) state for longer than CONFIG_DEFAULT_HUNG_TASK_TIMEOUT seconds. To prevent log spam during system spikes, sysctl_hung_task_warnings enforces a budget on the number of logged warnings. However, the current implementation has two major limitations: 1. Permanent exhaustion of warning budget sysctl_hung_task_warnings is decremented directly when printing warnings. Once this budget hits zero, no further warnings are reported until an administrator manually updates the sysctl value or reboots the system. Consequently, a single temporary hang episode permanently blinds the kernel watchdog to any subsequent hung tasks after system recovery. 2. Total log suppression when budget is exhausted Once the warning budget reaches zero, hung_task_info() completely suppresses all output, including the basic single-line alert. While suppressing verbose stack dumps and lock debugging is desirable to prevent dmesg flooding, hiding basic task alerts leaves administrators entirely unaware that tasks are hanging. This patch series resolves both limitations by decoupling the configured warning budget from the runtime warning counter, automatically resetting the budget when the system recovers, and keeping basic single-line hung task alerts visible. Patch 1 decouples the user-configured limit sysctl_hung_task_warnings from the runtime counter hung_task_warnings_printed, automatically resetting hung_task_warnings_printed back to the configured limit whenever a check interval passes with zero hung tasks detected. The runtime counter is also kept synchronised whenever the sysctl parameter is modified, and the corresponding sysctl documentation (i.e., Documentation/admin-guide/sysctl/kernel.rst) is updated to reflect this auto-reset behaviour. Patch 2 ensures that the basic single-line hung task messsage is always logged regardless of warning budget exhaustion, while restricting warning budget enforcement solely to verbose diagnostics such as process stack dumps, taint and release information, and lock blocker details. Additionally, it updates the warning exhaustion log message to clarify to administrators that future reports will only omit detailed process dumps rather than being completely suppressed. Changes since v7: - Consolidated the commit message of each patch (Lance Yang) - Linked to v7: https://lore.kernel.org/lkml/20260804155406.254810-1-atomlin@atomlin.com/ Changes since v6: - Restructured the series in a new direction. Introduced an internal counter (hung_task_warnings_printed) decoupled from sysctl_hung_task_warnings. The warning budget automatically resets to the configured limit once a check interval completes with zero hung tasks detected, or when modified via sysctl (Petr Mladek) - Ensured the single-line blocked hung task message is always printed even after the warning budget reaches zero. Now budget enforcement is restricted solely to suppressing verbose diagnostics (Petr Mladek) - Refined the description of sysctl hung_task_warnings (Lance Yang) - Removed field hung_task_reported from struct task_struct - Removed the CONFIG_DETECT_HUNG_TASK_BLOCKER integration and hung_task_blockers[] used to track memory addresses of blocker locks across check intervals - Removed the skip_show_task logic and dmesg log suppression messages - Removed tracking variables (warnings_decremented and hung_task_has_active) and the dmesg recovery notice printed when clearing the blocker array - Linked to v6: https://lore.kernel.org/lkml/20260719161305.428947-1-atomlin@atomlin.com/ Changes since v5: - Skipped hung_task_info() and sys_info() for tasks already reported in previous rounds to avoid log spam - Linked to v5: https://lore.kernel.org/lkml/20260712202100.123934-1-atomlin@atomlin.com/ Changes since v4: - Replaced the stack-local hashmap implementation with a persistent array (Petr Mladek) - Persistently track blocker addresses across scan intervals. Suppress warning reports and keep the sysctl_hung_task_warnings budget intact if the blocker is already tracked in the array (Petr Mladek) - Reset the warnings budget and clear the blocker array when the hang resolves (Petr Mladek) - Output a recovery message to the kernel ring buffer upon hang resolution - Linked to v4: https://lore.kernel.org/lkml/20260627205733.90983-1-atomlin@atomlin.com/ Changes since v3: - Deduct from the global budget if printing a full stack trace - Pivoted from heuristic Wait Channel hashing to deterministic blocker address hashing via CONFIG_DETECT_HUNG_TASK_BLOCKER - Replaced the hung_task_reported bit-field with a standalone u8 byte. Move hung_task_reported into an existing structural alignment hole within task_struct following blocked_lock, resulting in zero overall memory footprint increase and optimal cacheline grouping - Linked to v3: https://lore.kernel.org/lkml/20260621213756.43225-1-atomlin@atomlin.com/ Changes since v2: - Replaced the per-round cache flush with a task_struct bit-field for persistent cross-scan tracking, mitigating delayed budget exhaustion - Abandoned exact-stack hashing in favour of Wait Channel hashing - Transitioned from jhash() to hash_long() to optimise single-pointer hashing, and relocated the hash map to the local stack - Linked to v2: https://lore.kernel.org/lkml/20260620013559.1537893-1-atomlin@atomlin.com/ Changes since v1: - Preserve "INFO:" headers for all hung tasks; suppress only the stack dumps for duplicates (Masami Hiramatsu) - Print a clear notification when a trace is explicitly suppressed - Add #ifdef CONFIG_STACKTRACE guards to prevent Kconfig build errors - Optimise overhead by unwinding the stack only if a warning is actually going to be printed - Linked to v1: https://lore.kernel.org/lkml/20260617184841.1447955-1-atomlin@atomlin.com/ Aaron Tomlin (2): hung_task: Reset warning budget when problem gets resolved hung_task: Always print basic hung task info header Documentation/admin-guide/sysctl/kernel.rst | 5 ++- kernel/hung_task.c | 46 +++++++++++++++------ 2 files changed, 37 insertions(+), 14 deletions(-) -- 2.55.0