From nobody Sun Jun 28 01:48:35 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D604C433F5 for ; Wed, 16 Feb 2022 15:42:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235594AbiBPPmd (ORCPT ); Wed, 16 Feb 2022 10:42:33 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235580AbiBPPm3 (ORCPT ); Wed, 16 Feb 2022 10:42:29 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFAC26C1CA for ; Wed, 16 Feb 2022 07:42:16 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2A8B3619A6 for ; Wed, 16 Feb 2022 15:42:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0833FC340EF; Wed, 16 Feb 2022 15:42:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645026135; bh=6K9657j7gLRwoEvVjac7cH9GcoId6TrWRZBv5kqat48=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NO7roNpp9rWRvyrCpgkrjVUX1YRucdP9kuRIRaRLVi0c1+ph5QQ6P/9nNtSnvaYQf 2n4eP04EWyNX5SAINJXIzIi7FSzz0UsrhxJkpF7yIVeyrDs8+FTXnIreoKSZqCr/tY a0xCXyjVc9e2nLk1PqgeT1m3QRiB+tXGFiHXFQkdZp2cv4K6cf3AaIk2NNezxyYnl8 h1etmLR8uYv+MnFigV7fFg6ddzuntFxyI3z3VKl/fbkH4wm9rFNynWne4/YOYI8Q7c hwUAXmVjF8bTkAEUkf2sH+IuZJKvzcOK9vYknv/Uqec8IX/xQK6d39Ncoh6w4/mF5m P5nIeTitQXEzg== From: Frederic Weisbecker To: "Paul E . McKenney" Cc: LKML , Frederic Weisbecker , Neeraj Upadhyay , Boqun Feng , Uladzislau Rezki , Joel Fernandes Subject: [PATCH 1/5] rcu: Remove rcu_is_nocb_cpu() Date: Wed, 16 Feb 2022 16:42:04 +0100 Message-Id: <20220216154208.696069-2-frederic@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220216154208.696069-1-frederic@kernel.org> References: <20220216154208.696069-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" It's an unused leftover that can now be removed. Reported-by: Neeraj Upadhyay Cc: Uladzislau Rezki Cc: Joel Fernandes Cc: Boqun Feng Signed-off-by: Frederic Weisbecker --- kernel/rcu/rcu.h | 2 -- kernel/rcu/tree_nocb.h | 8 -------- 2 files changed, 10 deletions(-) diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h index 819f9d979e61..44efedd921d0 100644 --- a/kernel/rcu/rcu.h +++ b/kernel/rcu/rcu.h @@ -549,10 +549,8 @@ void rcu_gp_slow_unregister(atomic_t *rgssp); #endif /* #else #ifdef CONFIG_TINY_RCU */ =20 #ifdef CONFIG_RCU_NOCB_CPU -bool rcu_is_nocb_cpu(int cpu); void rcu_bind_current_to_nocb(void); #else -static inline bool rcu_is_nocb_cpu(int cpu) { return false; } static inline void rcu_bind_current_to_nocb(void) { } #endif =20 diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index 636d0546a4e9..02e1d05a11fc 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -215,14 +215,6 @@ static void rcu_init_one_nocb(struct rcu_node *rnp) init_swait_queue_head(&rnp->nocb_gp_wq[1]); } =20 -/* Is the specified CPU a no-CBs CPU? */ -bool rcu_is_nocb_cpu(int cpu) -{ - if (cpumask_available(rcu_nocb_mask)) - return cpumask_test_cpu(cpu, rcu_nocb_mask); - return false; -} - static bool __wake_nocb_gp(struct rcu_data *rdp_gp, struct rcu_data *rdp, bool force, unsigned long flags) --=20 2.25.1 From nobody Sun Jun 28 01:48:35 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A077C433EF for ; Wed, 16 Feb 2022 15:42:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235624AbiBPPmj (ORCPT ); Wed, 16 Feb 2022 10:42:39 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235585AbiBPPmb (ORCPT ); Wed, 16 Feb 2022 10:42:31 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7C559A9A6 for ; Wed, 16 Feb 2022 07:42:18 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2FC2661899 for ; Wed, 16 Feb 2022 15:42:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CEFCC340F1; Wed, 16 Feb 2022 15:42:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645026137; bh=8+SlU7r8WAJmX5jNCV3E4luagGnB16N6dk5c/+4swoI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kwQZ+eevSUosmgfHtAamiyR/6lH+C3ob1Qu9qWJ7biBuyPRRZPc4qzw5e0chgMIWS De3AV1NclV9Chzz7Gs91GF5H0B0jsopNVpYWLXOrzRLGPKG1Q6ZYSqLYxlh3nTH9WO 13KqxiqwHvmqDOnN4kewIMdkHnD3QyJSYKsn7giHfKR+SD0x4sLFpNniUbszXM4x9x xVsE9ShLmjOQ/Jf2kkI0AduomBe430g5P66nPUCRw7r/sZyJ3WRY42Og7ZvMNaB/7b tHEUQ5Cson1b7PKlp28DHueYrx3BdCBJd1pik8PORAo9M7xNt+MeA0BNCeXcxR95MM dTOWYPZvaw/qw== From: Frederic Weisbecker To: "Paul E . McKenney" Cc: LKML , Frederic Weisbecker , Neeraj Upadhyay , Boqun Feng , Uladzislau Rezki , Joel Fernandes Subject: [PATCH 2/5] rcu/nocb: Move rcu_nocb_is_setup to rcu_state Date: Wed, 16 Feb 2022 16:42:05 +0100 Message-Id: <20220216154208.696069-3-frederic@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220216154208.696069-1-frederic@kernel.org> References: <20220216154208.696069-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In order to avoid scattering the global RCU states, move the RCU nocb initialization witness within rcu_state. Reported-by: Paul E. McKenney Cc: Neeraj Upadhyay Cc: Uladzislau Rezki Cc: Joel Fernandes Cc: Boqun Feng Signed-off-by: Frederic Weisbecker --- kernel/rcu/tree.h | 1 + kernel/rcu/tree_nocb.h | 15 ++++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h index 19fc9acce3ce..735fc410d76a 100644 --- a/kernel/rcu/tree.h +++ b/kernel/rcu/tree.h @@ -368,6 +368,7 @@ struct rcu_state { arch_spinlock_t ofl_lock ____cacheline_internodealigned_in_smp; /* Synchronize offline with */ /* GP pre-initialization. */ + int nocb_is_setup; /* nocb is setup from boot */ }; =20 /* Values for rcu_state structure's gp_flags field. */ diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index 02e1d05a11fc..494e65445773 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -60,9 +60,6 @@ static inline bool rcu_current_is_nocb_kthread(struct rcu= _data *rdp) * Parse the boot-time rcu_nocb_mask CPU list from the kernel parameters. * If the list is invalid, a warning is emitted and all CPUs are offloaded. */ - -static bool rcu_nocb_is_setup; - static int __init rcu_nocb_setup(char *str) { alloc_bootmem_cpumask_var(&rcu_nocb_mask); @@ -72,7 +69,7 @@ static int __init rcu_nocb_setup(char *str) cpumask_setall(rcu_nocb_mask); } } - rcu_nocb_is_setup =3D true; + rcu_state.nocb_is_setup =3D true; return 1; } __setup("rcu_nocbs", rcu_nocb_setup); @@ -1165,17 +1162,17 @@ void __init rcu_init_nohz(void) need_rcu_nocb_mask =3D true; #endif /* #if defined(CONFIG_NO_HZ_FULL) */ =20 - if (need_rcu_nocb_mask) { + if (rcu_state.nocb_is_setup) { if (!cpumask_available(rcu_nocb_mask)) { if (!zalloc_cpumask_var(&rcu_nocb_mask, GFP_KERNEL)) { pr_info("rcu_nocb_mask allocation failed, callback offloading disabled= .\n"); return; } } - rcu_nocb_is_setup =3D true; + rcu_state.nocb_is_setup =3D true; } =20 - if (!rcu_nocb_is_setup) + if (!rcu_state.nocb_is_setup) return; =20 #if defined(CONFIG_NO_HZ_FULL) @@ -1233,7 +1230,7 @@ static void rcu_spawn_cpu_nocb_kthread(int cpu) struct task_struct *t; struct sched_param sp; =20 - if (!rcu_scheduler_fully_active || !rcu_nocb_is_setup) + if (!rcu_scheduler_fully_active || !rcu_state.nocb_is_setup) return; =20 /* If there already is an rcuo kthread, then nothing to do. */ @@ -1279,7 +1276,7 @@ static void __init rcu_spawn_nocb_kthreads(void) { int cpu; =20 - if (rcu_nocb_is_setup) { + if (rcu_state.nocb_is_setup) { for_each_online_cpu(cpu) rcu_spawn_cpu_nocb_kthread(cpu); } --=20 2.25.1 From nobody Sun Jun 28 01:48:35 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC727C433FE for ; Wed, 16 Feb 2022 15:42:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235634AbiBPPmn (ORCPT ); Wed, 16 Feb 2022 10:42:43 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235566AbiBPPmc (ORCPT ); Wed, 16 Feb 2022 10:42:32 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 988679A984 for ; Wed, 16 Feb 2022 07:42:20 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 35228619F6 for ; Wed, 16 Feb 2022 15:42:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12923C340EF; Wed, 16 Feb 2022 15:42:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645026139; bh=m+S1Tc4+/RJ6N1RKDacFpzfvDG/4zJND6bubnGil5PE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wws0deF3fieUDAQyT0xYnkKV1A9TJ5PP22+IWBpIqfqgeWRIs8+GKzdTWEWtjiw1g N67dQ0Exag3UqC2BDWgT6nxBkuww7huonp9UgYqRLDjdZDkg8FF5lBD0BIj/Idjq/A MKg8jb6MISundjQGWRi23UzQjYzxfnQqn5xK9c6eMfiL9EtOjmpA67fs5D8Zx8h5xs 3dGt6CPlyJbfBmwgme6uXUZ8jD0URvlhmeVY+Z6hIULl+UwpwkMBS+Qiguvypo4ogd qVgjLCifxkZprZ09QhbUWiszcIyCnYy+O6UzzoE0C57lIkxd3TetFit6iKZWLz51VA M2iyl9ejqc1oQ== From: Frederic Weisbecker To: "Paul E . McKenney" Cc: LKML , Frederic Weisbecker , Neeraj Upadhyay , Boqun Feng , Uladzislau Rezki , Joel Fernandes Subject: [PATCH 3/5] rcu: Assume rcu_init() is called before smp Date: Wed, 16 Feb 2022 16:42:06 +0100 Message-Id: <20220216154208.696069-4-frederic@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220216154208.696069-1-frederic@kernel.org> References: <20220216154208.696069-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" rcu_init() is called way before SMP is initialized and therefore only the boot CPU should be online at this stage. Simplify the boot per-cpu initialization according to this constraint. Signed-off-by: Frederic Weisbecker Cc: Neeraj Upadhyay Cc: Uladzislau Rezki Cc: Joel Fernandes Cc: Boqun Feng --- kernel/rcu/tree.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 86eec6a0f1a1..83dec1db86cf 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -4813,7 +4813,7 @@ static void __init kfree_rcu_batch_init(void) =20 void __init rcu_init(void) { - int cpu; + int cpu =3D smp_processor_id(); =20 rcu_early_boot_tests(); =20 @@ -4833,11 +4833,13 @@ void __init rcu_init(void) * or the scheduler are operational. */ pm_notifier(rcu_pm_notify, 0); - for_each_online_cpu(cpu) { - rcutree_prepare_cpu(cpu); - rcu_cpu_starting(cpu); - rcutree_online_cpu(cpu); - } + + /* This is early on boot, we expect a single CPU */ + WARN_ON(num_online_cpus() > 1); + + rcutree_prepare_cpu(cpu); + rcu_cpu_starting(cpu); + rcutree_online_cpu(cpu); =20 /* Create workqueue for Tree SRCU and for expedited GPs. */ rcu_gp_wq =3D alloc_workqueue("rcu_gp", WQ_MEM_RECLAIM, 0); --=20 2.25.1 From nobody Sun Jun 28 01:48:35 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F4F2C433F5 for ; Wed, 16 Feb 2022 15:42:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235646AbiBPPmr (ORCPT ); Wed, 16 Feb 2022 10:42:47 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235604AbiBPPmg (ORCPT ); Wed, 16 Feb 2022 10:42:36 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C04A9ADBB for ; Wed, 16 Feb 2022 07:42:24 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D7B6FB81F3B for ; Wed, 16 Feb 2022 15:42:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17A0AC340F0; Wed, 16 Feb 2022 15:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645026141; bh=n23OTEmoQAxAvjvctHPSBMXPOlhafd62smPY4TRLCzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XS2AHM/nQ/S/GQ6B7D/yNxfw+AXXmx6dzLeeLZ7zfihG5/qgxG+jk4KA94mJ42Bol tsgnZp2jBtX+UUjEM4v031u4TmktLPon0n+UYb4EmDVlyHYS+0SpIIGN9O+W2mYpzv W/06XN3DBmvzDIdmKq1zDy4E+TCbuknDyiPOyArE1BaA/DlmIlFc/LxIkicGXAmLLo lTvl555esxdum6B+9ER8fUj9qbCTQ1WThn0MxlS0Wmoj9EIcn8DrSBQl/1UDzrG4+3 FAJ82KylflDvvXkaFZ8NSwktDHkPiKjWMXExoqalAL8pr0G6AHkRO7V6RMHpmmRTVJ uJWar/++z+OfQ== From: Frederic Weisbecker To: "Paul E . McKenney" Cc: LKML , Frederic Weisbecker , Neeraj Upadhyay , Boqun Feng , Uladzislau Rezki , Joel Fernandes Subject: [PATCH 4/5] rcu: Initialize boost kthread only for boot node prior SMP initialization Date: Wed, 16 Feb 2022 16:42:07 +0100 Message-Id: <20220216154208.696069-5-frederic@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220216154208.696069-1-frederic@kernel.org> References: <20220216154208.696069-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" rcu_spawn_gp_kthread() is called as an early initcall, which means that SMP initialization hasn't happened yet and the boot CPU is the only one online. Therefore only the boost kthread for the leaf node of the boot CPU needs to be created at this stage. Signed-off-by: Frederic Weisbecker Cc: Neeraj Upadhyay Cc: Uladzislau Rezki Cc: Joel Fernandes Cc: Boqun Feng --- kernel/rcu/tree.c | 5 ++++- kernel/rcu/tree.h | 1 - kernel/rcu/tree_plugin.h | 16 ---------------- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 83dec1db86cf..4a98417c2e28 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -4508,6 +4508,7 @@ static int __init rcu_spawn_gp_kthread(void) struct rcu_node *rnp; struct sched_param sp; struct task_struct *t; + struct rcu_data *rdp =3D this_cpu_ptr(&rcu_data); =20 rcu_scheduler_fully_active =3D 1; t =3D kthread_create(rcu_gp_kthread, NULL, "%s", rcu_state.name); @@ -4526,7 +4527,9 @@ static int __init rcu_spawn_gp_kthread(void) raw_spin_unlock_irqrestore_rcu_node(rnp, flags); wake_up_process(t); rcu_spawn_nocb_kthreads(); - rcu_spawn_boost_kthreads(); + /* This is a pre-SMP initcall, we expect a single CPU */ + WARN_ON(num_online_cpus() > 1); + rcu_spawn_one_boost_kthread(rdp->mynode); rcu_spawn_core_kthreads(); return 0; } diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h index 735fc410d76a..48c772fc353f 100644 --- a/kernel/rcu/tree.h +++ b/kernel/rcu/tree.h @@ -426,7 +426,6 @@ static void rcu_preempt_boost_start_gp(struct rcu_node = *rnp); static bool rcu_is_callbacks_kthread(void); static void rcu_cpu_kthread_setup(unsigned int cpu); static void rcu_spawn_one_boost_kthread(struct rcu_node *rnp); -static void __init rcu_spawn_boost_kthreads(void); static bool rcu_preempt_has_tasks(struct rcu_node *rnp); static bool rcu_preempt_need_deferred_qs(struct task_struct *t); static void rcu_preempt_deferred_qs(struct task_struct *t); diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index 6082dd23408f..90925a589774 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -1226,18 +1226,6 @@ static void rcu_boost_kthread_setaffinity(struct rcu= _node *rnp, int outgoingcpu) free_cpumask_var(cm); } =20 -/* - * Spawn boost kthreads -- called as soon as the scheduler is running. - */ -static void __init rcu_spawn_boost_kthreads(void) -{ - struct rcu_node *rnp; - - rcu_for_each_leaf_node(rnp) - if (rcu_rnp_online_cpus(rnp)) - rcu_spawn_one_boost_kthread(rnp); -} - #else /* #ifdef CONFIG_RCU_BOOST */ =20 static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags) @@ -1263,10 +1251,6 @@ static void rcu_boost_kthread_setaffinity(struct rcu= _node *rnp, int outgoingcpu) { } =20 -static void __init rcu_spawn_boost_kthreads(void) -{ -} - #endif /* #else #ifdef CONFIG_RCU_BOOST */ =20 /* --=20 2.25.1 From nobody Sun Jun 28 01:48:35 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB813C433F5 for ; Wed, 16 Feb 2022 15:42:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235665AbiBPPms (ORCPT ); Wed, 16 Feb 2022 10:42:48 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235608AbiBPPmh (ORCPT ); Wed, 16 Feb 2022 10:42:37 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A20AAA146A for ; Wed, 16 Feb 2022 07:42:24 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3E953619A6 for ; Wed, 16 Feb 2022 15:42:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BBA0C004E1; Wed, 16 Feb 2022 15:42:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645026143; bh=yJU8hBc2czTJc3bbudjxiT4f52GXeYpKuKeizilsRso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MmARornArjckhS9MrmRfkVRvPK5ZXyBzs6of3apNy83fcQZVc+H5MH9kYrbltxjSC DRLvRYTOEQKQuxHV259ZfkCWufhG1QjV/y5IqHmdBw6LnONTRJhYvHeYwq5TV0qbWI FIn6YqAuSTm8ACObvyeKFj7w3U0uNNHs7zhYRHwPVCxvJbrUv9NBB/ZNjMmGHeLjV1 OAnX5S6F8PGegOtbG80rzbV1P1Nhf3urKd62O1AOSTZwvCn5SHoY9ViM4tT6yO4fq4 aRdpUpv4KMB/hXJt1ay9yR0rW1+APu3rRBeKal2ytpIJKsF47/juD9pH1xhi2JyBOI pVXIRwojTI2Dw== From: Frederic Weisbecker To: "Paul E . McKenney" Cc: LKML , Frederic Weisbecker , Neeraj Upadhyay , Boqun Feng , Uladzislau Rezki , Joel Fernandes Subject: [PATCH 5/5] rcu/nocb: Initialize nocb kthreads only for boot CPU prior SMP initialization Date: Wed, 16 Feb 2022 16:42:08 +0100 Message-Id: <20220216154208.696069-6-frederic@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220216154208.696069-1-frederic@kernel.org> References: <20220216154208.696069-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" rcu_spawn_gp_kthread() is called as an early initcall, which means that SMP initialization hasn't happened yet and the boot CPU is the only one online. Therefore only the NOCB kthreads related to the boot CPU need to be created at this stage. Signed-off-by: Frederic Weisbecker Cc: Neeraj Upadhyay Cc: Uladzislau Rezki Cc: Joel Fernandes Cc: Boqun Feng --- kernel/rcu/tree.c | 6 +++++- kernel/rcu/tree.h | 1 - kernel/rcu/tree_nocb.h | 20 -------------------- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 4a98417c2e28..3e9a8ec222e4 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -4526,9 +4526,13 @@ static int __init rcu_spawn_gp_kthread(void) smp_store_release(&rcu_state.gp_kthread, t); /* ^^^ */ raw_spin_unlock_irqrestore_rcu_node(rnp, flags); wake_up_process(t); - rcu_spawn_nocb_kthreads(); /* This is a pre-SMP initcall, we expect a single CPU */ WARN_ON(num_online_cpus() > 1); + /* + * Those kthreads couldn't be created on rcu_init() -> rcutree_prepare_cp= u() + * due to rcu_scheduler_fully_active. + */ + rcu_spawn_cpu_nocb_kthread(smp_processor_id()); rcu_spawn_one_boost_kthread(rdp->mynode); rcu_spawn_core_kthreads(); return 0; diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h index 48c772fc353f..e3296ecde277 100644 --- a/kernel/rcu/tree.h +++ b/kernel/rcu/tree.h @@ -443,7 +443,6 @@ static int rcu_nocb_need_deferred_wakeup(struct rcu_dat= a *rdp, int level); static bool do_nocb_deferred_wakeup(struct rcu_data *rdp); static void rcu_boot_init_nocb_percpu_data(struct rcu_data *rdp); static void rcu_spawn_cpu_nocb_kthread(int cpu); -static void __init rcu_spawn_nocb_kthreads(void); static void show_rcu_nocb_state(struct rcu_data *rdp); static void rcu_nocb_lock(struct rcu_data *rdp); static void rcu_nocb_unlock(struct rcu_data *rdp); diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index 494e65445773..9d6d4786bc70 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -1266,22 +1266,6 @@ static void rcu_spawn_cpu_nocb_kthread(int cpu) WRITE_ONCE(rdp->nocb_gp_kthread, rdp_gp->nocb_gp_kthread); } =20 -/* - * Once the scheduler is running, spawn rcuo kthreads for all online - * no-CBs CPUs. This assumes that the early_initcall()s happen before - * non-boot CPUs come online -- if this changes, we will need to add - * some mutual exclusion. - */ -static void __init rcu_spawn_nocb_kthreads(void) -{ - int cpu; - - if (rcu_state.nocb_is_setup) { - for_each_online_cpu(cpu) - rcu_spawn_cpu_nocb_kthread(cpu); - } -} - /* How many CB CPU IDs per GP kthread? Default of -1 for sqrt(nr_cpu_ids)= . */ static int rcu_nocb_gp_stride =3D -1; module_param(rcu_nocb_gp_stride, int, 0444); @@ -1538,10 +1522,6 @@ static void rcu_spawn_cpu_nocb_kthread(int cpu) { } =20 -static void __init rcu_spawn_nocb_kthreads(void) -{ -} - static void show_rcu_nocb_state(struct rcu_data *rdp) { } --=20 2.25.1