linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] rcu: Bunch of cleanups
@ 2022-02-16 15:42 Frederic Weisbecker
  2022-02-16 15:42 ` [PATCH 1/5] rcu: Remove rcu_is_nocb_cpu() Frederic Weisbecker
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Frederic Weisbecker @ 2022-02-16 15:42 UTC (permalink / raw)
  To: Paul E . McKenney
  Cc: LKML, Frederic Weisbecker, Neeraj Upadhyay, Boqun Feng,
	Uladzislau Rezki, Joel Fernandes

Hi,

Just a bit of housekeeping.

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git
	rcu/dev

HEAD: be4d4c3ba8c4ceeba9dc9df4de5451c7261161f3

Thanks,
	Frederic
---

Frederic Weisbecker (5):
      rcu: Remove rcu_is_nocb_cpu()
      rcu/nocb: Move rcu_nocb_is_setup to rcu_state
      rcu: Assume rcu_init() is called before smp
      rcu: Initialize boost kthread only for boot node prior SMP initialization
      rcu/nocb: Initialize nocb kthreads only for boot CPU prior SMP initialization


 kernel/rcu/rcu.h         |  2 --
 kernel/rcu/tree.c        | 25 +++++++++++++++++--------
 kernel/rcu/tree.h        |  3 +--
 kernel/rcu/tree_nocb.h   | 41 +++++------------------------------------
 kernel/rcu/tree_plugin.h | 16 ----------------
 5 files changed, 23 insertions(+), 64 deletions(-)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/5] rcu: Remove rcu_is_nocb_cpu()
  2022-02-16 15:42 [PATCH 0/5] rcu: Bunch of cleanups Frederic Weisbecker
@ 2022-02-16 15:42 ` Frederic Weisbecker
  2022-02-16 15:42 ` [PATCH 2/5] rcu/nocb: Move rcu_nocb_is_setup to rcu_state Frederic Weisbecker
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Frederic Weisbecker @ 2022-02-16 15:42 UTC (permalink / raw)
  To: Paul E . McKenney
  Cc: LKML, Frederic Weisbecker, Neeraj Upadhyay, Boqun Feng,
	Uladzislau Rezki, Joel Fernandes

It's an unused leftover that can now be removed.

Reported-by: Neeraj Upadhyay <quic_neeraju@quicinc.com>
Cc: Uladzislau Rezki <uladzislau.rezki@sony.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
---
 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 */
 
 #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
 
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]);
 }
 
-/* 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)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/5] rcu/nocb: Move rcu_nocb_is_setup to rcu_state
  2022-02-16 15:42 [PATCH 0/5] rcu: Bunch of cleanups Frederic Weisbecker
  2022-02-16 15:42 ` [PATCH 1/5] rcu: Remove rcu_is_nocb_cpu() Frederic Weisbecker
