]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rcu/nocb: Initialize nocb kthreads only for boot CPU prior SMP initialization
authorFrederic Weisbecker <frederic@kernel.org>
Wed, 16 Feb 2022 15:42:08 +0000 (16:42 +0100)
committerPaul E. McKenney <paulmck@kernel.org>
Tue, 12 Apr 2022 00:05:58 +0000 (17:05 -0700)
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 <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>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
kernel/rcu/tree.c
kernel/rcu/tree.h
kernel/rcu/tree_nocb.h

index 70b33c55d39a12e345357629bd96c99194bbb729..9f7441a78f9045ff5635c0f23e98763f9cb12c0d 100644 (file)
@@ -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_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;
index b2a0f2613ab98bdf485f8b7e00bcf28824ac0c21..25dc4166f2185a8e2f4bbf21cdac94497baa4706 100644 (file)
@@ -439,7 +439,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);
index 3c00240833d62554df34022d445d0bc5d3b84f35..46694e13398a3ee44746723c44f49e40312906eb 100644 (file)
@@ -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)
 {
 }