Skip to content

Commit de3f267

Browse files
committed
srcu: Make Tiny SRCU poll_state_synchronize_srcu() more precise
This commit applies the more-precise grace-period-state check used by rcu_seq_done_exact() to poll_state_synchronize_srcu(). This is important because Tiny SRCU uses a 16-bit counter, which can wrap quite quickly. If counter wrap continues to be a problem, then expanding ->srcu_idx and ->srcu_idx_max to 32 bits might be warranted. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent d66e4cf commit de3f267

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/rcu/srcutiny.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(start_poll_synchronize_srcu);
240240
*/
241241
bool poll_state_synchronize_srcu(struct srcu_struct *ssp, unsigned long cookie)
242242
{
243-
bool ret = USHORT_CMP_GE(READ_ONCE(ssp->srcu_idx), cookie);
243+
unsigned short cur_s = READ_ONCE(ssp->srcu_idx);
244244

245245
barrier();
246-
return ret;
246+
return USHORT_CMP_GE(cur_s, cookie) || USHORT_CMP_LT(cur_s, cookie - 3);
247247
}
248248
EXPORT_SYMBOL_GPL(poll_state_synchronize_srcu);
249249

0 commit comments

Comments
 (0)