Simply checking if the segcblist is enabled is enough to know if we
need to initialize it or not. It's safe to check within hotplug
machine.

Signed-off-by: Frederic Weisbecker <[email protected]>
Cc: Josh Triplett <[email protected]>
Cc: Lai Jiangshan <[email protected]>
Cc: Joel Fernandes <[email protected]>
Cc: Neeraj Upadhyay <[email protected]>
Cc: Boqun Feng <[email protected]>
---
 kernel/rcu/tree.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 4c5a1ac54fa6..f74a9ba62c12 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -4066,14 +4066,13 @@ int rcutree_prepare_cpu(unsigned int cpu)
        rdp->dynticks_nesting = 1;      /* CPU not up, no tearing. */
        rcu_dynticks_eqs_online();
        raw_spin_unlock_rcu_node(rnp);          /* irqs remain disabled. */
+
        /*
-        * Lock in case the CB/GP kthreads are still around handling
-        * old callbacks.
+        * Only non-NOCB CPUs that didn't have early-boot callbacks need to be
+        * (re-)initialized.
         */
-       rcu_nocb_lock(rdp);
-       if (rcu_segcblist_empty(&rdp->cblist)) /* No early-boot CBs? */
+       if (!rcu_segcblist_is_enabled(&rdp->cblist))
                rcu_segcblist_init(&rdp->cblist);  /* Re-enable callbacks. */
-       rcu_nocb_unlock(rdp);
 
        /*
         * Add CPU to leaf rcu_node pending-online bitmask.  Any needed
-- 
2.25.1

Reply via email to