SRCU polled grace-period updates for v6.1
Subsystems (3)
Paul E. McKenney
maintainercover SRCU polled grace-period updates for v6.1
Hello!
This series provides updates for polled SRCU grace periods, mainly for Tiny SRCU:
1. Make "srcud" option also test polled grace-period API.
2. Add GP and maximum requested GP to Tiny SRCU rcutorture output.
3. Make Tiny SRCU poll_state_synchronize_srcu() more precise.
4. Make Tiny SRCU use full-sized grace-period counters.
Thanx, Paul
------------------------------------------------------------------------
b/include/linux/srcutiny.h | 6 ++++-- b/kernel/rcu/rcutorture.c | 3 +++ b/kernel/rcu/srcutiny.c | 4 ++-- include/linux/srcutiny.h | 6 +++--- kernel/rcu/srcutiny.c | 14 +++++++------- 5 files changed, 19 insertions(+), 14 deletions(-)
Paul E. McKenney
maintainerPATCH 1/4 rcutorture: Make "srcud" option also test polled grace-period API
This commit brings the "srcud" (dynamically allocated) SRCU test in line with the "srcu" (statically allocated) test, so that both test the full SRCU polled grace-period API.
--- kernel/rcu/rcutorture.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/rcu/rcutorture.c +3 -0
@@ -709,6 +709,9 @@ static struct rcu_torture_ops srcud_ops = { .deferred_free = srcu_torture_deferred_free, .sync = srcu_torture_synchronize, .exp_sync = srcu_torture_synchronize_expedited, + .get_gp_state = srcu_torture_get_gp_state, + .start_gp_poll = srcu_torture_start_gp_poll, + .poll_gp_state = srcu_torture_poll_gp_state, .call = srcu_torture_call, .cb_barrier = srcu_torture_barrier, .stats = srcu_torture_stats,
Signature · 1 line
2.31.1.189.g2e36527f23
Paul E. McKenney
maintainerPATCH 2/4 srcu: Add GP and maximum requested GP to Tiny SRCU rcutorture output
In reply to Paul E. McKenneyThis commit adds the ->srcu_idx and ->srcu_max_idx fields to the Tiny SRCU rcutorture output for additional diagnostics.
--- include/linux/srcutiny.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
include/linux/srcutiny.h +4 -2
@@ -82,10 +82,12 @@ static inline void srcu_torture_stats_print(struct srcu_struct *ssp,int idx; idx = ((data_race (READ_ONCE (ssp->srcu_idx)) +1 ) &0x2 ) >>1 ; -pr_alert ("%s%s Tiny SRCU per-CPU(idx=%d): (%hd,%hd)\n" , +pr_alert ("%s%s Tiny SRCU per-CPU(idx=%d): (%hd,%hd) gp: %hu->%hu\n" , tt, tf, idx,data_race (READ_ONCE (ssp->srcu_lock_nesting[!idx])), - data_race(READ_ONCE(ssp->srcu_lock_nesting[idx]))); +data_race (READ_ONCE (ssp->srcu_lock_nesting[idx])), +data_race (READ_ONCE (ssp->srcu_idx)), + data_race(READ_ONCE(ssp->srcu_idx_max))); }#endif
Signature · 1 line
2.31.1.189.g2e36527f23
Paul E. McKenney
maintainerPATCH 3/4 srcu: Make Tiny SRCU poll_state_synchronize_srcu() more precise
In reply to Paul E. McKenneyThis 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.
--- kernel/rcu/srcutiny.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/srcutiny.c +2 -2
@@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(start_poll_synchronize_srcu);*/ bool poll_state_synchronize_srcu (struct srcu_struct *ssp,unsigned long cookie) { -bool ret =USHORT_CMP_GE (READ_ONCE (ssp->srcu_idx), cookie); +unsigned short cur_s =READ_ONCE (ssp->srcu_idx);barrier (); -return ret; +return USHORT_CMP_GE (cur_s, cookie) ||USHORT_CMP_LT (cur_s, cookie -3 ); }EXPORT_SYMBOL_GPL (poll_state_synchronize_srcu);
Signature · 1 line
2.31.1.189.g2e36527f23
Paul E. McKenney
maintainerPATCH 4/4 srcu: Make Tiny SRCU use full-sized grace-period counters
In reply to Paul E. McKenneyThis commit makes Tiny SRCU use full-sized grace-period counters to further avoid counter-wrap issues when using polled grace-period APIs.
--- include/linux/srcutiny.h | 6 +++--- kernel/rcu/srcutiny.c | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-)
include/linux/srcutiny.h +3 -3
@@ -15,10 +15,10 @@struct srcu_struct {short srcu_lock_nesting[2 ];/* srcu_read_lock() nesting depth. */ -unsigned short srcu_idx;/* Current reader array element in bit 0x2. */ -unsigned short srcu_idx_max;/* Furthest future srcu_idx request. */ u8 srcu_gp_running;/* GP workqueue running? */ u8 srcu_gp_waiting;/* GP waiting for readers? */ +unsigned long srcu_idx;/* Current reader array element in bit 0x2. */ +unsigned long srcu_idx_max;/* Furthest future srcu_idx request. */ struct swait_queue_head srcu_wq;/* Last srcu_read_unlock() wakes GP. */ struct rcu_head *srcu_cb_head;/* Pending callbacks: Head. */
@@ -82,7 +82,7 @@ static inline void srcu_torture_stats_print(struct srcu_struct *ssp,int idx; idx = ((data_race (READ_ONCE (ssp->srcu_idx)) +1 ) &0x2 ) >>1 ; - pr_alert("%s%s Tiny SRCU per-CPU(idx=%d): (%hd,%hd) gp: %hu->%hu\n", + pr_alert("%s%s Tiny SRCU per-CPU(idx=%d): (%hd,%hd) gp: %lu->%lu\n", tt, tf, idx, data_race(READ_ONCE(ssp->srcu_lock_nesting[!idx])), data_race(READ_ONCE(ssp->srcu_lock_nesting[idx])),
kernel/rcu/srcutiny.c +7 -7
@@ -117,7 +117,7 @@ void srcu_drive_gp(struct work_struct *wp)struct srcu_struct *ssp; ssp = container_of(wp, struct srcu_struct, srcu_work); -if (ssp->srcu_gp_running ||USHORT_CMP_GE (ssp->srcu_idx,READ_ONCE (ssp->srcu_idx_max))) +if (ssp->srcu_gp_running ||ULONG_CMP_GE (ssp->srcu_idx,READ_ONCE (ssp->srcu_idx_max)))return ;/* Already running or nothing to do. */ /* Remove recently arrived callbacks and wait for readers. */
@@ -150,17 +150,17 @@ void srcu_drive_gp(struct work_struct *wp)* straighten that out. */ WRITE_ONCE (ssp->srcu_gp_running, false); -if (USHORT_CMP_LT (ssp->srcu_idx,READ_ONCE (ssp->srcu_idx_max))) +if (ULONG_CMP_LT (ssp->srcu_idx,READ_ONCE (ssp->srcu_idx_max)))schedule_work (&ssp->srcu_work); }EXPORT_SYMBOL_GPL (srcu_drive_gp);static void srcu_gp_start_if_needed (struct srcu_struct *ssp) { -unsigned short cookie; +unsigned long cookie; cookie =get_state_synchronize_srcu (ssp); -if (USHORT_CMP_GE (READ_ONCE (ssp->srcu_idx_max), cookie)) +if (ULONG_CMP_GE (READ_ONCE (ssp->srcu_idx_max), cookie))return ;WRITE_ONCE (ssp->srcu_idx_max, cookie);if (!READ_ONCE (ssp->srcu_gp_running)) {
@@ -215,7 +215,7 @@ unsigned long get_state_synchronize_srcu(struct srcu_struct *ssp)barrier (); ret = (READ_ONCE (ssp->srcu_idx) +3 ) & ~0x1 ;barrier (); -return ret &USHRT_MAX ; +return ret; }EXPORT_SYMBOL_GPL (get_state_synchronize_srcu);
@@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(start_poll_synchronize_srcu);*/ bool poll_state_synchronize_srcu (struct srcu_struct *ssp,unsigned long cookie) { -unsigned short cur_s =READ_ONCE (ssp->srcu_idx); +unsigned long cur_s =READ_ONCE (ssp->srcu_idx);barrier (); -return USHORT_CMP_GE (cur_s, cookie) ||USHORT_CMP_LT (cur_s, cookie -3 ); +return ULONG_CMP_GE (cur_s, cookie) ||ULONG_CMP_LT (cur_s, cookie -3 ); }EXPORT_SYMBOL_GPL (poll_state_synchronize_srcu);
Signature · 1 line
2.31.1.189.g2e36527f23