From nobody Mon May 11 02:06:54 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 B1597C4332F for ; Mon, 18 Apr 2022 22:56:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233969AbiDRW72 (ORCPT ); Mon, 18 Apr 2022 18:59:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233749AbiDRW7Z (ORCPT ); Mon, 18 Apr 2022 18:59:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 675392CE3C; Mon, 18 Apr 2022 15:56:45 -0700 (PDT) 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 E1375611CA; Mon, 18 Apr 2022 22:56:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E177C385A7; Mon, 18 Apr 2022 22:56:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650322604; bh=W+quTVxJ1vAv3v7CzdiXe19ytpEERvKdahUOk+MXpvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=As1R+lzJ0X7Uph9qPJB5XuxNH0+Ej+ucJ7AZO9bBoEK+mFRkqZKVk+4LpRW5n0sYv OroTAnTDDCPOCBLHGn0F+2OTFpzUYBPt7KQRY4QuqiS6eZid2Pg4lUVVJY0yyZXpii qALEBlOjViE0nij2uU8HeoxY2kkXVcxyg34PvpVbxz6GUJgwMD5ejLntYpX3kfZHww w/iW43mNdJ2f/nupn1sRZ2pu3SA0+Vcg7aBHir0DogDEOjFvnTw26zDh5O57PoCVDO 3NlKCqTHlGFFSm8pU2YE6nb0Cw3zejh556NnNQCVp9ajfXnPKcVvpfdRS8pJ7JBfbT cG7tEV4C+aIpg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 0A8B45C04BD; Mon, 18 Apr 2022 15:56:44 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, Frederic Weisbecker , Neeraj Upadhyay , Uladzislau Rezki , Joel Fernandes , Boqun Feng , "Paul E . McKenney" Subject: [PATCH rcu 1/5] rcu: Remove rcu_is_nocb_cpu() Date: Mon, 18 Apr 2022 15:56:38 -0700 Message-Id: <20220418225642.3945539-1-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220418225633.GA3945428@paulmck-ThinkPad-P17-Gen-1> References: <20220418225633.GA3945428@paulmck-ThinkPad-P17-Gen-1> 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" From: Frederic Weisbecker The rcu_is_nocb_cpu() function is no longer used, so this commmit removes it. Reported-by: Neeraj Upadhyay Cc: Uladzislau Rezki Cc: Joel Fernandes Cc: Boqun Feng Signed-off-by: Frederic Weisbecker Signed-off-by: Paul E. McKenney --- 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 24b5f2c2de87..4c53a2ccf711 100644 --- a/kernel/rcu/rcu.h +++ b/kernel/rcu/rcu.h @@ -538,10 +538,8 @@ extern struct workqueue_struct *rcu_par_gp_wq; #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.31.1.189.g2e36527f23 From nobody Mon May 11 02:06:54 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 90D36C433EF for ; Mon, 18 Apr 2022 22:57:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234016AbiDRW7w (ORCPT ); Mon, 18 Apr 2022 18:59:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233895AbiDRW71 (ORCPT ); Mon, 18 Apr 2022 18:59:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFA422D1E2; Mon, 18 Apr 2022 15:56:46 -0700 (PDT) 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 9893CB81136; Mon, 18 Apr 2022 22:56:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 592B4C385A9; Mon, 18 Apr 2022 22:56:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650322604; bh=FCA6zs4LWWKubnderCQQGmx4BdH6abaJqQaksaPioy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WTTwxDV9hl9qnwWDZ7BJ2gIf1/LYaZWgs9VAJDqHUpx00SoyPmv3wOb1WAcdcfZHV gm+ZClsV/EQgeVJj7Wfbd0NV7aNXMN+fCaJf9mlBGvUfPEMzvDUNZKDXNaOzyxN7wU DJB9kkcWcXv0khMVTxLiFGBtZKRc+LypPknW6M22TS4aEl5D2dm5nc3ArJ90soRwa5 Wt7BNMrfmSTRa7Yt6BN94Ozp1fFsyY5ddArwGgdSovoAO2xEVdcjyfmqxeOlod01it LPYf63sqEcXalVKXtD6CDoWXftD96dFJSmHokzhPmmTrY0TPZdQWuxjgqhy6ZVvPAr iVhIhGTT1+iZA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 0D0725C04C6; Mon, 18 Apr 2022 15:56:44 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, Frederic Weisbecker , "Paul E . McKenney" , Neeraj Upadhyay , Uladzislau Rezki , Joel Fernandes , Boqun Feng Subject: [PATCH rcu 2/5] rcu/nocb: Move rcu_nocb_is_setup to rcu_state Date: Mon, 18 Apr 2022 15:56:39 -0700 Message-Id: <20220418225642.3945539-2-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220418225633.GA3945428@paulmck-ThinkPad-P17-Gen-1> References: <20220418225633.GA3945428@paulmck-ThinkPad-P17-Gen-1> 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" From: Frederic Weisbecker This commit moves the RCU nocb initialization witness within rcu_state to consolidate RCU's global state. Reported-by: Paul E. McKenney Cc: Neeraj Upadhyay Cc: Uladzislau Rezki Cc: Joel Fernandes Cc: Boqun Feng Signed-off-by: Frederic Weisbecker Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.h | 1 + kernel/rcu/tree_nocb.h | 13 +++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h index 926673ebe355..f6a3d54585c9 100644 --- a/kernel/rcu/tree.h +++ b/kernel/rcu/tree.h @@ -364,6 +364,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..3c00240833d6 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); @@ -1172,10 +1169,10 @@ void __init rcu_init_nohz(void) 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.31.1.189.g2e36527f23 From nobody Mon May 11 02:06:54 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 6EF13C433F5 for ; Mon, 18 Apr 2022 22:56:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234034AbiDRW7g (ORCPT ); Mon, 18 Apr 2022 18:59:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233774AbiDRW70 (ORCPT ); Mon, 18 Apr 2022 18:59:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B734928E1D; Mon, 18 Apr 2022 15:56:45 -0700 (PDT) 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 0AC22611DA; Mon, 18 Apr 2022 22:56:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56062C385A1; Mon, 18 Apr 2022 22:56:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650322604; bh=ZEBq7zR50zNnytDr1DAj4+RNb5TDVS+djhiUTtjXeg0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f3gmKPNN8cmRwuaGTSsPlS3Ky9iLBO8STYdFi4U5B7+XxGckJyXz8MWOWwza7TGRf fzawoVdYo+JyaHk16mjY8ZmAWlR6zHCOLtRxb50egPZN0I+HESzoFARPOw4yH9Aguw dmW70HkG8+0zkBbcn8W+3746CaVAsJCuzC1meYOztc+9wKfeqHy0JnICcTwxj0SXPL q/4nhJaHKS7gs/bB7/zjbhtUDhxdlt0ay0+hotVMocYpYqPH7zAuaCDnbrmQleuYhy 4yjfhLpaHmFGXAwzQ8bHOcA7Mn3l4COYpMZg+rI6baXErcDGgMa+MAVdQZL2+Vziu4 gLlMVzAGl9QfA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 0F1855C0848; Mon, 18 Apr 2022 15:56:44 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, Frederic Weisbecker , Neeraj Upadhyay , Uladzislau Rezki , Joel Fernandes , Boqun Feng , "Paul E . McKenney" Subject: [PATCH rcu 3/5] rcu: Assume rcu_init() is called before smp Date: Mon, 18 Apr 2022 15:56:40 -0700 Message-Id: <20220418225642.3945539-3-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220418225633.GA3945428@paulmck-ThinkPad-P17-Gen-1> References: <20220418225633.GA3945428@paulmck-ThinkPad-P17-Gen-1> 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" From: Frederic Weisbecker The rcu_init() function 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 accordingly. Signed-off-by: Frederic Weisbecker Cc: Neeraj Upadhyay Cc: Uladzislau Rezki Cc: Joel Fernandes Cc: Boqun Feng Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index a4b8189455d5..e6a9e5744e45 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -4782,7 +4782,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 @@ -4802,11 +4802,10 @@ 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); - } + WARN_ON(num_online_cpus() > 1); // Only one CPU this early in boot. + 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.31.1.189.g2e36527f23 From nobody Mon May 11 02:06:54 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 EEBD5C433EF for ; Mon, 18 Apr 2022 22:57:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234119AbiDRW7r (ORCPT ); Mon, 18 Apr 2022 18:59:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233925AbiDRW71 (ORCPT ); Mon, 18 Apr 2022 18:59:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D1A02D1E3; Mon, 18 Apr 2022 15:56:47 -0700 (PDT) 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 AE43AB81141; Mon, 18 Apr 2022 22:56:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C8DEC385AB; Mon, 18 Apr 2022 22:56:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650322604; bh=uWd89iiBegiXH2yFXUEeLrHLbhhtzxwYgrGcGcPkkBM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hv9HajFku9vlwCBfNN9B78AoEU55p18W2PTxAzb28wvYJKYJo3ojz7eTUs3ANCUap PyOMul9trUbvABUDn1PHz81Yb/H+gWcxiqoFbTIccg2Ch7fEWgqssuZ7w1fKer5anB AOIg4DNHVU3i9YkiJT02q2Fyvy2FrTsnU7MOXjzqmghtUXcaGM8fobOYyZ8th/3obb AjnXOCvmIZOnymY/BFLMxYWRqhCNjQZCBTTy3V0yIZJpX5YjSTtARtirIRcOhw3MOu XXfCIvL1QqusEKH4hUke+ygqi/3yIRFrW7fue5udw2yNIzF6NYTUyFqnYCuzZ/8cdS Z4pUDxIR+XRDA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 113335C0A0D; Mon, 18 Apr 2022 15:56:44 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, Frederic Weisbecker , Neeraj Upadhyay , Uladzislau Rezki , Joel Fernandes , Boqun Feng , "Paul E . McKenney" Subject: [PATCH rcu 4/5] rcu: Initialize boost kthread only for boot node prior SMP initialization Date: Mon, 18 Apr 2022 15:56:41 -0700 Message-Id: <20220418225642.3945539-4-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220418225633.GA3945428@paulmck-ThinkPad-P17-Gen-1> References: <20220418225633.GA3945428@paulmck-ThinkPad-P17-Gen-1> 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" From: Frederic Weisbecker The rcu_spawn_gp_kthread() function is called as an early initcall, which means that SMP initialization hasn't happened yet and only the boot CPU is online. Therefore, create only the boost kthread for the leaf node of the boot CPU. Signed-off-by: Frederic Weisbecker Cc: Neeraj Upadhyay Cc: Uladzislau Rezki Cc: Joel Fernandes Cc: Boqun Feng Signed-off-by: Paul E. McKenney --- 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 e6a9e5744e45..70b33c55d39a 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -4480,6 +4480,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); @@ -4498,7 +4499,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 f6a3d54585c9..b2a0f2613ab9 100644 --- a/kernel/rcu/tree.h +++ b/kernel/rcu/tree.h @@ -422,7 +422,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 8360d86db1c0..b139635f33bd 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.31.1.189.g2e36527f23 From nobody Mon May 11 02:06:54 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 86524C433F5 for ; Mon, 18 Apr 2022 22:57:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234070AbiDRW7j (ORCPT ); Mon, 18 Apr 2022 18:59:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233856AbiDRW70 (ORCPT ); Mon, 18 Apr 2022 18:59:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B78E12CE2E; Mon, 18 Apr 2022 15:56:45 -0700 (PDT) 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 1A43D60FC5; Mon, 18 Apr 2022 22:56:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F2D3C385A8; Mon, 18 Apr 2022 22:56:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650322604; bh=aoxHRcD5CE1ksNMOtptxB5UStULjmR/2Os4/NqSTB9w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CzeP9fMoz/970D1bk1F5wcGZQvAuQEvERKqPa7U2pjTUKchZ2ZbHs1JP2izKTEH5q wvyQPZY9HaBEApBK9aUYNFN5wd8LgQLUzYo/I2gStVexBxfAYLVkHH9K2/XyPbgb7h Ju/szWCGQuTqtm8zmSPIsUxKzX/R2A01qZIfKZ1N0p+jqTPFdMBKq0hNSdar7EfpQI it+vjLBj/nxajlYVhpeobRMV5CcLzo83ipiQZpojrxMQcPG5xxQRsTWrqei7qJqkcY ez3AftZ8qFXlofV1cIlwRSDL6tfgmc/wRRNv8HnVeZHg1AyP81fhCjDqAS9JeExpZ/ Tb061OLev6Gng== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 132DD5C0A23; Mon, 18 Apr 2022 15:56:44 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, Frederic Weisbecker , Neeraj Upadhyay , Uladzislau Rezki , Joel Fernandes , Boqun Feng , "Paul E . McKenney" Subject: [PATCH rcu 5/5] rcu/nocb: Initialize nocb kthreads only for boot CPU prior SMP initialization Date: Mon, 18 Apr 2022 15:56:42 -0700 Message-Id: <20220418225642.3945539-5-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220418225633.GA3945428@paulmck-ThinkPad-P17-Gen-1> References: <20220418225633.GA3945428@paulmck-ThinkPad-P17-Gen-1> 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" From: Frederic Weisbecker The rcu_spawn_gp_kthread() function is called as an early initcall, which means that SMP initialization hasn't happened yet and only the boot CPU is online. Therefore, create only the NOCB kthreads related to the boot CPU. Signed-off-by: Frederic Weisbecker Cc: Neeraj Upadhyay Cc: Uladzislau Rezki Cc: Joel Fernandes Cc: Boqun Feng Signed-off-by: Paul E. McKenney --- 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 70b33c55d39a..9f7441a78f90 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -4498,9 +4498,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 b2a0f2613ab9..25dc4166f218 100644 --- a/kernel/rcu/tree.h +++ b/kernel/rcu/tree.h @@ -439,7 +439,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 3c00240833d6..46694e13398a 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.31.1.189.g2e36527f23