Skip to content

Commit 95ff24e

Browse files
committed
rcu: Upgrade header comment for poll_state_synchronize_rcu()
This commit emphasizes the possibility of concurrent calls to synchronize_rcu() and synchronize_rcu_expedited() causing one or the other of the two grace periods being lost from the viewpoint of poll_state_synchronize_rcu(). If you cannot afford to lose grace periods this way, you should instead use the _full() variants of the polled RCU API, for example, poll_state_synchronize_rcu_full(). Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 253cbbf commit 95ff24e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

kernel/rcu/tree.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3559,7 +3559,9 @@ EXPORT_SYMBOL_GPL(start_poll_synchronize_rcu_full);
35593559
* If @false is returned, it is the caller's responsibility to invoke this
35603560
* function later on until it does return @true. Alternatively, the caller
35613561
* can explicitly wait for a grace period, for example, by passing @oldstate
3562-
* to cond_synchronize_rcu() or by directly invoking synchronize_rcu().
3562+
* to either cond_synchronize_rcu() or cond_synchronize_rcu_expedited()
3563+
* on the one hand or by directly invoking either synchronize_rcu() or
3564+
* synchronize_rcu_expedited() on the other.
35633565
*
35643566
* Yes, this function does not take counter wrap into account.
35653567
* But counter wrap is harmless. If the counter wraps, we have waited for
@@ -3570,6 +3572,12 @@ EXPORT_SYMBOL_GPL(start_poll_synchronize_rcu_full);
35703572
* completed. Alternatively, they can use get_completed_synchronize_rcu()
35713573
* to get a guaranteed-completed grace-period state.
35723574
*
3575+
* In addition, because oldstate compresses the grace-period state for
3576+
* both normal and expedited grace periods into a single unsigned long,
3577+
* it can miss a grace period when synchronize_rcu() runs concurrently
3578+
* with synchronize_rcu_expedited(). If this is unacceptable, please
3579+
* instead use the _full() variant of these polling APIs.
3580+
*
35733581
* This function provides the same memory-ordering guarantees that
35743582
* would be provided by a synchronize_rcu() that was invoked at the call
35753583
* to the function that provided @oldstate, and that returned at the end

0 commit comments

Comments
 (0)