From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42E31367F41 for ; Mon, 2 Feb 2026 13:26:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770038782; cv=none; b=lO+Q88LpbO0ywCiFvNehszz3HKIp/7MIdODn1t7YVZAWkBNTjP5vs40kwJGBGYNSGs8K+QcN+CuB+dXeRW02pZmCK1m/fUkQGSo2hBxO3MH8M7o/cmNmFAy3PsZ9wnaouKHyoLYoJOPik4x1ezZowXj2giP1REmkk/V5gFWP8uI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770038782; c=relaxed/simple; bh=XalfvpIz6YxbJZtePZ58FQ3BEEcnhEiwX7y+3S8VEn0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UWA++ap6bfxwcMMQJRRB6XlRxpzyO+1h3eM4Z82nJk/fv74BUaH0ZCs0Dx5CKDRge5Y3tuYqlHrsEl8SoaFW5ILIgJafA/HZV2JSee64j51T/CmtaszZ7fvYQ4C3nbjj6jD06Ijp+2A+rUaZOF4iafRoIJhvS9XQovNG0Nz/VS4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=Qy+M1Uxs; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="Qy+M1Uxs" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-432d2670932so4093194f8f.2 for ; Mon, 02 Feb 2026 05:26:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1770038777; x=1770643577; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=06MSQa9TIbWa/odXTm1MvsLs6OsLuBX9+2z7JnWoKyU=; b=Qy+M1UxsfDhz3DcWX2jvnsw4ufH0TcmrYKYzkZqwkGUHBHC7yvbDz5XnkzD01XEB4F tiXShBdflGLQpF9+TyaUu9QTyPA5gkqK7IKQXZgPDxmmFljbj47i5rvr9BkC8LhFAuE7 5RU17aJyjfaUvwbeTivBQLD24eMChu8luHuUgBws9ZcDRUy71oNKqbUU6JgMvlMt2YXJ Jyl7C2Jyla86rbu1m/Et17rr294vMOk8kXUDxr6iQ0/Mb5VF03fXphlp4kyDzyFaOsta 0YhEVbLQP4Tpcqnvw3BBNl26buDH0WKIGcD1YBILQgFIjZMCvvtnupCz5v61AxNeMhxq B5zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770038777; x=1770643577; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=06MSQa9TIbWa/odXTm1MvsLs6OsLuBX9+2z7JnWoKyU=; b=KHqxiiqONm1/RMPY5j/4ICEoPeSEUGKyYmtzFMwGh+jG4FIYSZIb4FJg6tS52UgA/H EnR0zwK2e4TA7STMgr1h+XsvJgbKLvAfb7UPvYZDxsGIx467FPa9PDD5QULIGS+qlqxp fr2CH2BAxGdxF6KRgFqmFQjWldXqjiVkQpfYSJPFGjbRIQHm/55vcOVqV/m2Af9/RUHb 7R4YY0imh+WG+SxSWh6A6T4lCns1sRhT5FtGPB9QlRh0w0pbKsKl3MEUHdy25/9GFgkF FkgcyVT9UtG8IQBA08FyqwT9bkNk5ijn2WTMTS38k+PyxdUrbJAyqkKHbUMHSufXhExC 5mog== X-Forwarded-Encrypted: i=1; AJvYcCX+l3bj9AQek6ZCYpZ3SLtChINW47jUd5dHqp6LrHsVNkAI+eAq6AMDI4TGae1nAuDDacv/doBIz8ZTvtU=@vger.kernel.org X-Gm-Message-State: AOJu0YzRr3BhhLeF8QDCeup0epJPHaD9NBfacXp4WfzJqCKJpdcMKDLW HKqSL1ETv2fAQje7FAh4ZFnIIpE9THVt0A5Qfu8bC4X4AWGV/zvxOtWPpOEitY4ctlo= X-Gm-Gg: AZuq6aJY+pT2x0jphf1W6wGXZoVU2vj20hFYGbKeEkuIGavou+hGEEBKaQPbGHHuqOM e1rH6koS438REPGeoPkqXZgt0rFH+2U6srV/UvbSS7Z8ncGQb+SGUWVXk6TNoC+R8Ob1c8sydEb YWL6B7J40NhQlPn7OLnFb/EVbHmICUcuqkkbJeNJ8X1FQZNOVlU1UZbrBA5MgrVCdy/XN87Cpsz qPkNjPOjuth4xV3QU6V0g5I/X/ynSoL5bzJmONRKLvPtpN4QtwXoHuZ9g0nGda1cxsLjBhIix0m 1Pf1hYyO7b9qkyAQeM0xHtvqffMKy1Z2uj/oOqKih+DQcyiHRDu8XJaGhG8nMqz1KzOeGi8/SO9 Q/Fb2rW2g+ZMdMiDYab9iACbz/44UgzyOtQktOnc6NeST5+J2tsz1jRXMAMfzkjCgj2sO6aTu9A MpGS94rN6JJBhp4YQtFw== X-Received: by 2002:a05:6000:2689:b0:430:fa9a:74d with SMTP id ffacd0b85a97d-435f3a7bb17mr17893027f8f.24.1770038777289; Mon, 02 Feb 2026 05:26:17 -0800 (PST) Received: from pathway (nat2.prg.suse.com. [195.250.132.146]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-435e1354114sm46386784f8f.42.2026.02.02.05.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Feb 2026 05:26:16 -0800 (PST) Date: Mon, 2 Feb 2026 14:26:14 +0100 From: Petr Mladek To: Aaron Tomlin Cc: akpm@linux-foundation.org, lance.yang@linux.dev, mhiramat@kernel.org, gregkh@linuxfoundation.org, joel.granados@kernel.org, neelx@suse.com, sean@ashe.io, mproche@gmail.com, chjohnst@gmail.com, nick.lange@gmail.com, linux-kernel@vger.kernel.org Subject: Re: [v7 PATCH 2/2] hung_task: Enable runtime reset of hung_task_detect_count Message-ID: References: <20260125135848.3356585-1-atomlin@atomlin.com> <20260125135848.3356585-3-atomlin@atomlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260125135848.3356585-3-atomlin@atomlin.com> On Sun 2026-01-25 08:58:48, Aaron Tomlin wrote: > Currently, the hung_task_detect_count sysctl provides a cumulative count > of hung tasks since boot. In long-running, high-availability > environments, this counter may lose its utility if it cannot be reset > once an incident has been resolved. Furthermore, the previous > implementation relied upon implicit ordering, which could not strictly > guarantee that diagnostic metadata published by one CPU was visible to > the panic logic on another. > > This patch introduces the capability to reset the detection count by > writing "0" to the hung_task_detect_count sysctl. The proc_handler logic > has been updated to validate this input and atomically reset the > counter. > > The synchronisation of sysctl_hung_task_detect_count relies upon a > transactional model to ensure the integrity of the detection counter > against concurrent resets from userspace. The application of > atomic_long_read_acquire() and atomic_long_cmpxchg_release() is correct > and provides the following guarantees: > > 1. Prevention of Load-Store Reordering via Acquire Semantics By > utilising atomic_long_read_acquire() to snapshot the counter > before initiating the task traversal, we establish a strict > memory barrier. This prevents the compiler or hardware from > reordering the initial load to a point later in the scan. Without > this "acquire" barrier, a delayed load could potentially read a > "0" value resulting from a userspace reset that occurred > mid-scan. This would lead to the subsequent cmpxchg succeeding > erroneously, thereby overwriting the user's reset with stale > increment data. > > 2. Atomicity of the "Commit" Phase via Release Semantics The > atomic_long_cmpxchg_release() serves as the transaction's commit > point. The "release" barrier ensures that all diagnostic > recordings and task-state observations made during the scan are > globally visible before the counter is incremented. > > 3. Race Condition Resolution This pairing effectively detects any > "out-of-band" reset of the counter. If > sysctl_hung_task_detect_count is modified via the procfs > interface during the scan, the final cmpxchg will detect the > discrepancy between the current value and the "acquire" snapshot. > Consequently, the update will fail, ensuring that a reset command > from the administrator is prioritised over a scan that may have > been invalidated by that very reset. > > Signed-off-by: Aaron Tomlin LGTM, feel free to use: Reviewed-by: Petr Mladek Best Regards, Petr