From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from CWXP265CU010.outbound.protection.outlook.com (mail-ukwestazon11022119.outbound.protection.outlook.com [52.101.101.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 1D57A1D5160 for ; Tue, 3 Mar 2026 20:30:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.101.119 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772569844; cv=fail; b=FK8aCSzUZnwHem1o44HAhnJqd65HgRNOzxwxkhII0dPnCNmguj8JSKgwT0r+2GDV9UiIsSBZOmTzU9zwLhZEsW0UEqgVDVvp8yCBmwC/+LMMPuH3F9EngiJFa8yCoFqT9TKQi1e4Dx/t8pVn4/bePeNUnuk/a2Dxumd5g/pUoQ0= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772569844; c=relaxed/simple; bh=2F/djqk4iBZ2LytldZI2DsPeHon/dsb9wvkUc4FJKEM=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=GMxKHsOFT048n40ykhcMuoSgsBikxFwZDmv1KnG0COfbl04CWaqz0PROJMbo8coAQQlt9l+/lrfM1WqYr789Sl82a5M59HhnQMY2mmtJKzJv2giudvfT+Y0dZwnX0gu8AfpUrOqGhi4yDbGAWyLSNFZttcuG2TlkrLD7b0NZavQ= 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.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=cg+2pmm9Ax2nBVap5nSs8tBkK+BA23ioEALBCEWTPightxkbSVx5IrSrKOld/rj1NnUjywsax7JbhEEhBorUMMpFrGuJ8c63i5q/Wx3Or57HkPYKeS8mE1JA4T3t/N5inSuU6z/W8h39UcmmmZSnjCN8nQKJbzleYf3ugs7bnCgeBvdz7/cofxoqEuEXZ/D1bC6sD5XocEqyKBR/6rAUI7Sh2nDop+up07agMbS5jekqI9rvdcdPUbODqUGj9fi7peBM/faBFq9Y4XrCdHerhRmI6azcJNixqd3HTFMvrwx0Q3UDkhWYRwgsa6gfezPrO9cFQsRrEVPw0iUMOrqoYA== 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=qm6/mQR8tVAKotKp2hyAnBblrD1U/JX11c1TY1AG5HM=; b=RSAugeCipG84eBPbWIzYT0fddOCVJIGuABA8Dcy08Swx/Sby9zgAOylpQe1EIstvB7GaNBKo0dRQAbWbBEDjhQ3mZ5sfEHbPIX0EIKeUcTvsD6l4KYmlJo3JkbkN84gFGphGnaSZjONKp3pfONmkpB92Fh3mkkRkvc348nYQ6WDcgWDMbYYASvqYXZo1RnU8wteg7OIEq0d+ep6+ehuzcg/ODLjA/8oReFdSIW6C/6lGqAtqZP4guamHSyx/9Hs4SOUCA/AVZbzKvipm06dTALMggex8ZvYWme5smJ21kvv57yCav82viANQ8M9wFPfwF6ZDFRDazOBOeyhHywLFMA== 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 LO0P123MB6636.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:24e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9654.22; Tue, 3 Mar 2026 20:30:34 +0000 Received: from CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM ([fe80::de8e:2e4f:6c6:f3bf]) by CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM ([fe80::de8e:2e4f:6c6:f3bf%2]) with mapi id 15.20.9654.022; Tue, 3 Mar 2026 20:30:34 +0000 From: Aaron Tomlin To: akpm@linux-foundation.org, lance.yang@linux.dev, mhiramat@kernel.org, gregkh@linuxfoundation.org, pmladek@suse.com Cc: neelx@suse.com, sean@ashe.io, mproche@gmail.com, chjohnst@gmail.com, nick.lange@gmail.com, da.anzani@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH v9 0/3] hung_task: Provide runtime reset interface for hung task detector Date: Tue, 3 Mar 2026 15:30:28 -0500 Message-ID: <20260303203031.4097316-1-atomlin@atomlin.com> X-Mailer: git-send-email 2.51.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BLAPR03CA0102.namprd03.prod.outlook.com (2603:10b6:208:32a::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_|LO0P123MB6636:EE_ X-MS-Office365-Filtering-Correlation-Id: fb8dd80b-0b2f-4425-f9f4-08de7963b8c8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|376014; X-Microsoft-Antispam-Message-Info: VXo+Sah8OKWK9Wz2JIPFvO+Tigs7yDtIZ8QdOPDTrHxx8HEB0oamF2kKqvq2ZMqnCBDWZ/fArFcVYhh/sUi3dPwrpBca778bNS1fIvkDKXAgjfbLpBoMe+uBIoLFgbJknro9Cev9SIX+rlssBMNSODdHBdc5tBUsT4iyLAjmLroKrP50UgoQO3cUrolr0aLWgLzVhL8QFrlhZrHeV8ZRKqMM2PtEheoUjrwu2fbKxq7c8QO05nklx2BILU87VvMg6mKFPP8ri3g6iALOGZeqwCvrLsVCcTqZklEvwpops0dFpY4Xb3GtuBxre13wvEV23T2ctFg5Bm3F49h4R5b72Ki6O0ryj3VEohLz5YhHyRBhX7NH+RoohbKotSdXb1AquEsMg0LzkfhdZFAwdvBffehmJow3FEQ+0gEKrrkXRLVEBd+/ZMAVuoRh02XfMk/yau/NlkgymwGZQR6UAziTsoV19aIpYdOmg3dYs4GrQLzZ+jwUk27rOUySrGPi7vpHVF0e8FwyPiERFcFeZPDOpQhlCVhevH9WP1cC5F9gW8P6UIqRSJ7xQMUQfVUm4Pcys+CTlFn0+76tpHvmUI6aAP31mFvQ9DPw2oWEi9CtzDc/4SOGPLi3a/KhcYt6qd7d4YdBdiOMTmYYMYWAmJ11ns/HVrmdWb62W6NwSonmPRDvgy/0rpFPMcP1qA/mK+WIUJOjbva3J06yyM7zQ6R0DdidJXDMMZIHE0QYX590xdE= 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)(7416014)(376014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?yv+GPoKIoWBovCgtwmicLUQAOMxTzaLrQHLrylCw45LZXaz+Y9zbIsmke5T5?= =?us-ascii?Q?oTUW6AmsC4GvNfaTduYtYdZTJPHgWjzYi3l0rmbRxKFuhJxl8w3Gwg85pqL2?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u/o5AFzGpS7GJp2yBerP0fp1?= =?us-ascii?Q?U+SVwCvREinzxoheOzrTerzgxMaun8gz34P962P5J2aelyo67pGazT+kyCMQ?= =?us-ascii?Q?JjwtnR/0jGy7wNtyU5M8qdqUa0x/i4r1/B5rco+dG8+evAc9RLfyc5K2a0RG?= =?us-ascii?Q?Ggrdf57kOr9D+nvTkQAoCBsv4KH3OjA+L5esg7UOFcd/tn4LZxMQ5YnU3naf?= =?us-ascii?Q?FqJzrtmaXH6145ZaocoVdh0O7XN3BX/KQXuII83ws4Q/ZOuhwd1YIloXURpg?= =?us-ascii?Q?0uu69tVLhG1QJHkP6f7I6aE8uRWhRaPryNnzV5QOACX9SpbJBTbzPsxUohZq?= =?us-ascii?Q?K0bZ54kTPuP0XV9uRukJs7UIzjX0RzdlCQ3BaOnzH95iywI6E+vEBr3zqEAE?= =?us-ascii?Q?GvmwOy865vx0jTn0/PBTXgxFkn7omkgrkg+/E6UsV9BhH7V7nDHTHCrqeS0C?= =?us-ascii?Q?jPcli5ya3VvWapngQtGRgK6Wxu3wzwagZDNc+MWP9QAXFaESLyZEJgLgY15y?= =?us-ascii?Q?Z1uCDGI4BkvEdqSoNDSoltbn76l70uKbooh4BdxHFAAy6rtsOdFacXXAritq?= =?us-ascii?Q?uFWpxT8IYVCNJdM7hsyw7958di8Qe1gJMGuoZ6kjpVrR/melDBTlXSMnPPkS?= =?us-ascii?Q?BeJyJq3q2lbDcYH/NRVzOSi705krOimzGOtIEvotSABK37wXbf4eymjjn5jZ?= =?us-ascii?Q?9lPskmC8/5zEeUE2J291YBfU75gash33dwasD9ts2wYj2kr138rqpLCMlYj/?= =?us-ascii?Q?PIWVSTE31Q=3D=3D?= X-OriginatorOrg: atomlin.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb8dd80b-0b2f-4425-f9f4-08de7963b8c8 X-MS-Exchange-CrossTenant-AuthSource: CWLP123MB3523.GBRP123.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2026 20:30:34.5378 (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: 12v1D0pAX0zVq7fVx0XJT5a00gOj+D01DaZIVkV1yjCA/iAUCmIGd7f1wEikHaxylCj1Qa3S0BNKWM1tvWBlxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LO0P123MB6636 Hi Lance, Greg, Petr, Joel, Masami, Andrew, This series introduces the ability to reset /proc/sys/kernel/hung_task_detect_count. Writing a "0" value to this file atomically resets the counter of detected hung tasks. This functionality provides system administrators with the means to clear the cumulative diagnostic history following incident resolution, thereby simplifying subsequent monitoring without necessitating a system restart. Please let me know your thoughts. Changes since v8 [1]: - Added Reviewed-by: tag from Petr Mladek, Joel Granados and Lance Yang Changes since v7 [2]: - Immediately update the global counter as soon as a hung task is detected (Petr Mladek) - Added Reviewed-by: tag from Masami Hiramatsu and Aaron Tomlin Changes since v6 [3]: - Decoupled the detection logic from the reporting logic. check_hung_task() was renamed to hung_task_info() and the task_is_hung() check was hoisted into the primary check_hung_uninterruptible_tasks() loop (Petr Mladek) - Changed the global statistic update mechanism from incremental atomic increments (per task) to a single batched atomic_long_cmpxchg_relaxed() at the end of the scan (Petr Mladek) - Strengthened the memory ordering using atomic_long_read_acquire() and atomic_long_cmpxchg_release(). This ensures strict synchronisation between the scan and concurrent userspace resets (Petr Mladek) - Updated the inline reporting comment to remove the hardcoded "2 minutes" reference Changes since v5 [4]: - Introduced a preparatory patch (Joel Granados) - Extended custom proc_handler to handle SYSCTL_USER_TO_KERN writes, strictly validating that only a value of "0" is permitted for resets (Joel Granados) - Transitioned from atomic_long_inc_return_relaxed() to a more robust read_acquire/cmpxchg_release pattern to ensure "All-or-Nothing" scan updates (Petr Mladek) - Re-introduce hung_task_diagnostics(). For better readability and consistent metadata publication Changes since v4 [5]: - Added missing underflow check (Lance Yang) Changes since v3 [6]: - Use atomic operations to ensure cross-CPU visibility and prevent an integer underflow - Use acquire/release semantics for memory ordering (Petr Mladek) - Move quoted string to a single line (Petr Mladek) - Remove variables coredump_msg and disable_msg to simplify code (Petr Mladek) - Add trailing "\n" to all strings to ensure immediate console flushing (Petr Mladek) - Improve the hung task counter documentation (Joel Granados) - Reject non-zero writes with -EINVAL (Joel Granados) - Translate to the new sysctl API (Petr Mladek) Changes since v2 [7]: - Avoided a needless double update to hung_task_detect_count (Lance Yang) - Restored previous use of pr_err() for each message (Greg KH) - Provided a complete descriptive comment for the helper Changes since v1 [8]: - Removed write-only sysfs attribute (Lance Yang) - Modified procfs hung_task_detect_count instead (Lance Yang) - Introduced a custom proc_handler - Updated documentation (Lance Yang) - Added 'static inline' as a hint to eliminate any function call overhead - Removed clutter through encapsulation [1]: https://lore.kernel.org/lkml/20260208002116.3790497-1-atomlin@atomlin.com/ [2]: https://lore.kernel.org/lkml/20260125135848.3356585-1-atomlin@atomlin.com/ [3]: https://lore.kernel.org/lkml/20260115023229.3028462-1-atomlin@atomlin.com/ [4]: https://lore.kernel.org/lkml/20251231004125.2380105-1-atomlin@atomlin.com/ [5]: https://lore.kernel.org/lkml/20251222014210.2032214-1-atomlin@atomlin.com/ [6]: https://lore.kernel.org/all/20251216030036.1822217-1-atomlin@atomlin.com/ [7]: https://lore.kernel.org/lkml/20251211033004.1628875-1-atomlin@atomlin.com/ [8]: https://lore.kernel.org/lkml/20251209041218.1583600-1-atomlin@atomlin.com/ Aaron Tomlin (2): hung_task: Refactor detection logic and atomicise detection count hung_task: Enable runtime reset of hung_task_detect_count Petr Mladek (1): hung_task: Increment the global counter immediately Documentation/admin-guide/sysctl/kernel.rst | 3 +- kernel/hung_task.c | 101 ++++++++++++++------ 2 files changed, 75 insertions(+), 29 deletions(-) -- 2.51.0