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 79BA0265CA2 for ; Tue, 21 Apr 2026 03:05:49 +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=1776740750; cv=none; b=BOLBYFKNRVveWxDaVwGl8qwoeocpch+tBQ6a1uzehG/DBYPOMCmZd8RnnX75j/1xCFKMPjAAVM2ovFss8jluK+VwhDdT7oUbvm7pB4bk95hLZCb9OL3Gwco8EzhL8d7q/AeAvfpWT3tFddikx5BRI2ynCE6pN9GlupoO8aefyO0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776740750; c=relaxed/simple; bh=rOGBf0wYekJdoD4SBA74vbDVOqUx1Wsq4aN0zXB95Dk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C1dNdB+5WCjNE4aa99hrC0kSOaQERjW+8zFLKqeZSLEgFjiskz8vAVLSRrH7gQAHIaFYRTLyMLEp1VL9axIJwoY01SUWu6wzpg/N5p/BSdr6URzsohJSe5Nqt5vhc/8aI46N7Avg9E6/D7rBXHbQIn+LXu0KHnOOg+eQCxP6VH8= 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=Ml9oJTm6; 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="Ml9oJTm6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776740748; 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=7VstpRTEn9ptpP1VmY9IUyGFYY+MvC6/GBVaS0P0YxY=; b=Ml9oJTm6iSanwimrg9raD1jFqjHevpZ08ky1VeXvA0ZEAJVhwPxLCLGFR/MJdFVCTotkWD NCGIxPbp388RBUJ7v5+tWQqjoBA9v3BsJlgkb6zB7x1pA9JzWaqWG1I3kbMHNjVl9cRSr1 7lSS8eX3aQj6Lms+bmj/FKVD21ZI+IU= 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-304-wfxxcSTJNc2iOwvbuYVEbw-1; Mon, 20 Apr 2026 23:05:44 -0400 X-MC-Unique: wfxxcSTJNc2iOwvbuYVEbw-1 X-Mimecast-MFC-AGG-ID: wfxxcSTJNc2iOwvbuYVEbw_1776740740 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 DEEC219560BC; Tue, 21 Apr 2026 03:05:38 +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 CECEB19560AB; Tue, 21 Apr 2026 03:05:31 +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 06/23] rcu/nocbs: Allow runtime changes in RCU NOCBS cpumask Date: Mon, 20 Apr 2026 23:03:34 -0400 Message-ID: <20260421030351.281436-7-longman@redhat.com> In-Reply-To: <20260421030351.281436-1-longman@redhat.com> References: <20260421030351.281436-1-longman@redhat.com> Precedence: bulk X-Mailing-List: rcu@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 We can make use of the rcu_nocb_cpu_offload()/rcu_nocb_cpu_deoffload() APIs to enable RCU NO-CB CPU offloading of newly isolated CPUs and deoffloading of de-isolated CPUs. Add a new rcu_nocb_update_cpus() helper to do that and call it directly from housekeeping_update() when the HK_TYPE_KERNEL_NOISE cpumask is being changed. This dynamic RCU NO-CB CPU offloading feature can only used if either "rcs_nocbs" or the "nohz_full" boot command parameters are used with or without parameter so that the proper RCU NO-CB resources are properly initialized at boot time. Signed-off-by: Waiman Long --- include/linux/rcupdate.h | 2 ++ kernel/rcu/tree_nocb.h | 22 ++++++++++++++++++++++ kernel/sched/isolation.c | 4 +++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 04f3f86a4145..987e3d1d413e 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -150,6 +150,7 @@ void rcu_init_nohz(void); int rcu_nocb_cpu_offload(int cpu); int rcu_nocb_cpu_deoffload(int cpu); void rcu_nocb_flush_deferred_wakeup(void); +void rcu_nocb_update_cpus(struct cpumask *cpumask); #define RCU_NOCB_LOCKDEP_WARN(c, s) RCU_LOCKDEP_WARN(c, s) @@ -159,6 +160,7 @@ static inline void rcu_init_nohz(void) { } static inline int rcu_nocb_cpu_offload(int cpu) { return -EINVAL; } static inline int rcu_nocb_cpu_deoffload(int cpu) { return 0; } static inline void rcu_nocb_flush_deferred_wakeup(void) { } +static inline void rcu_nocb_update_cpus(struct cpumask *cpumask) { } #define RCU_NOCB_LOCKDEP_WARN(c, s) diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index 2d06dcb61f37..b2daba1e5cb9 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -1173,6 +1173,28 @@ int rcu_nocb_cpu_offload(int cpu) } EXPORT_SYMBOL_GPL(rcu_nocb_cpu_offload); +void rcu_nocb_update_cpus(struct cpumask *cpumask) +{ + int cpu, ret; + + if (!rcu_state.nocb_is_setup) { + pr_warn_once("Dynamic RCU NOCB cannot be enabled without nohz_full/rcu_nocbs kernel boot parameter!\n"); + return; + } + + for_each_cpu_andnot(cpu, cpumask, rcu_nocb_mask) { + ret = rcu_nocb_cpu_offload(cpu); + if (WARN_ON_ONCE(ret)) + return; + } + + for_each_cpu_andnot(cpu, rcu_nocb_mask, cpumask) { + ret = rcu_nocb_cpu_deoffload(cpu); + if (WARN_ON_ONCE(ret)) + return; + } +} + #ifdef CONFIG_RCU_LAZY static unsigned long lazy_rcu_shrink_count(struct shrinker *shrink, struct shrink_control *sc) diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index 48b155e0b290..b5635484ec69 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -181,8 +181,10 @@ int housekeeping_update(struct cpumask *isol_mask, unsigned long flags) if ((housekeeping.flags & flags) != flags) WRITE_ONCE(housekeeping.flags, housekeeping.flags | flags); - if (flags & HK_FLAG_KERNEL_NOISE) + if (flags & HK_FLAG_KERNEL_NOISE) { tick_nohz_full_update_cpus(isol_mask); + rcu_nocb_update_cpus(isol_mask); + } synchronize_rcu(); -- 2.53.0