@ 2022-02-16 15:42 ` Frederic Weisbecker
  2022-02-16 21:30   ` Paul E. McKenney
  2022-02-16 15:42 ` [PATCH 3/5] rcu: Assume rcu_init() is called before smp Frederic Weisbecker
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Frederic Weisbecker @ 2022-02-16 15:42 UTC (permalink / raw)
  To: Paul E . McKenney
  Cc: LKML, Frederic Weisbecker, Neeraj Upadhyay, Boqun Feng,
	Uladzislau Rezki, Joel Fernandes

In order to avoid scattering the global RCU states, move the RCU nocb
initialization witness within rcu_state.

Reported-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Neeraj Upadhyay <quic_neeraju@quicinc.com>
Cc: Uladzislau Rezki <uladzislau.rezki@sony.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
---
 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 */
 };
 
 /* 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 = true;
+	rcu_state.nocb_is_setup = true;
 	return 1;
 }
 __setup("rcu_nocbs", rcu_nocb_setup);
@@ -1165,17 +1162,17 @@ void __init rcu_init_nohz(void)
 		need_rcu_nocb_mask = true;
 #endif /* #if defined(CONFIG_NO_HZ_FULL) */
 
-	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 = true;
+		rcu_state.nocb_is_setup = true;
 	}
 
-	if (!rcu_nocb_is_setup)
+	if (!rcu_state.nocb_is_setup)
 		return;
 
 #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;
 
-	if (!rcu_scheduler_fully_active || !rcu_nocb_is_setup)
+	if (!rcu_scheduler_fully_active || !rcu_state.nocb_is_setup)
 		return;
 
 	/* 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;
 
-	if (rcu_nocb_is_setup) {
+	if (rcu_state.nocb_is_setup) {
 		for_each_online_cpu(cpu)
 			rcu_spawn_cpu_nocb_kthread(cpu);
 	}
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/5] rcu: Assume rcu_init() is called before smp
  2022-02-16 15:42 [PATCH 0/5] rcu: Bunch of cleanups Frederic Weisbecker
  2022-02-16 15:42 ` [PATCH 1/5] rcu: Remove rcu_is_nocb_cpu() Frederic Weisbecker
  2022-02-16 15:42 ` [PATCH 2/5] rcu/nocb: Move rcu_nocb_is_setup to rcu_state Frederic Weisbecker
@ 2022-02-16 15:42 ` Frederic Weisbecker
  2022-02-16 15:42 ` [PATCH 4/5] rcu: Initialize boost kthread only for boot node prior SMP initialization Frederic Weisbecker
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Frederic Weisbecker @ 2022-02-16 15:42 UTC (permalink / raw)
  To: Paul E . McKenney
  Cc: LKML, Frederic Weisbecker, Neeraj Upadhyay, Boqun Feng,
	Uladzislau Rezki, Joel Fernandes

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 <frederic@kernel.org>
Cc: Neeraj Upadhyay <quic_neeraju@quicinc.com>
Cc: Uladzislau Rezki <uladzislau.rezki@sony.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
---
 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)
 
 void __init rcu_init(void)
 {
-	int cpu;
+	int cpu = smp_processor_id();
 
 	rcu_early_boot_tests();
 
@@ -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);
 
 	/* Create workqueue for Tree SRCU and for expedited GPs. */
 	rcu_gp_wq = alloc_workqueue("rcu_gp", WQ_MEM_RECLAIM, 0);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 4/5] rcu: Initialize boost kthread only for boot node prior SMP initialization
  2022-02-16 15:42 [PATCH 0/5] rcu: Bunch of cleanups Frederic Weisbecker
                   ` (2 preceding siblings ...)
  2022-02-16 15:42 ` [PATCH 3/5] rcu: Assume rcu_init() is called before smp Frederic Weisbecker
@ 2022-02-16 15:42 ` Frederic Weisbecker
  2022-02-16 15:42 ` [PATCH 5/5] rcu/nocb: Initialize nocb kthreads only for boot CPU " Frederic Weisbecker
  2022-02-16 20:13 ` [PATCH 0/5] rcu: Bunch of cleanups Paul E. McKenney
  5 siblings, 0 replies; 13+ messages in thread
From: Frederic Weisbecker @ 2022-02-16 15:42 UTC (permalink / raw)
  To: Paul E . McKenney
  Cc: LKML, Frederic Weisbecker, Neeraj Upadhyay, Boqun Feng,
	Uladzislau Rezki, Joel Fernandes

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 <frederic@kernel.org>
Cc: Neeraj Upadhyay <quic_neeraju@quicinc.com>
Cc: Uladzislau Rezki <uladzislau.rezki@sony.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
---
 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 = this_cpu_ptr(&rcu_data);
 
 	rcu_scheduler_fully_active = 1;
 	t = 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);
 }
 
-/*
- * 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 */
 
 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)
 {
 }
 
