Skip to content

Commit c21357e

Browse files
Frederic Weisbeckerneeraju
authored andcommitted
srcu: Explain why callbacks invocations can't run concurrently
If an SRCU barrier is queued while callbacks are running and a new callbacks invocator for the same sdp were to run concurrently, the RCU barrier might execute too early. As this requirement is non-obvious, make sure to keep a record. Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Neeraj Upadhyay (AMD) <neeraj.iitr10@gmail.com>
1 parent 94c55b9 commit c21357e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

kernel/rcu/srcutree.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,6 +1715,11 @@ static void srcu_invoke_callbacks(struct work_struct *work)
17151715
WARN_ON_ONCE(!rcu_segcblist_segempty(&sdp->srcu_cblist, RCU_NEXT_TAIL));
17161716
rcu_segcblist_advance(&sdp->srcu_cblist,
17171717
rcu_seq_current(&ssp->srcu_sup->srcu_gp_seq));
1718+
/*
1719+
* Although this function is theoretically re-entrant, concurrent
1720+
* callbacks invocation is disallowed to avoid executing an SRCU barrier
1721+
* too early.
1722+
*/
17181723
if (sdp->srcu_cblist_invoking ||
17191724
!rcu_segcblist_ready_cbs(&sdp->srcu_cblist)) {
17201725
spin_unlock_irq_rcu_node(sdp);
@@ -1745,6 +1750,7 @@ static void srcu_invoke_callbacks(struct work_struct *work)
17451750
sdp->srcu_cblist_invoking = false;
17461751
more = rcu_segcblist_ready_cbs(&sdp->srcu_cblist);
17471752
spin_unlock_irq_rcu_node(sdp);
1753+
/* An SRCU barrier or callbacks from previous nesting work pending */
17481754
if (more)
17491755
srcu_schedule_cbs_sdp(sdp, 0);
17501756
}

0 commit comments

Comments
 (0)