Skip to content

Commit 1b022b8

Browse files
Frederic WeisbeckerNeeraj Upadhyay
authored andcommitted
rcu/nocb: Conditionally wake up rcuo if not already waiting on GP
A callback enqueuer currently wakes up the rcuo kthread if it is adding the first non-done callback of a CPU, whether the kthread is waiting on a grace period or not (unless the CPU is offline). This looks like a desired behaviour because then the rcuo kthread doesn't wait for the end of the current grace period to handle the callback. It is accelerated right away and assigned to the next grace period. The GP kthread is notified about that fact and iterates with the upcoming GP without sleeping in-between. However this best-case scenario is contradicted by a few details, depending on the situation: 1) If the callback is a non-bypass one queued with IRQs enabled, the wake up only occurs if no other pending callbacks are on the list. Therefore the theoretical "optimization" actually applies on rare occasions. 2) If the callback is a non-bypass one queued with IRQs disabled, the situation is similar with even more uncertainty due to the deferred wake up. 3) If the callback is lazy, a few jiffies don't make any difference. 4) If the callback is bypass, the wake up timer is programmed 2 jiffies ahead by rcuo in case the regular pending queue has been handled in the meantime. The rare storm of callbacks can otherwise wait for the currently elapsing grace period to be flushed and handled. For all those reasons, the optimization is only theoretical and occasional. Therefore it is reasonable that callbacks enqueuers only wake up the rcuo kthread when it is not already waiting on a grace period to complete. Signed-off-by: Frederic Weisbecker <[email protected]> Signed-off-by: Neeraj Upadhyay <[email protected]>
1 parent 9139f93 commit 1b022b8

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

kernel/rcu/tree_nocb.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,7 @@ static bool __wake_nocb_gp(struct rcu_data *rdp_gp,
216216
raw_spin_unlock_irqrestore(&rdp_gp->nocb_gp_lock, flags);
217217
if (needwake) {
218218
trace_rcu_nocb_wake(rcu_state.name, rdp->cpu, TPS("DoWake"));
219-
if (cpu_is_offline(raw_smp_processor_id()))
220-
swake_up_one_online(&rdp_gp->nocb_gp_wq);
221-
else
222-
wake_up_process(rdp_gp->nocb_gp_kthread);
219+
swake_up_one_online(&rdp_gp->nocb_gp_wq);
223220
}
224221

225222
return needwake;

0 commit comments

Comments
 (0)