From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy2-f12.google.com (mail-dy2-f12.google.com [74.125.229.12]) (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 60E6C49BD82 for ; Fri, 2 Oct 2026 13:11:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.229.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790946698; cv=none; b=GJ6q4o/d8u7H1U3LfAuQ+iFLSdjNQq4TzOQUTwCEEtSBSuLHu35ajyLJIidPkfiTWXvV2I2GizyBKmgVxpr3sLuoOnqIDJOpW8v9kCFYbWQeCft/LvRfonBAACPoI959VAjwUptkDeLAhwBUkJKDfwi25Iznxg0VYON1i9U7Tf0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790946698; c=relaxed/simple; bh=9LKpz3kS0U/O+ogCzpthVS7zLgh0K4YTIMJPzUCU0Uo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jXblxcFaBRYzf5j9yHRoF7oSQhH4I8McEVvDLjTj4BI99Nirxh3KbU9/RFsBd7Mh3yiacUEemCFXUI7WT6tMc9jqWmwDP+/n/RVDUjtz5eMFFb5XISEDfhnH07yZlugYsECmQzk7EoEKBxXsQZ7whx2kBWdJ9pGAuvq9J3IqHss= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=F0qrgyUM; arc=none smtp.client-ip=74.125.229.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="F0qrgyUM" Received: by mail-dy2-f12.google.com with SMTP id 5a478bee46e88-328664c2da6so6455202eec.1 for ; Fri, 02 Oct 2026 06:11:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790946691; x=1791551491; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=AXW18KF21LCiFNVNAVkygqJCkvk1Ia+QDkwORzpp+Bk=; b=F0qrgyUMn/DtHRvDp1I6VmWz2lgKRF1LdP1Q65wTl5qJxotATi3jFXgZZ5268knBCy XtbwNg6fIRuNUr0PbpGFE5mkHHftEAxGmV1gnkcv/sub2VqC1yGLSIlrzpVM1qz409Un Wt8V6JEbo0QNXvKGDMeP7onepELRSotQ5sHGpLfwUXMElOUKVZxH5J+UnuYL8RTuv9lx F7tvP8O1QkMeoIoA0BwAfsnz1G2nRjbu97PwFYrHY9tMz71ueZNKrYodReNqAApuC6ur 4BLdanOPS27O9yhYToZTJJCgc4lclkFS+iKvrKsjp+udb9j4oLdo6OQAIJlX0L3bzTDe oNKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790946691; x=1791551491; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=AXW18KF21LCiFNVNAVkygqJCkvk1Ia+QDkwORzpp+Bk=; b=p0Oyr3VtcF+1yyo+osC6lj0ENIHgf80IQnD6boUhhBiqpUnA606iT2wx2TAz8cVAEQ /cG7kOD1zRbPDwDI060fXJwm+uRZ2jKAIjgS9cvmo94Zhpn13bY1nrsSaNNXSSo7dz0D /aMnk2E/vxJZJXjI+yWMaoaWsng+cBF/GIGRr/yL5pJ20Lqbl97Ct6lEALc2fT5hIpDn F4oNWtqJIE6rT4pyBFA/qJnK2MPreL3KtFRcgWHZ3QJDMJlvyVY26bZ2uyA7oAIiqCnR 0cNJrd+j2cM/xy9yzkyDOiH5+TzBf+3uTHoG7URRzWaDkcJTx0gVr6U1eDeRq9fZsUlx AnKQ== X-Forwarded-Encrypted: i=1; AKwUvByHIvj4EjHV3IC3s92OZ/B/tYvSpRP4vXFwxTgpR8fNm3G146qHXsidRCsFkmjwu8LpFfnidsNbNEw=@vger.kernel.org X-Gm-Message-State: AFq9FYKYHIKzB2fvf47MFDPvMlgN1+NYr0NDj0NajozK75viKDDPTVOd ljUuxiYa4bXzlO8U7TY1JrVnqli9IByeuNoLEVB0rxYjyI/JSTwfxVl2 X-Gm-Gg: AYBFou2Y3ijKo8LQv7QqcgGCD4ZIanccXiEfM6I1Us+E+cv0reVInWMzI2Lm9YVX8VE eLtwC0uc1MHWadDJmuQ8SMN4Aw8dxPiQ/S42eoCoQyoFRIx2ZBreoSpIWG4e0CS7ULgc1aDDQ7m 429lvsGOuqTzO4qimBC71bYZ9VGD14EZUGn8tqPRB5fY6RcO/R5gWaVDNKxPYrjIouLhggXojvp L5k7MBsv/f0IDxZKSa6hIDvhcDlDtpeUylTzYpd1wb34GLjbJCuzmpVAtv4qjSCYT65gKdWJyTK YfyqWipvHOBj1jYt9Dz70AL92EfuAvyzYhr1w5oSjBGlu6lm16uFG00gOOm0Oaj02RLZ21lONI2 7RpLDGw3GnzGNLJiqkzcVV0/GbqS1+qo2aWlZH5xy9zrtAqsF4I6GjyfvMRXnkSzi6j/QDgkH00 qTRxaCGz7TLBy02Cm+mQODYHLF8NjydA2VgyrZC50IQ5oRwoSYhynwCZ1yLfGNMNClUa+aMlCv+ IlM X-Received: by 2002:a05:7300:b905:b0:343:6622:ee15 with SMTP id 5a478bee46e88-34f150a014bmr4182712eec.11.1790946690523; Fri, 02 Oct 2026 06:11:30 -0700 (PDT) Received: from [127.0.1.1] ([23.254.208.9]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-34f0672c739sm7309347eec.3.2026.10.02.06.11.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 06:11:29 -0700 (PDT) From: Qiliang Yuan Date: Fri, 02 Oct 2026 21:10:27 +0800 Subject: [PATCH v5 07/12] watchdog: Sync watchdog_cpumask with HK_TYPE_KERNEL_NOISE on isolation Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261002-wujing-dhm-v5-7-78a6996d87ad@gmail.com> References: <20261002-wujing-dhm-v5-0-78a6996d87ad@gmail.com> In-Reply-To: <20261002-wujing-dhm-v5-0-78a6996d87ad@gmail.com> To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Anna-Maria Behnsen , Tejun Heo , Jonathan Corbet , Shuah Khan , Shuah Khan , Thomas Gleixner Cc: Waiman Long , linux-kernel@vger.kernel.org, rcu@vger.kernel.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Qiliang Yuan X-Mailer: b4 0.13.0 The watchdog is initialized at boot to run on all housekeeping CPUs (HK_TYPE_KERNEL_NOISE). When a cpuset isolated partition removes CPUs from that mask at runtime, watchdog continues running on those CPUs because nothing updates watchdog_cpumask. Save the boot-time watchdog_cpumask as watchdog_cpumask_boot, which captures the user's intended coverage (possibly narrowed via kernel parameter or sysctl) before any runtime isolation. Introduce lockup_detector_hk_update() which intersects this boot snapshot with the current HK_TYPE_KERNEL_NOISE mask and reconfigures the detector. This ensures that isolated CPUs are excluded while honoring any manual narrowing the admin applied at or after boot. lockup_detector_hk_update() snapshots the RCU-protected housekeeping mask under rcu_read_lock(), then updates watchdog_cpumask and calls __lockup_detector_reconfigure() under watchdog_mutex, matching the same locking discipline used by proc_watchdog_cpumask(). Signed-off-by: Qiliang Yuan --- include/linux/nmi.h | 2 ++ kernel/watchdog.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/linux/nmi.h b/include/linux/nmi.h index af69712df5f48..409af7884d939 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -37,6 +37,7 @@ extern int sysctl_hardlockup_all_cpu_backtrace; static inline void lockup_detector_init(void) { } static inline void lockup_detector_retry_init(void) { } static inline void lockup_detector_soft_poweroff(void) { } +static inline void lockup_detector_hk_update(void) { } #endif /* !CONFIG_LOCKUP_DETECTOR */ #ifdef CONFIG_SOFTLOCKUP_DETECTOR @@ -120,6 +121,7 @@ void watchdog_hardlockup_enable(unsigned int cpu); void watchdog_hardlockup_disable(unsigned int cpu); void lockup_detector_reconfigure(void); +void lockup_detector_hk_update(void); #ifdef CONFIG_HARDLOCKUP_DETECTOR_BUDDY void watchdog_buddy_check_hardlockup(int hrtimer_interrupts); diff --git a/kernel/watchdog.c b/kernel/watchdog.c index e567fbb0d4692..d4eccb8e337f1 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -53,6 +53,8 @@ static int __read_mostly watchdog_hardlockup_available; struct cpumask watchdog_cpumask __read_mostly; unsigned long *watchdog_cpumask_bits = cpumask_bits(&watchdog_cpumask); +/* Boot snapshot: user's intended watchdog mask before any runtime isolation. */ +static struct cpumask watchdog_cpumask_boot __ro_after_init; #ifdef CONFIG_HARDLOCKUP_DETECTOR @@ -1348,6 +1350,27 @@ static void __init lockup_detector_delay_init(struct work_struct *work) lockup_detector_setup(); } +void lockup_detector_hk_update(void) +{ + cpumask_var_t new_mask; + + if (!alloc_cpumask_var(&new_mask, GFP_KERNEL)) + return; + + rcu_read_lock(); + cpumask_and(new_mask, &watchdog_cpumask_boot, + housekeeping_cpumask_rcu(HK_TYPE_KERNEL_NOISE)); + rcu_read_unlock(); + + mutex_lock(&watchdog_mutex); + cpumask_copy(&watchdog_cpumask, new_mask); + __lockup_detector_reconfigure(false); + mutex_unlock(&watchdog_mutex); + + free_cpumask_var(new_mask); +} +EXPORT_SYMBOL_GPL(lockup_detector_hk_update); + /* * lockup_detector_retry_init - retry init lockup detector if possible. * @@ -1390,6 +1413,7 @@ void __init lockup_detector_init(void) cpumask_copy(&watchdog_cpumask, housekeeping_cpumask(HK_TYPE_KERNEL_NOISE)); + cpumask_copy(&watchdog_cpumask_boot, &watchdog_cpumask); if (!watchdog_hardlockup_probe()) watchdog_hardlockup_available = true; -- 2.43.0