Skip to content

Commit 3d05031

Browse files
committed
rcu: Make nocb_gp_wait() double-check unexpected-callback warning
Currently, nocb_gp_wait() unconditionally complains if there is a callback not already associated with a grace period. This assumes that either there was no such callback initially on the one hand, or that the rcu_advance_cbs() function assigned all such callbacks to a grace period on the other. However, in theory there are some situations that would prevent rcu_advance_cbs() from assigning all of the callbacks. This commit therefore checks for unassociated callbacks immediately after rcu_advance_cbs() returns, while the corresponding rcu_node structure's ->lock is still held. If there are unassociated callbacks at that point, the subsequent WARN_ON_ONCE() is disabled. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 13817dd commit 3d05031

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

kernel/rcu/tree_plugin.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1931,6 +1931,7 @@ static void nocb_gp_wait(struct rcu_data *my_rdp)
19311931
struct rcu_data *rdp;
19321932
struct rcu_node *rnp;
19331933
unsigned long wait_gp_seq = 0; // Suppress "use uninitialized" warning.
1934+
bool wasempty = false;
19341935

19351936
/*
19361937
* Each pass through the following loop checks for CBs and for the
@@ -1970,10 +1971,13 @@ static void nocb_gp_wait(struct rcu_data *my_rdp)
19701971
rcu_seq_done(&rnp->gp_seq, cur_gp_seq))) {
19711972
raw_spin_lock_rcu_node(rnp); /* irqs disabled. */
19721973
needwake_gp = rcu_advance_cbs(rnp, rdp);
1974+
wasempty = rcu_segcblist_restempty(&rdp->cblist,
1975+
RCU_NEXT_READY_TAIL);
19731976
raw_spin_unlock_rcu_node(rnp); /* irqs disabled. */
19741977
}
19751978
// Need to wait on some grace period?
1976-
WARN_ON_ONCE(!rcu_segcblist_restempty(&rdp->cblist,
1979+
WARN_ON_ONCE(wasempty &&
1980+
!rcu_segcblist_restempty(&rdp->cblist,
19771981
RCU_NEXT_READY_TAIL));
19781982
if (rcu_segcblist_nextgp(&rdp->cblist, &cur_gp_seq)) {
19791983
if (!needwait_gp ||

0 commit comments

Comments
 (0)