OSDN Git Service

rcu/nocb: Only (re-)initialize segcblist when needed on CPU up
authorFrederic Weisbecker <frederic@kernel.org>
Thu, 28 Jan 2021 17:12:10 +0000 (18:12 +0100)
committerPaul E. McKenney <paulmck@kernel.org>
Mon, 8 Mar 2021 22:20:22 +0000 (14:20 -0800)
commitec711bc12c777b1165585f59f7a6c35a89e04cc3
treed55400bcb5f544dba9946d9e07467ab14c4f3203
parent8a682b3974c36853b52fc8ede14dee966e96e19f
rcu/nocb: Only (re-)initialize segcblist when needed on CPU up

At the start of a CPU-hotplug operation, the incoming CPU's callback
list can be in a number of states:

1. Disabled and empty.  This is the case when the boot CPU has
not invoked call_rcu(), when a non-boot CPU first comes online,
and when a non-offloaded CPU comes back online.  In this case,
it is both necessary and permissible to initialize ->cblist.
Because either the CPU is currently running with interrupts
disabled (boot CPU) or is not yet running at all (other CPUs),
it is not necessary to acquire ->nocb_lock.

In this case, initialization is required.

2. Disabled and non-empty.  This cannot occur, because early boot
call_rcu() invocations enable the callback list before enqueuing
their callback.

3. Enabled, whether empty or not. In this case, the callback
list has already been initialized.  This case occurs when the
boot CPU has executed an early boot call_rcu() and also when
an offloaded CPU comes back online.  In both cases, there is
no need to initialize the callback list: In the boot-CPU case,
the CPU has not (yet) gone offline, and in the offloaded case,
the rcuo kthreads are taking care of business.

Because it is not necessary to initialize the callback list,
it is also not necessary to acquire ->nocb_lock.

Therefore, checking if the segcblist is enabled suffices.  This commit
therefore initializes the callback list at rcutree_prepare_cpu() time
only if that list is disabled.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: Neeraj Upadhyay <neeraju@codeaurora.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
kernel/rcu/tree.c