From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 095B0364045 for ; Tue, 21 Apr 2026 03:05:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776740757; cv=none; b=PBPcb6R6S79Dm0E1TQ8GUS3kQGjXgxA+5UvFqxVdurO3SQgjVAXgmojP31dj8krEkjImuAI7RbfFzZo9wXjLqfnHXI7xGiYV4AenfgYFSfaHfXjvB4oh8t8X5xjUQXbVHC2JF2kaCT9TMoKJIuKgGJnqWfe6Jd9g2phAlu++9bk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776740757; c=relaxed/simple; bh=6dOR9VvfHXSOAa+3ONfN9QOA7EaOHN44SvLAlIcSGZo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j0mWQtPEU6uuCV2lyy98xV5E93Tf0yegN0SHeqEZkxIjz1BygcAWv9sxHLNTMB3o6ZIVVAOqlil03a8qePbMJVss9bRKV7UNCCnm9/HDIexk6PCCrDIxAR2MW0bamE8r7wmIGPnkgfrTjIYYDw7p3r8Ddpo/skjGwfxPoRNi7XY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Bbruz1zH; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Bbruz1zH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776740755; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iRnLiTFd5Q/8p4sCGe2o1EMdVAtDIxePLghGCtdhHc0=; b=Bbruz1zHSwEDfdR//i9NJ4Ns7Bqfk6fcsbjWsCgqaQ9vJreaObAIzNqOb3XH5fQZVrzGu/ UKFent1Dg8hcTqM9Tmx7ZHt8RAQa/kS4Lg6aweoI3Dj7aqUMRzaaY1HhNkFiEoIrqkepB5 xoc/CaVhcGkLfKJYgrxfPd0Wx1yYXrE= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-30-2NDOP3YyMf-mNL6wwN032w-1; Mon, 20 Apr 2026 23:05:51 -0400 X-MC-Unique: 2NDOP3YyMf-mNL6wwN032w-1 X-Mimecast-MFC-AGG-ID: 2NDOP3YyMf-mNL6wwN032w_1776740746 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7ACED19560AD; Tue, 21 Apr 2026 03:05:46 +0000 (UTC) Received: from llong-thinkpadp16vgen1.westford.csb (unknown [10.22.65.81]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2157519560B7; Tue, 21 Apr 2026 03:05:39 +0000 (UTC) From: Waiman Long To: Tejun Heo , Johannes Weiner , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan , Catalin Marinas , Will Deacon , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Guenter Roeck , Frederic Weisbecker , "Paul E. McKenney" , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Anna-Maria Behnsen , Ingo Molnar , Thomas Gleixner , Chen Ridong , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-hwmon@vger.kernel.org, rcu@vger.kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, Costa Shulyupin , Qiliang Yuan , Waiman Long Subject: [PATCH 07/23] watchdog: Sync up with runtime change of isolated CPUs Date: Mon, 20 Apr 2026 23:03:35 -0400 Message-ID: <20260421030351.281436-8-longman@redhat.com> In-Reply-To: <20260421030351.281436-1-longman@redhat.com> References: <20260421030351.281436-1-longman@redhat.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 At bootup, watchdog will exclude nohz_full CPUs specified at boot time. As we are now enabling runtime changes to nohz_full CPUs, the list of CPUs with watchdog timer running should be updated to exclude the current set of isolated CPUs. Add a new watchdog_cpumask_update() helper to be invoked by housekeeping_update() when the HK_TYPE_KERNEL_NOISE (HK_TYPE_TIMER) cpumask is being updated to update watchdog_cpumask and watchdog_allowed_mask for soft lockup detector. The cpumask updates will be done when the affected CPUs are in the offline state. When those CPUs are brought up later, the new cpumask will be used to determine if any hard/soft watchdog should be enabled again. Signed-off-by: Waiman Long --- include/linux/nmi.h | 2 ++ kernel/sched/isolation.c | 1 + kernel/watchdog.c | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/include/linux/nmi.h b/include/linux/nmi.h index bc1162895f35..5bf941d2b168 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -17,6 +17,7 @@ void lockup_detector_init(void); void lockup_detector_retry_init(void); void lockup_detector_soft_poweroff(void); +void watchdog_cpumask_update(struct cpumask *mask); extern int watchdog_user_enabled; extern int watchdog_thresh; @@ -37,6 +38,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 watchdog_cpumask_update(struct cpumask *mask) { } #endif /* !CONFIG_LOCKUP_DETECTOR */ #ifdef CONFIG_SOFTLOCKUP_DETECTOR diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index b5635484ec69..1f3f1c83dd12 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -184,6 +184,7 @@ int housekeeping_update(struct cpumask *isol_mask, unsigned long flags) if (flags & HK_FLAG_KERNEL_NOISE) { tick_nohz_full_update_cpus(isol_mask); rcu_nocb_update_cpus(isol_mask); + watchdog_cpumask_update(isol_mask); } synchronize_rcu(); diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 87dd5e0f6968..498c1463b843 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -1071,6 +1071,30 @@ static inline void lockup_detector_setup(void) } #endif /* !CONFIG_SOFTLOCKUP_DETECTOR */ +/** + * watchdog_cpumask_update - update watchdog_cpumask & watchdog_allowed_mask + * @isol_mask: cpumask of isolated CPUs + * + * Update watchdog_cpumask and watchdog_allowed_mask to be inverse of the + * given isolated cpumask to disable watchdog activities on isolated CPUs. + * It should be called with the affected CPUs in offline state which will be + * brought up online later. + * + * Any changes made in watchdog_cpumask by users via the sysctl parameter will + * be overridden. However, proc_watchdog_update() isn't called. So change will + * only happens on CPUs that will brought up later on to minimize changes to + * the existing watchdog configuration. + */ +void watchdog_cpumask_update(struct cpumask *isol_mask) +{ + mutex_lock(&watchdog_mutex); + cpumask_andnot(&watchdog_cpumask, cpu_possible_mask, isol_mask); +#ifdef CONFIG_SOFTLOCKUP_DETECTOR + cpumask_copy(&watchdog_allowed_mask, &watchdog_cpumask); +#endif + mutex_unlock(&watchdog_mutex); +} + /** * lockup_detector_soft_poweroff - Interface to stop lockup detector(s) * -- 2.53.0