-static void __init rcu_spawn_boost_kthreads(void)
-{
-}
-
 #endif /* #else #ifdef CONFIG_RCU_BOOST */
 
 /*
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 5/5] rcu/nocb: Initialize nocb kthreads only for boot CPU prior SMP initialization
  2022-02-16 15:42 [PATCH 0/5] rcu: Bunch of cleanups Frederic Weisbecker
                   ` (3 preceding siblings ...)
  2022-02-16 15:42 ` [PATCH 4/5] rcu: Initialize boost kthread only for boot node prior SMP initialization Frederic Weisbecker
@ 2022-02-16 15:42 ` Frederic Weisbecker
  2022-02-16 20:13 ` [PATCH 0/5] rcu: Bunch of cleanups Paul E. McKenney
  5 siblings, 0 replies; 13+ messages in thread
From: Frederic Weisbecker @ 2022-02-16 15:42 UTC (permalink / raw)
  To: Paul E . McKenney
  Cc: LKML, Frederic Weisbecker, Neeraj Upadhyay, Boqun Feng,
	Uladzislau Rezki, Joel Fernandes

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 <frederic@kernel.org>
Cc: Neeraj Upadhyay <quic_neeraju@quicinc.com>
Cc: Uladzislau Rezki <uladzislau.rezki@sony.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
---
 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_cpu()
+	 * 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_data *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);
 }
 
-/*
- * 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 = -1;
 module_param(rcu_nocb_gp_stride, int, 0444);
@@ -1538,10 +1522,6 @@ 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)
 {
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/5] rcu: Bunch of cleanups
  2022-02-16 15:42 [PATCH 0/5] rcu: Bunch of cleanups Frederic Weisbecker
                   ` (4 preceding siblings ...)
  2022-02-16 15:42 ` [PATCH 5/5] rcu/nocb: Initialize nocb kthreads only for boot CPU " Frederic Weisbecker
@ 2022-02-16 20:13 ` Paul E. McKenney
  5 siblings, 0 replies; 13+ messages in thread
From: Paul E. McKenney @ 2022-02-16 20:13 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: LKML, Neeraj Upadhyay, Boqun Feng, Uladzislau Rezki, Joel Fernandes

On Wed, Feb 16, 2022 at 04:42:03PM +0100, Frederic Weisbecker wrote:
> Hi,
> 
> Just a bit of housekeeping.
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git
> 	rcu/dev
> 
> HEAD: be4d4c3ba8c4ceeba9dc9df4de5451c7261161f3

Queued and pushed, thank you!  I reworked 3/5 to make it clear that the
preceding (existing) block comment still applieds to that whole section
of code and did the usual wordsmithing.

Nice to get rid of those unused functions and to avoid the unnecessary
for_each_online_cpu() loops!

							Thanx, Paul

> Thanks,
> 	Frederic
> ---
> 
> Frederic Weisbecker (5):
>       rcu: Remove rcu_is_nocb_cpu()
>       rcu/nocb: Move rcu_nocb_is_setup to rcu_state
>       rcu: Assume rcu_init() is called before smp
>       rcu: Initialize boost kthread only for boot node prior SMP initialization
>       rcu/nocb: Initialize nocb kthreads only for boot CPU prior SMP initialization
> 
> 
>  kernel/rcu/rcu.h         |  2 --
>  kernel/rcu/tree.c        | 25 +++++++++++++++++--------
>  kernel/rcu/tree.h        |  3 +--
>  kernel/rcu/tree_nocb.h   | 41 +++++------------------------------------
>  kernel/rcu/tree_plugin.h | 16 ----------------
>  5 files changed, 23 insertions(+), 64 deletions(-)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/5] rcu/nocb: Move rcu_nocb_is_setup to rcu_state
  2022-02-16 15:42 ` [PATCH 2/5] rcu/nocb: Move rcu_nocb_is_setup to rcu_state Frederic Weisbecker
@ 2022-02-16 21:30   ` Paul E. McKenney
  2022-02-17  1:53     ` Paul E. McKenney
  0 siblings, 1 reply; 13+ messages in thread
From: Paul E. McKenney @ 2022-02-16 21:30 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: LKML, Neeraj Upadhyay, Boqun Feng, Uladzislau Rezki, Joel Fernandes

On Wed, Feb 16, 2022 at 04:42:05PM +0100, Frederic Weisbecker wrote:
> In order to avoid scattering the global RCU states, move the RCU nocb
> initialization witness within rcu_state.
> 
> Reported-by: Paul E. McKenney <paulmck@kernel.org>
> Cc: Neeraj Upadhyay <quic_neeraju@quicinc.com>
> Cc: Uladzislau Rezki <uladzislau.rezki@sony.com>
> Cc: Joel Fernandes <joel@joelfernandes.org>
> Cc: Boqun Feng <boqun.feng@gmail.com>
> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>

Build testing for CONFIG_NO_HZ_FULL=n kernels suggested the following
patch be merged into this one.  Or does this variable need to be used
somewhere?  Either way, please let me know!

							Thanx, Paul

------------------------------------------------------------------------

commit 1a4f308b3b3841ef10043fe6c3dd12fc872b0400
Author: Paul E. McKenney <paulmck@kernel.org>
Date:   Wed Feb 16 13:27:42 2022 -0800

    squash! rcu/nocb: Move rcu_nocb_is_setup to rcu_state
    
    [ paulmck: Remove unused need_rcu_nocb_mask local variable. ]
    
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>

diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h
index 9d6d4786bc703..9d97aa1f4d6ce 100644
--- a/kernel/rcu/tree_nocb.h
+++ b/kernel/rcu/tree_nocb.h
@@ -1154,14 +1154,8 @@ EXPORT_SYMBOL_GPL(rcu_nocb_cpu_offload);
 void __init rcu_init_nohz(void)
 {
 	int cpu;
-	bool need_rcu_nocb_mask = false;
 	struct rcu_data *rdp;
 
-#if defined(CONFIG_NO_HZ_FULL)
-	if (tick_nohz_full_running && !cpumask_empty(tick_nohz_full_mask))
-		need_rcu_nocb_mask = true;
-#endif /* #if defined(CONFIG_NO_HZ_FULL) */
-
 	if (rcu_state.nocb_is_setup) {
 		if (!cpumask_available(rcu_nocb_mask)) {
 			if (!zalloc_cpumask_var(&rcu_nocb_mask, GFP_KERNEL)) {

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/5] rcu/nocb: Move rcu_nocb_is_setup to rcu_state
  2022-02-16 21:30   ` Paul E. McKenney
@ 2022-02-17  1:53     ` Paul E. McKenney
  2022-02-17  5:28       ` Paul E. McKenney
  0 siblings, 1 reply; 13+ messages in thread
From: Paul E. McKenney @ 2022-02-17  1:53 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: LKML, Neeraj Upadhyay, Boqun Feng, Uladzislau Rezki, Joel Fernandes

On Wed, Feb 16, 2022 at 01:30:35PM -0800, Paul E. McKenney wrote:
> On Wed, Feb 16, 2022 at 04:42:05PM +0100, Frederic Weisbecker wrote:
> > In order to avoid scattering the global RCU states, move the RCU nocb
> > initialization witness within rcu_state.
> > 
> > Reported-by: Paul E. McKenney <paulmck@kernel.org>
> > Cc: Neeraj Upadhyay <quic_neeraju@quicinc.com>
> > Cc: Uladzislau Rezki <uladzislau.rezki@sony.com>
> > Cc: Joel Fernandes <joel@joelfernandes.org>
> > Cc: Boqun Feng <boqun.feng@gmail.com>
> > Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> 
> Build testing for CONFIG_NO_HZ_FULL=n kernels suggested the following
> patch be merged into this one.  Or does this variable need to be used
> somewhere?  Either way, please let me know!

TASKS03, TREE04, and TREE07 don't like this much, according to git
bisect.  They are the ones with nohz_full CPUs, in case that is crucial.
Trying again after reverting this commit locally.

If that works, I would be tempted to try the modification shown below.

Thoughts?

							Thanx, Paul

> ------------------------------------------------------------------------
> 
> commit 1a4f308b3b3841ef10043fe6c3dd12fc872b0400
> Author: Paul E. McKenney <paulmck@kernel.org>
> Date:   Wed Feb 16 13:27:42 2022 -0800
> 
>     squash! rcu/nocb: Move rcu_nocb_is_setup to rcu_state
>     
>     [ paulmck: Remove unused need_rcu_nocb_mask local variable. ]
>     
>     Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> 
> diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h
> index 9d6d4786bc703..9d97aa1f4d6ce 100644
> --- a/kernel/rcu/tree_nocb.h
> +++ b/kernel/rcu/tree_nocb.h
> @@ -1154,14 +1154,8 @@ EXPORT_SYMBOL_GPL(rcu_nocb_cpu_offload);
>  void __init rcu_init_nohz(void)
>  {
>  	int cpu;
> -	bool need_rcu_nocb_mask = false;
>  	struct rcu_data *rdp;
>  
> -#if defined(CONFIG_NO_HZ_FULL)
> -	if (tick_nohz_full_running && !cpumask_empty(tick_nohz_full_mask))
> -		need_rcu_nocb_mask = true;

		rcu_state.nocb_is_setup = true;

> -#endif /* #if defined(CONFIG_NO_HZ_FULL) */
> -
>  	if (rcu_state.nocb_is_setup) {
>  		if (!cpumask_available(rcu_nocb_mask)) {
>  			if (!zalloc_cpumask_var(&rcu_nocb_mask, GFP_KERNEL)) {

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/5] rcu/nocb: Move rcu_nocb_is_setup to rcu_state
  2022-02-17  1:53     ` Paul E. McKenney
@ 2022-02-17  5:28       ` Paul E. McKenney
  2022-02-17 11:30         ` Frederic Weisbecker
  0 siblings, 1 reply; 13+ messages in thread
From: Paul E. McKenney @ 2022-02-17  5:28 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: LKML, Neeraj Upadhyay, Boqun Feng, Uladzislau Rezki, Joel Fernandes

On Wed, Feb 16, 2022 at 05:53:32PM -0800, Paul E. McKenney wrote:
> On Wed, Feb 16, 2022 at 01:30:35PM -0800, Paul E. McKenney wrote:
> > On Wed, Feb 16, 2022 at 04:42:05PM +0100, Frederic Weisbecker wrote:
> > > In order to avoid scattering the global RCU states, move the RCU nocb
> > > initialization witness within rcu_state.
> > > 
> > > Reported-by: Paul E. McKenney <paulmck@kernel.org>
> > > Cc: Neeraj Upadhyay <quic_neeraju@quicinc.com>
> > > Cc: Uladzislau Rezki <uladzislau.rezki@sony.com>
> > > Cc: Joel Fernandes <joel@joelfernandes.org>
> > > Cc: Boqun Feng <boqun.feng@gmail.com>
> > > Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> > 
> > Build testing for CONFIG_NO_HZ_FULL=n kernels suggested the following
> > patch be merged into this one.  Or does this variable need to be used
> > somewhere?  Either way, please let me know!
> 
> TASKS03, TREE04, and TREE07 don't like this much, according to git
> bisect.  They are the ones with nohz_full CPUs, in case that is crucial.
> Trying again after reverting this commit locally.
> 
> If that works, I would be tempted to try the modification shown below.

And that does pass significant rcutorture testing, but over to you.  ;-)

							Thanx, Paul

> > ------------------------------------------------------------------------
> > 
> > commit 1a4f308b3b3841ef10043fe6c3dd12fc872b0400
> > Author: Paul E. McKenney <paulmck@kernel.org>
> > Date:   Wed Feb 16 13:27:42 2022 -0800
> > 
> >     squash! rcu/nocb: Move rcu_nocb_is_setup to rcu_state
> >     
> >     [ paulmck: Remove unused need_rcu_nocb_mask local variable. ]
> >     
> >     Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> > 
> > diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h
> > index 9d6d4786bc703..9d97aa1f4d6ce 100644
> > --- a/kernel/rcu/tree_nocb.h
> > +++ b/kernel/rcu/tree_nocb.h
> > @@ -1154,14 +1154,8 @@ EXPORT_SYMBOL_GPL(rcu_nocb_cpu_offload);
> >  void __init rcu_init_nohz(void)
> >  {
> >  	int cpu;
> > -	bool need_rcu_nocb_mask = false;
> >  	struct rcu_data *rdp;
> >  
> > -#if defined(CONFIG_NO_HZ_FULL)
> > -	if (tick_nohz_full_running && !cpumask_empty(tick_nohz_full_mask))
> > -		need_rcu_nocb_mask = true;
> 
> 		rcu_state.nocb_is_setup = true;
> 
> > -#endif /* #if defined(CONFIG_NO_HZ_FULL) */
> > -
> >  	if (rcu_state.nocb_is_setup) {
> >  		if (!cpumask_available(rcu_nocb_mask)) {
> >  			if (!zalloc_cpumask_var(&rcu_nocb_mask, GFP_KERNEL)) {

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/5] rcu/nocb: Move rcu_nocb_is_setup to rcu_state
  2022-02-17  5:28       ` Paul E. McKenney
@ 2022-02-17 11:30         ` Frederic Weisbecker
  2022-02-17 15:11           ` Paul E. McKenney
  0 siblings, 1 reply; 13+ messages in thread
From: Frederic Weisbecker @ 2022-02-17 11:30 UTC (permalink / raw)
  To: Paul E. McKenney
  Cc: LKML, Neeraj Upadhyay, Boqun Feng, Uladzislau Rezki, Joel Fernandes

On Wed, Feb 16, 2022 at 09:28:04PM -0800, Paul E. McKenney wrote:
> On Wed, Feb 16, 2022 at 05:53:32PM -0800, Paul E. McKenney wrote:
> > On Wed, Feb 16, 2022 at 01:30:35PM -0800, Paul E. McKenney wrote:
> > > On Wed, Feb 16, 2022 at 04:42:05PM +0100, Frederic Weisbecker wrote:
> > > > In order to avoid scattering the global RCU states, move the RCU nocb
> > > > initialization witness within rcu_state.
> > > > 
> > > > Reported-by: Paul E. McKenney <paulmck@kernel.org>
> > > > Cc: Neeraj Upadhyay <quic_neeraju@quicinc.com>
> > > > Cc: Uladzislau Rezki <uladzislau.rezki@sony.com>
> > > > Cc: Joel Fernandes <joel@joelfernandes.org>
> > > > Cc: Boqun Feng <boqun.feng@gmail.com>
> > > > Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> > > 
> > > Build testing for CONFIG_NO_HZ_FULL=n kernels suggested the following
> > > patch be merged into this one.  Or does this variable need to be used
> > > somewhere?  Either way, please let me know!
> > 
> > TASKS03, TREE04, and TREE07 don't like this much, according to git
> > bisect.  They are the ones with nohz_full CPUs, in case that is crucial.
> > Trying again after reverting this commit locally.
> > 
> > If that works, I would be tempted to try the modification shown below.
> 
> And that does pass significant rcutorture testing, but over to you.  ;-)

Ah no we still need that variable, but I screwed up and wrongly converted
need_rcu_nocb_mask to rcu_state.nocb_is_setup somewhere.

Here is the v2 of the culprit patch (sorry):

---
From: Frederic Weisbecker <frederic@kernel.org>
Date: Mon, 14 Feb 2022 14:23:39 +0100
Subject: [PATCH] rcu/nocb: Move rcu_nocb_is_setup to rcu_state

In order to avoid scattering the global RCU states, move the RCU nocb
initialization witness within rcu_state.

Reported-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Neeraj Upadhyay <quic_neeraju@quicinc.com>
Cc: Uladzislau Rezki <uladzislau.rezki@sony.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
---
 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 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 */
 };
 
 /* 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 = true;
+	rcu_state.nocb_is_setup = true;
 	return 1;
 }
 __setup("rcu_nocbs", rcu_nocb_setup);
@@ -1172,10 +1169,10 @@ void __init rcu_init_nohz(void)
 				return;
 			}
 		}
-		rcu_nocb_is_setup = true;
+		rcu_state.nocb_is_setup = true;
 	}
 
-	if (!rcu_nocb_is_setup)
+	if (!rcu_state.nocb_is_setup)
 		return;
 
 #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;
 
-	if (!rcu_scheduler_fully_active || !rcu_nocb_is_setup)
+	if (!rcu_scheduler_fully_active || !rcu_state.nocb_is_setup)
 		return;
 
 	/* 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;
 
-	if (rcu_nocb_is_setup) {
+	if (rcu_state.nocb_is_setup) {
 		for_each_online_cpu(cpu)
 			rcu_spawn_cpu_nocb_kthread(cpu);
 	}
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/5] rcu/nocb: Move rcu_nocb_is_setup to rcu_state
  2022-02-17 11:30         ` Frederic Weisbecker
@ 2022-02-17 15:11           ` Paul E. McKenney
  2022-02-17 17:50             ` Paul E. McKenney
  0 siblings, 1 reply; 13+ messages in thread
From: Paul E. McKenney @ 2022-02-17 15:11 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: LKML, Neeraj Upadhyay, Boqun Feng, Uladzislau Rezki, Joel Fernandes

On Thu, Feb 17, 2022 at 12:30:12PM +0100, Frederic Weisbecker wrote:
> On Wed, Feb 16, 2022 at 09:28:04PM -0800, Paul E. McKenney wrote:
> > On Wed, Feb 16, 2022 at 05:53:32PM -0800, Paul E. McKenney wrote:
> > > On Wed, Feb 16, 2022 at 01:30:35PM -0800, Paul E. McKenney wrote:
> > > > On Wed, Feb 16, 2022 at 04:42:05PM +0100, Frederic Weisbecker wrote:
> > > > > In order to avoid scattering the global RCU states, move the RCU nocb
> > > > > initialization witness within rcu_state.
> > > > > 
> > > > > Reported-by: Paul E. McKenney <paulmck@kernel.org>
> > > > > Cc: Neeraj Upadhyay <quic_neeraju@quicinc.com>
> > > > > Cc: Uladzislau Rezki <uladzislau.rezki@sony.com>
> > > > > Cc: Joel Fernandes <joel@joelfernandes.org>
> > > > > Cc: Boqun Feng <boqun.feng@gmail.com>
> > > > > Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> > > > 
> > > > Build testing for CONFIG_NO_HZ_FULL=n kernels suggested the following
> > > > patch be merged into this one.  Or does this variable need to be used
> > > > somewhere?  Either way, please let me know!
> > > 
> > > TASKS03, TREE04, and TREE07 don't like this much, according to git
> > > bisect.  They are the ones with nohz_full CPUs, in case that is crucial.
> > > Trying again after reverting this commit locally.
> > > 
> > > If that works, I would be tempted to try the modification shown below.
> > 
> > And that does pass significant rcutorture testing, but over to you.  ;-)
> 
> Ah no we still need that variable, but I screwed up and wrongly converted
> need_rcu_nocb_mask to rcu_state.nocb_is_setup somewhere.
> 
> Here is the v2 of the culprit patch (sorry):

Been there, done that!  ;-)

I pulled this one in and I will let you know how it goes.

							Thanx, Paul

> ---
> From: Frederic Weisbecker <frederic@kernel.org>
> Date: Mon, 14 Feb 2022 14:23:39 +0100
> Subject: [PATCH] rcu/nocb: Move rcu_nocb_is_setup to rcu_state
> 
> In order to avoid scattering the global RCU states, move the RCU nocb
> initialization witness within rcu_state.
> 
> Reported-by: Paul E. McKenney <paulmck@kernel.org>
> Cc: Neeraj Upadhyay <quic_neeraju@quicinc.com>
> Cc: Uladzislau Rezki <uladzislau.rezki@sony.com>
> Cc: Joel Fernandes <joel@joelfernandes.org>
> Cc: Boqun Feng <boqun.feng@gmail.com>
> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> ---
>  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 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 */
>  };
>  
>  /* 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 = true;
> +	rcu_state.nocb_is_setup = true;
>  	return 1;
>  }
>  __setup("rcu_nocbs", rcu_nocb_setup);
> @@ -1172,10 +1169,10 @@ void __init rcu_init_nohz(void)
>  				return;
>  			}
>  		}
> -		rcu_nocb_is_setup = true;
> +		rcu_state.nocb_is_setup = true;
>  	}
>  
> -	if (!rcu_nocb_is_setup)
> +	if (!rcu_state.nocb_is_setup)
>  		return;
>  
>  #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;
>  
> -	if (!rcu_scheduler_fully_active || !rcu_nocb_is_setup)
> +	if (!rcu_scheduler_fully_active || !rcu_state.nocb_is_setup)
>  		return;
>  
>  	/* 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;
>  
> -	if (rcu_nocb_is_setup) {
> +	if (rcu_state.nocb_is_setup) {
>  		for_each_online_cpu(cpu)
>  			rcu_spawn_cpu_nocb_kthread(cpu);
>  	}
> -- 
> 2.25.1

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/5] rcu/nocb: Move rcu_nocb_is_setup to rcu_state
  2022-02-17 15:11           ` Paul E. McKenney
@ 2022-02-17 17:50             ` Paul E. McKenney
  0 siblings, 0 replies; 13+ messages in thread
From: Paul E. McKenney @ 2022-02-17 17:50 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: LKML, Neeraj Upadhyay, Boqun Feng, Uladzislau Rezki, Joel Fernandes

On Thu, Feb 17, 2022 at 07:11:43AM -0800, Paul E. McKenney wrote:
> On Thu, Feb 17, 2022 at 12:30:12PM +0100, Frederic Weisbecker wrote:
> > On Wed, Feb 16, 2022 at 09:28:04PM -0800, Paul E. McKenney wrote:
> > > On Wed, Feb 16, 2022 at 05:53:32PM -0800, Paul E. McKenney wrote:
> > > > On Wed, Feb 16, 2022 at 01:30:35PM -0800, Paul E. McKenney wrote:
> > > > > On Wed, Feb 16, 2022 at 04:42:05PM +0100, Frederic Weisbecker wrote:
> > > > > > In order to avoid scattering the global RCU states, move the RCU nocb
> > > > > > initialization witness within rcu_state.
> > > > > > 
> > > > > > Reported-by: Paul E. McKenney <paulmck@kernel.org>
> > > > > > Cc: Neeraj Upadhyay <quic_neeraju@quicinc.com>
> > > > > > Cc: Uladzislau Rezki <uladzislau.rezki@sony.com>
> > > > > > Cc: Joel Fernandes <joel@joelfernandes.org>
> > > > > > Cc: Boqun Feng <boqun.feng@gmail.com>
> > > > > > Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> > > > > 
> > > > > Build testing for CONFIG_NO_HZ_FULL=n kernels suggested the following
> > > > > patch be merged into this one.  Or does this variable need to be used
> > > > > somewhere?  Either way, please let me know!
> > > > 
> > > > TASKS03, TREE04, and TREE07 don't like this much, according to git
> > > > bisect.  They are the ones with nohz_full CPUs, in case that is crucial.
> > > > Trying again after reverting this commit locally.
> > > > 
> > > > If that works, I would be tempted to try the modification shown below.
> > > 
> > > And that does pass significant rcutorture testing, but over to you.  ;-)
> > 
> > Ah no we still need that variable, but I screwed up and wrongly converted
> > need_rcu_nocb_mask to rcu_state.nocb_is_setup somewhere.
> > 
> > Here is the v2 of the culprit patch (sorry):
> 
> Been there, done that!  ;-)
> 
> I pulled this one in and I will let you know how it goes.

And it passed moderate rcutorture testing with flying colors!  ;-)

So let's see what -next makes of it...

							Thanx, Paul

> > ---
> > From: Frederic Weisbecker <frederic@kernel.org>
> > Date: Mon, 14 Feb 2022 14:23:39 +0100
> > Subject: [PATCH] rcu/nocb: Move rcu_nocb_is_setup to rcu_state
> > 
> > In order to avoid scattering the global RCU states, move the RCU nocb
> > initialization witness within rcu_state.
> > 
> > Reported-by: Paul E. McKenney <paulmck@kernel.org>
> > Cc: Neeraj Upadhyay <quic_neeraju@quicinc.com>
> > Cc: Uladzislau Rezki <uladzislau.rezki@sony.com>
> > Cc: Joel Fernandes <joel@joelfernandes.org>
> > Cc: Boqun Feng <boqun.feng@gmail.com>
> > Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> > ---
> >  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 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 */
> >  };
> >  
> >  /* 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 = true;
> > +	rcu_state.nocb_is_setup = true;
> >  	return 1;
> >  }
> >  __setup("rcu_nocbs", rcu_nocb_setup);
> > @@ -1172,10 +1169,10 @@ void __init rcu_init_nohz(void)
> >  				return;
> >  			}
> >  		}
> > -		rcu_nocb_is_setup = true;
> > +		rcu_state.nocb_is_setup = true;
> >  	}
> >  
> > -	if (!rcu_nocb_is_setup)
> > +	if (!rcu_state.nocb_is_setup)
> >  		return;
> >  
> >  #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;
> >  
> > -	if (!rcu_scheduler_fully_active || !rcu_nocb_is_setup)
> > +	if (!rcu_scheduler_fully_active || !rcu_state.nocb_is_setup)
> >  		return;
> >  
> >  	/* 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;
> >  
> > -	if (rcu_nocb_is_setup) {
> > +	if (rcu_state.nocb_is_setup) {
> >  		for_each_online_cpu(cpu)
> >  			rcu_spawn_cpu_nocb_kthread(cpu);
> >  	}
> > -- 
> > 2.25.1

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-02-17 17:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16 15:42 [PATCH 0/5] rcu: Bunch of cleanups Frederic Weisbecker
2022-02-16 15:42 ` [PATCH 1/5] rcu: Remove rcu_is_nocb_cpu() Frederic Weisbecker
2022-02-16 15:42 ` [PATCH 2/5] rcu/nocb: Move rcu_nocb_is_setup to rcu_state Frederic Weisbecker
2022-02-16 21:30   ` Paul E. McKenney
2022-02-17  1:53     ` Paul E. McKenney
2022-02-17  5:28       ` Paul E. McKenney
2022-02-17 11:30         ` Frederic Weisbecker
2022-02-17 15:11           ` Paul E. McKenney
2022-02-17 17:50             ` Paul E. McKenney
2022-02-16 15:42 ` [PATCH 3/5] rcu: Assume rcu_init() is called before smp Frederic Weisbecker
2022-02-16 15:42 ` [PATCH 4/5] rcu: Initialize boost kthread only for boot node prior SMP initialization Frederic Weisbecker
2022-02-16 15:42 ` [PATCH 5/5] rcu/nocb: Initialize nocb kthreads only for boot CPU " Frederic Weisbecker
2022-02-16 20:13 ` [PATCH 0/5] rcu: Bunch of cleanups Paul E. McKenney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).