From nobody Tue Dec 16 16:39:03 2025 Received: from CWXP265CU008.outbound.protection.outlook.com (mail-ukwestazon11020141.outbound.protection.outlook.com [52.101.195.141]) (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 E208D2F25F2 for ; Tue, 16 Dec 2025 03:00:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.195.141 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765854048; cv=fail; b=KZwUGllwEdLJam+vez7gcyz7jThant2xTLBnLGgul61/eXRDSyKBk8zWLVV3nJgJDVsxnroGpU55VWezyAlfPNATbMkZo9bdGTMN9kI5yBtUG5AEpa5MDH6o8z0grBqZmvBfqlUC9GR13+1Z/wzRx+4yqE/IxBrhWKRm88rjvP4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765854048; c=relaxed/simple; bh=Hs3DPYLV9bwLV5dTNgDhDiBHB2n4q4qQGOEh0IynsTY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=rhnh1QPxKoxpK3GTIsgCdCBtC46MIMi5lm5dK8P1lUCj/ul5pZ7mkaGzS5wOKz3x2PO8IY3vKYQUJ/S1JD3mzwAG6dZrGW5Ax8UwdP9XJl+CiE+cBj9OJrC7UJzb2eWpjly033tk2nLvkUrqn9IgbJWx3m74vP+KMFGchz0kcFE= 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.195.141 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=L3CESfxvHohBMX7ZDzyGD/VFpju6mZhO3aU8RCkm5EJlM9UUJLchHemglknvALGPiyw+ttO63jdGYdHI1ouTHAAt5xPCVYNYgqm2p68v0iLN9vjGsjuVRGOGVKmKahR2zJuBUUB0AEX3Ig4v6vADy+QxysHlleXKEVCl4XuLsCcZaTpjcmrs82lx2e7TGwYXVjl5//EXkMCD6s5lTBZAAnJiEClSSqrZYBnghS0x335NeiZdlbJmMk5oB6/Cf4waE64qBm6I2UFI/lkxluzsK0PhIzM9h2KrPdsM90TgBpMI7WcYjYrU4LEkdWlHNVOdmAKzjzJa7uFxZPWwa4ZeBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gmows/uhR5zNfFtPTsf7Au+8einzR5oG2BMwwCFnZtk=; b=UBrAuLCFl+mk6t5ev7ZSXGQKrVDKfk2FeuXq3DGmzY2clPXI8xQ3jdmBTB+yLI4pxQme/kSACtK+l7LRQ8AVNsEHLEtasic9dpyNUeskGgRknp9MqzESsJylEapFVbI4a9+tDdgGvTyYutunywadV3qYOTh8KJo5rA2/EppAt4Ei8JYGhqjndcWyTG2h3/xrICpnT93u0DNfe5xExTfrG0Y3F6tnAGBQiw/PEjY20JBGLDNTcpBWE1i3E4qrU8j9J77hSS7zTY7o6GJ8mAvKSthS9i5TSaPtCW29j0410bBaZ7WumVNwnFyyAslYy1kg/SnxhHBytxOkj2IQRqg5SA== 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 CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:70::10) by CWXP123MB4183.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:b1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9412.13; Tue, 16 Dec 2025 03:00:44 +0000 Received: from CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM ([fe80::de8e:2e4f:6c6:f3bf]) by CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM ([fe80::de8e:2e4f:6c6:f3bf%5]) with mapi id 15.20.9412.011; Tue, 16 Dec 2025 03:00:44 +0000 From: Aaron Tomlin To: akpm@linux-foundation.org, lance.yang@linux.dev, mhiramat@kernel.org, gregkh@linuxfoundation.org, pmladek@suse.com Cc: sean@ashe.io, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/2] hung_task: Introduce helper for hung task warning Date: Mon, 15 Dec 2025 22:00:35 -0500 Message-ID: <20251216030036.1822217-2-atomlin@atomlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251216030036.1822217-1-atomlin@atomlin.com> References: <20251216030036.1822217-1-atomlin@atomlin.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9PR03CA0291.namprd03.prod.outlook.com (2603:10b6:408:f5::26) To CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:70::10) 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: CWLP123MB3523:EE_|CWXP123MB4183:EE_ X-MS-Office365-Filtering-Correlation-Id: f5ff0d2b-063e-4ed5-71b3-08de3c4f4e28 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?xHTq8l2eXHB6hRbXvPCH7ec8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D?= =?us-ascii?Q?4Vz+G78VghXy611Fw+QzY5K7st9gtwWxQR0wwwAcFe2Q+MTR7eSroZXfrCZI?= =?us-ascii?Q?Gx6bSV3r7lZV5kXhD7EDpBfykzQkMLULS7rb3+oc3EDpPYeiOrG+gXDc5cG0?= =?us-ascii?Q?3pit/1HI+I7wXSqIDbsu9YxVh6C4s2w6ev5AoshPqRL4pOdCQd3QiffEGQ0y?= =?us-ascii?Q?GyjvTYLlSm4ecvm+0G9zUsjmvs/7vgUYBnvz7tqukcCnz8v/J0Fl8aCh9KVW?= =?us-ascii?Q?3KlvpJbiCoeCnib7ItCtIJOcdQ3wyYV+lkpw1Np+jGNhV45bvyBy2WPIANd4?= =?us-ascii?Q?tLR+cmMjRmKt7fQIox3Z1EeALUYrWWT4G3qs1MnJnPfBblbsRmKbK8t6m9od?= =?us-ascii?Q?uW8YaEp6phe1H/VNSZ31zhTEKZCewtLQazQgkIVP5yCzu/8Irb4hz30OYQd4?= =?us-ascii?Q?ZDzT9ds+LXQn/JXycIDevisYtdMi7V3e3+0F6RPgF8e9jzF+tpz4pE+3HpVm?= =?us-ascii?Q?vO05kyVmFwrGAh+qGf0wKq9eTL/FDNlo2gRyLo1ShWAaJFlzYwQn3lgCoiRj?= =?us-ascii?Q?YKcdOscq5SqGA3vEyWWTkXZYiFkaYAAh?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ooMYNHktJiEmANCX0zRBinuvcMEQ1Vx2Nm7O7O+In5Uj0YJXF8YXerORIjtQ?= =?us-ascii?Q?MCgKNYndzgjrX8z0J8yQB5rwwEeNIDi8RRHu6LqGc3PRbino3Z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CJxQithi2ZTcKCmOabUW7FMiwlgO7CJ2F4Yu4pYKXH?= =?us-ascii?Q?Rkjj5+COygrjf/lcXOePwK6hxZGFWbeN8FelRoy0Zb5bPonKP8z0kXtwx8SF?= =?us-ascii?Q?axGq3QdvwlqYIVryDLo6n+y0rY+VMmg3OU7A4RyvEwPtz0I869vAnOKvi2Ye?= =?us-ascii?Q?piiJ1X9eHIb2uG2oFQ6NRhBj2kBSi1EQa77uLaC2Zd7GpoorVs29+UEQVdJm?= =?us-ascii?Q?9KuR20T+TS0Kovtki8Hkpu1S+L3OYogXs0ZW85/J3FyZVeQZvtC/9bOBEHN0?= =?us-ascii?Q?5Lx26tFPaLvbEIhBibtT09StmWZLrQDIpywHkTgEJMbO/5TNUpzhTr0QYYdR?= =?us-ascii?Q?iEfIFueR0kVUJ9wloezBcpEro2u5gdWE1I6eLJHhmM52BaIYWMJRWoXTcNn/?= =?us-ascii?Q?vbsCkxvtztEL/jB3qXUh4xh3Q8Ikpv9m76Bn55+utYgnQd63PtnC1FsBsktk?= =?us-ascii?Q?yAJAwaSYh0vOkJLpRpPtTHHeklPSKk83RImoWkdlsvOXuy09SSNfbwxHwYm6?= =?us-ascii?Q?Et0mTtjtsKhpWn60JW8ApGnjZobgg/gJh04CsiMWp7opcrKmLDftZNz8OkDV?= =?us-ascii?Q?FcjWq1S5QzMy2K4bwX6eQYNJLJUrMUNw2r/de6Jy?= X-OriginatorOrg: atomlin.com X-MS-Exchange-CrossTenant-Network-Message-Id: f5ff0d2b-063e-4ed5-71b3-08de3c4f4e28 X-MS-Exchange-CrossTenant-AuthSource: CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2025 03:00:44.7683 (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: Z7QlgPdrH/hiuEsmKBOcsQ9jrDgpyKRKaG1D6PS3sY5LXoM+MspiTCQI56lfmNgURlk/hSBiGzAg/w8mw83cCg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWXP123MB4183 Content-Type: text/plain; charset="utf-8" Consolidate the multi-line console output block for reporting a hung task into a new helper function, hung_task_diagnostics(). This improves readability in the main check_hung_task() loop and makes the diagnostic output structure easier to maintain and update in the future. Signed-off-by: Aaron Tomlin --- kernel/hung_task.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/kernel/hung_task.c b/kernel/hung_task.c index d2254c91450b..5902573200c0 100644 --- a/kernel/hung_task.c +++ b/kernel/hung_task.c @@ -223,6 +223,32 @@ static inline void debug_show_blocker(struct task_stru= ct *task, unsigned long ti } #endif =20 +/** + * hung_task_diagnostics - Print structured diagnostic info for a hung tas= k. + * @t: Pointer to the detected hung task. + * + * This function consolidates the printing of core diagnostic information + * for a task found to be blocked. + */ +static inline void hung_task_diagnostics(struct task_struct *t) +{ + unsigned long blocked_secs =3D (jiffies - t->last_switch_time) / HZ; + const char *coredump_msg =3D " Blocked by coredump."; + const char *disable_msg =3D + "\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\"" + " disables this message."; + + pr_err("INFO: task %s:%d blocked for more than %ld seconds.\n", + t->comm, t->pid, blocked_secs); + pr_err(" %s %s %.*s\n", + print_tainted(), init_utsname()->release, + (int)strcspn(init_utsname()->version, " "), + init_utsname()->version); + if (t->flags & PF_POSTCOREDUMP) + pr_err("%s\n", coredump_msg); + pr_err("%s\n", disable_msg); +} + static void check_hung_task(struct task_struct *t, unsigned long timeout, unsigned long prev_detect_count) { @@ -252,16 +278,7 @@ static void check_hung_task(struct task_struct *t, uns= igned long timeout, if (sysctl_hung_task_warnings || hung_task_call_panic) { if (sysctl_hung_task_warnings > 0) sysctl_hung_task_warnings--; - pr_err("INFO: task %s:%d blocked for more than %ld seconds.\n", - t->comm, t->pid, (jiffies - t->last_switch_time) / HZ); - pr_err(" %s %s %.*s\n", - print_tainted(), init_utsname()->release, - (int)strcspn(init_utsname()->version, " "), - init_utsname()->version); - if (t->flags & PF_POSTCOREDUMP) - pr_err(" Blocked by coredump.\n"); - pr_err("\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\"" - " disables this message.\n"); + hung_task_diagnostics(t); sched_show_task(t); debug_show_blocker(t, timeout); =20 --=20 2.51.0 From nobody Tue Dec 16 16:39:03 2025 Received: from CWXP265CU008.outbound.protection.outlook.com (mail-ukwestazon11020141.outbound.protection.outlook.com [52.101.195.141]) (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 E07692F60BC for ; Tue, 16 Dec 2025 03:00:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.195.141 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765854050; cv=fail; b=uvvrkqrsoR1/AbQ6amgmnFug9YiSgmEre5iv9iJD1OJxNV8pBO0UpeazvcBbUbW0boYLyMqKxEi6iuNxXir3V9vgpZ40bceATyhf1SsOAthOTzMeley9Ta0x6a/PdUCZKlQ0HAJ5ScMQlk4R55jicpBf3wHep0wGFae1lf/L7YI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765854050; c=relaxed/simple; bh=X9FVFY6TvA61OIavhFiAqOr0dXhX+wVhBfTGDJM59pA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=G+1nU9CgFhSiDYnkT9A2f2RioceCETv5mo+FsmCC/QE3u5movKGfzzLx0MToQznU5l+FKb8w2gipEhgEFaC7NGEdzPalvCKX2p2uNPmuie0vq24bA1vUHxMUXVYjlFM5dpANVBlzRWA3jBexsDyNieJof+F0zIHPHUhIIvxAvfQ= 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.195.141 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=vW4Pn4mX6xm8LqqUkUfIEZJmCKaEjQMaCgcEiQmKuRps/IUpnxW8jQWe1u8r2kb+Qav/27ojuERIXDcXK0rWR+GrOns69eBNm6fp6pOKRltYP46Qtzdp81+KEcinpAZ5S8JlprO7FEZTNGvmivqJqg+KnOPNmcSjZNy9l36xqJxc3xXBFnC+lbLN338s7slaj5hqcK+kCW98FQBkDu4clgyGb29FJvXbL0Mai3GvcCwr0ldipnIICOwb3ZZWoTTH+/RfUb7Z9o2tGptPeldX6Zcug1TBqAMZeEmENnYymDN9kwJgz1OCDXJ+xrdHmrvpVpiDfSp6B6Q0sIo4l6N8ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=T7T4+HA1GzzEim/iozJ94waZpDyt/O9bVlD1tiZ3M/g=; b=AHjBieatudYUrzuEf2WYzCDy+TsAckUiJ3pcPWdM3CGowel6BtVySEZSEhSX58ZhkxnRGvUTmTp1XAM2M3MP94tdhTaEuPk/NWMSPVl/78UfX2jeXJY16Wur8/jte6olcqAAoRq3K79B7Xxck+LcPoyFkVIYQC9B6+JEqj6ISluUG1EG/0YP4LJbupQVdIeiwD5k6N+tySxOexc3VTTPgkyC73p15hLB5856ybT2qMbmx4VGL0Nts+j1F1yj85ks/rFZ0TblNpmuTzkRbrHgxbbNcKUhEwy36y++WfQ2GrsncnG9ivWo5IBbayRJbPc+tYvyqDi5i9KFUdNn7vqjCQ== 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 CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:70::10) by CWXP123MB4183.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:b1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9412.13; Tue, 16 Dec 2025 03:00:47 +0000 Received: from CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM ([fe80::de8e:2e4f:6c6:f3bf]) by CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM ([fe80::de8e:2e4f:6c6:f3bf%5]) with mapi id 15.20.9412.011; Tue, 16 Dec 2025 03:00:47 +0000 From: Aaron Tomlin To: akpm@linux-foundation.org, lance.yang@linux.dev, mhiramat@kernel.org, gregkh@linuxfoundation.org, pmladek@suse.com Cc: sean@ashe.io, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/2] hung_task: Enable runtime reset of hung_task_detect_count Date: Mon, 15 Dec 2025 22:00:36 -0500 Message-ID: <20251216030036.1822217-3-atomlin@atomlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251216030036.1822217-1-atomlin@atomlin.com> References: <20251216030036.1822217-1-atomlin@atomlin.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9PR03CA0732.namprd03.prod.outlook.com (2603:10b6:408:110::17) To CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:70::10) 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: CWLP123MB3523:EE_|CWXP123MB4183:EE_ X-MS-Office365-Filtering-Correlation-Id: e8393093-29da-44b0-768b-08de3c4f500c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?3vk4Hv6Am6gtjEeaXKIWJRkaaVNTWEHpCxcyftnmp1+7XE8izytk1eOk6s1g?= =?us-ascii?Q?cApCe6k27PjdlIKXTHoPwdGjaH8gxBxMzOdkBNAoX/u6fMW7shpuQIS0jWvH?= =?us-ascii?Q?2qhMIQe8y4ymgYK0D5ywcxHVf2aZ4pC6BqLc4IKYeKTVHmok5oAPzdmW9de8?= =?us-ascii?Q?TYSW/zm3jCUCC6MpOdvAqv9tH6Kt6SbzJRZbKAjNTgVRrx+plsLpYTTgXXml?= =?us-ascii?Q?GKs6W4xqY3YlWEbYsSqraV4aqsW92NGMN9tiKMGvNvkIXfiLaTlryMgYF0J5?= =?us-ascii?Q?GzyNdlES3ecEcGECPstZmXjEHq9oiG8ydQspAGvL39vpKsmKvsa9xdVbegMq?= =?us-ascii?Q?lxBW6CTQjeVJmtlItXRdCHSjxGywgMPqSi3PWhphX3mdLnbSLIhamjDjK3hu?= =?us-ascii?Q?BNI3HA1+mcXv3DiLJVzGo9V2tKnOqfewFjWpOlOhYvEDYIYglhOBaiMcDW4w?= =?us-ascii?Q?bFk+N9/la/LCdXCsR+CmF/+td07Zat/I1550zQ0AEjituzKLlHD6d6NiKxdW?= =?us-ascii?Q?3Sa+bo+/CjdKhBwRNno+LwnFw40CbK12XwBsek9gQCAkw/7hQ+TNRD0E1k23?= =?us-ascii?Q?HywE8PTAXpxyDC0vd7voEN5JzBpfQ66gEOgAGiSQRKGFFB7OqEGGZoHc5K4C?= =?us-ascii?Q?BiluSPjS83MZ6TNIKp1JpByx0t8s8KlwlRXIxaqgUyaawzBNVYhGckMgFb5n?= =?us-ascii?Q?hesgXTNACzl0CaFdNWR/iUqxri4i+ZlC4iQnhxc6ExmUGqgsTOBDBVxeRusD?= =?us-ascii?Q?jBciFaN4w2vu1XCzlXpZllQieKZo9q7nwVbWGBklyC1KNqnF+zmW/kfNnQ0j?= =?us-ascii?Q?kI+67xlXGIrhmxcHLd1RiHmvwAeBogcTW7jT7vzASmCHxbRxaV9LeodpKs9N?= =?us-ascii?Q?DFjK8oN3xn63op7FNgVlM/yQt2scBZmm/Go4AjdQjePJSe0HcZmVc7YXrEDQ?= =?us-ascii?Q?lCZslzM00F8QjmnOWxfZ918dJtRNKhhd6S2ZaZVCfJZMlffcVXUHktsbNYzu?= =?us-ascii?Q?WIK4JlXqBdSU6NaS6sO7wktMAMRk9Obp4visCYmpk4eQ/L8kDWRoI7ZiX71x?= =?us-ascii?Q?iYr5pQx2NGc1OOz0+FBxD1K/SkVo0XujOKkfCLf5XGdyQTY35lrimTec/o8P?= =?us-ascii?Q?3plxvzKpAbMOWYPBukmbxb7trw2ahAAl5FgghWUpzcT3x8ilpFE9icY/oDw6?= =?us-ascii?Q?uZeSTlhV3lZppj7f35VdygsiQYtZcnxNk9YYlzYuiI5VI6I0gI/i/nuWGOP0?= =?us-ascii?Q?g/MlrzACLd9OgPUK14magW2GQzk31+m2ug5AEtmG/q9cENptES5tGPKQcc/g?= =?us-ascii?Q?JDOcj6FDFUIZr8SEX0aagKc9Z5NSI3xU3OSEZVZ1QgyGfTYOtNasn59hD5zD?= =?us-ascii?Q?PZdCzdBn0XxCLCvD/foVrnIpFHZiT6QR8H/NUlWhD0abkqrsTm+XJlq/lxRp?= =?us-ascii?Q?MzqlxuOJ5y/zKghDqD9pTyn4NONPnYCz?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?zEwcH4/fzVK+dfb82ETNZPkvYdHLhXsWuS3t/KJgkfhNSGp2RyhIpZm7Fv6S?= =?us-ascii?Q?66N0Huc7dt5QMHWWF0QjLEm3ZCnfIZ4ZN1wBP/vIuE7bBSicoBfiow1nRu9i?= =?us-ascii?Q?FSRHohB1NeIUWwcyPxbo+h0BxJwdpXBvZ9mun0Tt9igEtb1Wr4woc4+AcWht?= =?us-ascii?Q?g6HqvbQbBYhiCXub+VDNIeCl7JBvdcUAr9IeFf3n2aNfaEyarZ7X6jjeZCiu?= =?us-ascii?Q?IcribKsZtUms5WW5H1H6XJuBbZVOsuREHBNtemlTkQcq0FKL71gNIPhAeEEu?= =?us-ascii?Q?yHEKJXjue2XVn7MsEJzOzGFJzGl/dWb2Lqx9gzQA6qvl9dpFpqOr9XMK96qG?= =?us-ascii?Q?tdfpaAaHXqV/DJDp1BxZ7q2rnvpF9M01AH5XA5E2AomwiFNp8p4jXxea0Bab?= =?us-ascii?Q?BBszmSdEBSFho/pWzSqHepsZ9aa97DLwDALU/teJObACJ0dqusOKDKgXFqTa?= =?us-ascii?Q?+WyDV8gFzCG5W4LKaKDppTXpJPSHoU5/w6zfa66S7KDkPujfOTz4j03TrS8i?= =?us-ascii?Q?FcaTWK0QtDD0W9dE7xVDdDVn0z92E7UKmYYmxjFSNkdaD2FZxn46cvD2zCnS?= =?us-ascii?Q?HyqobVuEV7wJ3EYUYvJCKdZpd9INPSDKfJjezQE5RxLtrc0Ji6ywJ1vIXmxD?= =?us-ascii?Q?fOmq4hye8hKmiPspaDGYw+c36YDEAz1Fh0o7SfFUUq4lq+2HYtIdZIqvM10a?= =?us-ascii?Q?hjgI7qDGyM9KL/RGSwOR//AK2+8J3LK1vHhJTuLXvQL8vvqgxyawHNImubFu?= =?us-ascii?Q?J0E9NIRu6EA7O0U4NoPnkVTWhTkwvl1EwuVxd2A0hBm32Iuh6xmdbn4pWEd6?= =?us-ascii?Q?0o0Yqb3qsf3UuvzLHm86huCTOdRdYfM7+Ckh+G7+m1wU6KYONM10AGr9m/La?= =?us-ascii?Q?1hAgpuCvD+eNSoUliltCrjsjkhO21VPx+cgoloAdvdF2eKsrpyU2uK4lRUYx?= =?us-ascii?Q?KJT7VtYo43FIEhBgUTfw+0NO4/PVFlzTsfHYUODqhtiSCmwPSZLfiJhxuLsA?= =?us-ascii?Q?owcQrmotUTkFJ5MZr9lt/oUtmkSW5jijUZiuWIqB19bPt+yZbYy/BUGin0+S?= =?us-ascii?Q?7T4Gxj29EMFSX7ABHcJwnZFm4/1gZf4R6hZUrOqDH5fPmd5RMm7J/aOIWYct?= =?us-ascii?Q?3Q2r+1mVt7PMdkOZkR+bv35nrQRUIZZbUdp6Be/bOZfL71mLil29PhHVA1+j?= =?us-ascii?Q?RUblELN9z6ZtRzgaTmfP4ps0PqZWwzssuB9BX4H/jTHyNua9HcbRxN6dAck+?= =?us-ascii?Q?uCh1DbY5tp1M9Sd387kAsA31sx0YOVlA80j0FgVIO6pNIc9pZl4BxmC0mKJl?= =?us-ascii?Q?O+G/ozVcG1iLzrHCvcO9UOIN8q65byxZjZKNCM7tJXDK8qfkpRy/BB64GUIS?= =?us-ascii?Q?aKbXiU1K6ShnkJiba6WhcvnZrtjxB3tJJuiK0ykbvTz4hHJt074nnjzEAgCh?= =?us-ascii?Q?qqjtNVMNIFxCv677Zn7Z9Jz52mZ2OCGAZpkrDee5MMO0SbH4UQDNago94LvK?= =?us-ascii?Q?AGBKPO/E/SF/NOrg7HEF0YvLJhoto+6OlCmCAFNAp8TzwDiW1FGgQvd6n/kR?= =?us-ascii?Q?cQ3QzIErVgQGwnCE7quWjb9CweaZqSXTyCLPBH3V?= X-OriginatorOrg: atomlin.com X-MS-Exchange-CrossTenant-Network-Message-Id: e8393093-29da-44b0-768b-08de3c4f500c X-MS-Exchange-CrossTenant-AuthSource: CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2025 03:00:47.8287 (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: wy86wFnH+cxCR3PO6lwbVuhlK1NOLDO02NcHPTJDFsALrj+Ioce1vy6es4uKwGv7rVFQipnN/vi3sMV6BBNwsA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWXP123MB4183 Content-Type: text/plain; charset="utf-8" Introduce support for writing to /proc/sys/kernel/hung_task_detect_count. Writing any value to this file atomically resets the counter of detected hung tasks to zero. This grants system administrators the ability to clear the cumulative diagnostic history after resolving an incident, simplifying monitoring without requiring a system restart. Signed-off-by: Aaron Tomlin --- Documentation/admin-guide/sysctl/kernel.rst | 2 +- kernel/hung_task.c | 29 +++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/ad= min-guide/sysctl/kernel.rst index 239da22c4e28..43c17b919969 100644 --- a/Documentation/admin-guide/sysctl/kernel.rst +++ b/Documentation/admin-guide/sysctl/kernel.rst @@ -418,7 +418,7 @@ hung_task_detect_count =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 Indicates the total number of tasks that have been detected as hung since -the system boot. +the system boot. The counter can be reset to zero when written to. =20 This file shows up if ``CONFIG_DETECT_HUNG_TASK`` is enabled. =20 diff --git a/kernel/hung_task.c b/kernel/hung_task.c index 5902573200c0..01ce46a107b0 100644 --- a/kernel/hung_task.c +++ b/kernel/hung_task.c @@ -375,6 +375,31 @@ static long hung_timeout_jiffies(unsigned long last_ch= ecked, } =20 #ifdef CONFIG_SYSCTL + +/** + * proc_dohung_task_detect_count - proc handler for hung_task_detect_count + * @table: Pointer to the struct ctl_table definition for this proc entry + * @write: Flag indicating the operation + * @buffer: User space buffer for data transfer + * @lenp: Pointer to the length of the data being transferred + * @ppos: Pointer to the current file offset + * + * This handler is used for reading the current hung task detection count + * and for resetting it to zero when a write operation is performed. + * Returns 0 on success or a negative error code on failure. + */ +static int proc_dohung_task_detect_count(const struct ctl_table *table, in= t write, + void *buffer, size_t *lenp, loff_t *ppos) +{ + if (!write) + return proc_doulongvec_minmax(table, write, buffer, lenp, ppos); + + WRITE_ONCE(sysctl_hung_task_detect_count, 0); + *ppos +=3D *lenp; + + return 0; +} + /* * Process updating of timeout sysctl */ @@ -457,8 +482,8 @@ static const struct ctl_table hung_task_sysctls[] =3D { .procname =3D "hung_task_detect_count", .data =3D &sysctl_hung_task_detect_count, .maxlen =3D sizeof(unsigned long), - .mode =3D 0444, - .proc_handler =3D proc_doulongvec_minmax, + .mode =3D 0644, + .proc_handler =3D proc_dohung_task_detect_count, }, { .procname =3D "hung_task_sys_info", --=20 2.51.0