Skip to content

Commit 8d97039

Browse files
Frederic Weisbeckerpaulmckrcu
authored andcommitted
rcu/nocb: Prepare nocb_cb_wait() to start with a non-offloaded rdp
In order to be able to toggle the offloaded state from cpusets, a nocb kthread will need to be created for all possible CPUs whenever either of the "rcu_nocbs=" or "nohz_full=" parameters are specified. Therefore, the nocb_cb_wait() kthread must be prepared to start running on a de-offloaded rdp. To accomplish this, simply move the sleeping condition to the beginning of the nocb_cb_wait() function, which prevents this kthread from attempting to invoke callbacks before the corresponding CPU is offloaded. Reviewed-by: Neeraj Upadhyay <quic_neeraju@quicinc.com> Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Cc: Boqun Feng <boqun.feng@gmail.com> Cc: Uladzislau Rezki <urezki@gmail.com> Cc: Josh Triplett <josh@joshtriplett.org> Cc: Joel Fernandes <joel@joelfernandes.org> Tested-by: Juri Lelli <juri.lelli@redhat.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
1 parent 2ebc45c commit 8d97039

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

kernel/rcu/tree_nocb.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,18 @@ static void nocb_cb_wait(struct rcu_data *rdp)
803803
bool can_sleep = true;
804804
struct rcu_node *rnp = rdp->mynode;
805805

806+
do {
807+
swait_event_interruptible_exclusive(rdp->nocb_cb_wq,
808+
nocb_cb_wait_cond(rdp));
809+
810+
// VVV Ensure CB invocation follows _sleep test.
811+
if (smp_load_acquire(&rdp->nocb_cb_sleep)) { // ^^^
812+
WARN_ON(signal_pending(current));
813+
trace_rcu_nocb_wake(rcu_state.name, rdp->cpu, TPS("WokeEmpty"));
814+
}
815+
} while (!nocb_cb_can_run(rdp));
816+
817+
806818
local_irq_save(flags);
807819
rcu_momentary_dyntick_idle();
808820
local_irq_restore(flags);
@@ -855,17 +867,6 @@ static void nocb_cb_wait(struct rcu_data *rdp)
855867

856868
if (needwake_state)
857869
swake_up_one(&rdp->nocb_state_wq);
858-
859-
do {
860-
swait_event_interruptible_exclusive(rdp->nocb_cb_wq,
861-
nocb_cb_wait_cond(rdp));
862-
863-
// VVV Ensure CB invocation follows _sleep test.
864-
if (smp_load_acquire(&rdp->nocb_cb_sleep)) { // ^^^
865-
WARN_ON(signal_pending(current));
866-
trace_rcu_nocb_wake(rcu_state.name, rdp->cpu, TPS("WokeEmpty"));
867-
}
868-
} while (!nocb_cb_can_run(rdp));
869870
}
870871

871872
/*

0 commit comments

Comments
 (0)