Skip to content

Commit f50ad4b

Browse files
author
Joel Fernandes
committed
srcu: Use rcu_seq_done_exact() for polling API
poll_state_synchronize_srcu() uses rcu_seq_done() unlike poll_state_synchronize_rcu() which uses rcu_seq_done_exact(). The rcu_seq_done_exact() makes more sense for polling API, as with this API, there is a higher chance that there is a significant delay between the get_state..() and poll_state..() calls since a cookie can be stored and reused at a later time. During such a delay, if the gp_seq counter progresses more than ULONG_MAX/2 distance, then poll_state..() may return false for a long time unwantedly. Fix by using the more accurate rcu_seq_done_exact() API which is exactly what straight RCU's polling does. It may make sense, as future work, to add debug code here as well, where we compare a physical timestamp between get_state..() and poll_state() calls and yell if significant time has past but the grace period has still not progressed. Reviewed-by: Neeraj Upadhyay <[email protected]> Reviewed-by: Paul E. McKenney <[email protected]> Reviewed-by: Kent Overstreet <[email protected]> Cc: Kent Overstreet <[email protected]> Signed-off-by: Joel Fernandes <[email protected]>
1 parent 4d949ed commit f50ad4b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/rcu/srcutree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1589,7 +1589,7 @@ EXPORT_SYMBOL_GPL(start_poll_synchronize_srcu);
15891589
bool poll_state_synchronize_srcu(struct srcu_struct *ssp, unsigned long cookie)
15901590
{
15911591
if (cookie != SRCU_GET_STATE_COMPLETED &&
1592-
!rcu_seq_done(&ssp->srcu_sup->srcu_gp_seq, cookie))
1592+
!rcu_seq_done_exact(&ssp->srcu_sup->srcu_gp_seq, cookie))
15931593
return false;
15941594
// Ensure that the end of the SRCU grace period happens before
15951595
// any subsequent code that the caller might execute.

0 commit comments

Comments
 (0)