rcutorture: Perform more frequent testing of ->gpwrap
Subsystems (3)
Joel Fernandes
maintainerPATCH v5 1/1 rcutorture: Perform more frequent testing of ->gpwrap
Currently, the ->gpwrap is not tested (at all per my testing) due to the requirement of a large delta between a CPU's rdp->gp_seq and its node's rnp->gpseq.
This results in no testing of ->gpwrap being set. This patch by default adds 5 minutes of testing with ->gpwrap forced by lowering the delta between rdp->gp_seq and rnp->gp_seq to just 8 GPs. All of this is configurable, including the active time for the setting and a full testing cycle.
By default, the first 25 minutes of a test will have the _default_ behavior there is right now (ULONG_MAX / 4) delta. Then for 5 minutes, we switch to a smaller delta causing 1-2 wraps in 5 minutes. I believe this is reasonable since we at least add a little bit of testing for usecases where ->gpwrap is set.
---v4->v5
- Added gpwrap_lag torture param to turn off entire test.
- replaced references to 'ovf' with 'gpwrap lag'.
Will move this to my rcu/torture-for-6.16 and update my rcu/for-next branches.
.../admin-guide/kernel-parameters.txt | 5 ++ kernel/rcu/rcu.h | 4 ++ kernel/rcu/rcutorture.c | 72 ++++++++++++++++++- kernel/rcu/tree.c | 34 ++++++++- kernel/rcu/tree.h | 1 + 5 files changed, 113 insertions(+), 3 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +5 -0
@@ -5657,6 +5657,11 @@ are zero, rcutorture acts as if is interpreted they are all non-zero. + rcutorture.gpwrap_lag= [KNL] + Enable grace-period wrap lag testing. Setting + to false prevents the gpwrap lag test from + running. + rcutorture.irqreader= [KNL] Run RCU readers from irq handlers, or, more accurately, from a timer handler. Not all RCU
kernel/rcu/rcu.h +4 -0
@@ -572,6 +572,8 @@ void do_trace_rcu_torture_read(const char *rcutorturename,unsigned long c_old, unsigned long c);void rcu_gp_set_torture_wait (int duration); +void rcu_set_gpwrap_lag (unsigned long lag); +int rcu_get_gpwrap_count (int cpu);#else static inline void rcutorture_get_gp_data (int *flags,unsigned long *gp_seq) {
@@ -589,6 +591,8 @@ void do_trace_rcu_torture_read(const char *rcutorturename, do { } while (0)#endif static inline void rcu_gp_set_torture_wait (int duration) { } +static inline void rcu_set_gpwrap_lag (unsigned long lag) { } +static inline int rcu_get_gpwrap_count (int cpu) {return 0 ; }#endif unsigned long long rcutorture_gather_gp_seqs (void );void rcutorture_format_gp_seqs (unsigned long long seqs,char *cp,size_t len);
kernel/rcu/rcutorture.c +71 -1
127 lines not on this page · raw message
kernel/rcu/tree.c +32 -2
@@ -80,6 +80,15 @@ static void rcu_sr_normal_gp_cleanup_work(struct work_struct *); static DEFINE_PER_CPU_SHARED_ALIGNED(struct rcu_data, rcu_data) = { .gpwrap = true, }; + +int rcu_get_gpwrap_count (int cpu) +{ +struct rcu_data *rdp =per_cpu_ptr (&rcu_data, cpu); + +return READ_ONCE (rdp->gpwrap_count); +} +EXPORT_SYMBOL_GPL (rcu_get_gpwrap_count); +static struct rcu_state rcu_state = { .level = { &rcu_state.node[0 ] }, .gp_state =RCU_GP_IDLE ,
@@ -757,6 +766,25 @@ void rcu_request_urgent_qs_task(struct task_struct *t)smp_store_release (per_cpu_ptr (&rcu_data.rcu_urgent_qs, cpu), true); } +/** +* rcu_set_gpwrap_lag - Set RCU GP sequence overflow lag value. +* @lag_gps: Set overflow lag to this many grace period worth of counters +* which is used by rcutorture to quickly force a gpwrap situation. +* @lag_gps = 0 means we reset it back to the boot-time value. +*/ +static unsigned long seq_gpwrap_lag =ULONG_MAX /4 ; + +void rcu_set_gpwrap_lag (unsigned long lag_gps) +{ +unsigned long lag_seq_count; + + lag_seq_count = (lag_gps ==0 ) + ?ULONG_MAX /4 + : lag_gps <<RCU_SEQ_CTR_SHIFT ; +WRITE_ONCE (seq_gpwrap_lag, lag_seq_count); +} +EXPORT_SYMBOL_GPL (rcu_set_gpwrap_lag); +/* * When trying to report a quiescent state on behalf of some other CPU, * it is our responsibility to check for and handle potential overflow
@@ -767,9 +795,11 @@ void rcu_request_urgent_qs_task(struct task_struct *t)static void rcu_gpnum_ovf (struct rcu_node *rnp,struct rcu_data *rdp) {raw_lockdep_assert_held_rcu_node (rnp); -if (ULONG_CMP_LT (rcu_seq_current (&rdp->gp_seq) +ULONG_MAX /4 , - rnp->gp_seq)) +if (ULONG_CMP_LT (rcu_seq_current (&rdp->gp_seq) + seq_gpwrap_lag, + rnp->gp_seq)) {WRITE_ONCE (rdp->gpwrap, true); +WRITE_ONCE (rdp->gpwrap_count,READ_ONCE (rdp->gpwrap_count) +1 ); + }if (ULONG_CMP_LT (rdp->rcu_iw_gp_seq +ULONG_MAX /4 , rnp->gp_seq)) rdp->rcu_iw_gp_seq = rnp->gp_seq +ULONG_MAX /4 ; }
kernel/rcu/tree.h +1 -0
@@ -183,6 +183,7 @@ struct rcu_data {bool core_needs_qs;/* Core waits for quiescent state. */ bool beenonline;/* CPU online at least once. */ bool gpwrap;/* Possible ->gp_seq wrap. */ +unsigned int gpwrap_count;/* Count of GP sequence wrap. */ bool cpu_started;/* RCU watching this onlining CPU. */ struct rcu_node *mynode;/* This CPU's leaf of hierarchy */ unsigned long grpmask;/* Mask to apply to leaf qsmask. */
Signature · 1 line
2.43.0
Joel Fernandes
maintainerQuoted 37 lines · Joel Fernandes
Currently, the ->gpwrap is not tested (at all per my testing) due to the requirement of a large delta between a CPU's
rdp->gp_seqand its node'srnp->gpseq.This results in no testing of ->gpwrap being set. This patch by default adds 5 minutes of testing with ->gpwrap forced by lowering the delta between
rdp->gp_seqandrnp->gp_seqto just 8 GPs. All of this is configurable, including the active time for the setting and a full testing cycle.By default, the first 25 minutes of a test will have the _default_ behavior there is right now (
ULONG_MAX/ 4) delta. Then for 5 minutes, we switch to a smaller delta causing 1-2 wraps in 5 minutes. I believe this is reasonable since we at least add a little bit of testing for usecases where ->gpwrap is set.Tested-by Paul E. McKenney <[email protected]>Signed-off-by Joel Fernandes <[email protected]>---
v4->v5
- Addedgpwrap_lagtorture param to turn off entire test.
- replaced references to 'ovf' with 'gpwrap lag'.Will move this to my rcu/torture-for-6.16 and update my rcu/for-next branches.
.../admin-guide/kernel-parameters.txt | 5 ++ kernel/rcu/rcu.h | 4 ++ kernel/rcu/rcutorture.c | 72 ++++++++++++++++++- kernel/rcu/tree.c | 34 ++++++++- kernel/rcu/tree.h | 1 + 5 files changed, 113 insertions(+), 3 deletions(-)Documentation/admin-guide/kernel-parameters.txt +0
-0
Documentation/admin-guide/kernel-parameters.txt line 5664
Quoted 8 lines
Documentation/admin-guide/kernel-parameters.txt +5
-0@@ -5657,6 +5657,11 @@ are zero, rcutorture acts as if is interpreted they are all non-zero. + rcutorture.gpwrap_lag= [KNL] + Enable grace-period wrap lag testing. Setting + to false prevents the gpwrap lag test from + running. +
FYI, I added docs for the additional params here as well:
+ rcutorture.gpwrap_lag= [KNL]
+ Enable grace-period wrap lag testing. Setting + to false prevents the gpwrap lag test from + running. + + rcutorture.gpwrap_lag_gps= [KNL] + Set the value for grace-period wrap lag during + active lag testing periods. This controls how many + grace periods differences we tolerate between + rdp and rnp's gp_seq before setting overflow flag. + + rcutorture.gpwrap_lag_cycle_mins= [KNL] + Set the total cycle duration for gpwrap lag + testing in minutes. This is the total time for + one complete cycle of active and inactive + testing periods. Default is 30 minutes. + + rcutorture.gpwrap_lag_active_mins= [KNL] + Set the duration for which gpwrap lag is active + within each cycle, in minutes. During this time, + the grace-period wrap lag will be set to the + value specified by gpwrap_lag_gps. Default is + 5 minutes.
+
Will push this to my rcu/torture-for-6.16 and also update my rcu/for-next branch.
- Joel
Paul E. McKenney
maintainerQuoted 41 lines · Joel Fernandes
Quoted 40 lines · Joel Fernandes
Currently, the ->gpwrap is not tested (at all per my testing) due to the requirement of a large delta between a CPU's
rdp->gp_seqand its node'srnp->gpseq.This results in no testing of ->gpwrap being set. This patch by default adds 5 minutes of testing with ->gpwrap forced by lowering the delta between
rdp->gp_seqandrnp->gp_seqto just 8 GPs. All of this is configurable, including the active time for the setting and a full testing cycle.By default, the first 25 minutes of a test will have the _default_ behavior there is right now (
ULONG_MAX/ 4) delta. Then for 5 minutes, we switch to a smaller delta causing 1-2 wraps in 5 minutes. I believe this is reasonable since we at least add a little bit of testing for usecases where ->gpwrap is set.Tested-by Paul E. McKenney <[email protected]>Signed-off-by Joel Fernandes <[email protected]>---
v4->v5
- Addedgpwrap_lagtorture param to turn off entire test.
- replaced references to 'ovf' with 'gpwrap lag'.Will move this to my rcu/torture-for-6.16 and update my rcu/for-next branches.
.../admin-guide/kernel-parameters.txt | 5 ++ kernel/rcu/rcu.h | 4 ++ kernel/rcu/rcutorture.c | 72 ++++++++++++++++++- kernel/rcu/tree.c | 34 ++++++++- kernel/rcu/tree.h | 1 + 5 files changed, 113 insertions(+), 3 deletions(-)Documentation/admin-guide/kernel-parameters.txt +0
-0@@ -5657,6 +5657,11 @@ are zero, rcutorture acts as if is interpreted they are all non-zero.
Quoted 6 lines
Documentation/admin-guide/kernel-parameters.txt line 5664
Quoted 5 lines
Documentation/admin-guide/kernel-parameters.txt +5
-0+ rcutorture.gpwrap_lag= [KNL] + Enable grace-period wrap lag testing. Setting + to false prevents the gpwrap lag test from + running. +FYI, I added docs for the additional params here as well:
Even better, thank you!
Documentation/admin-guide/kernel-parameters.txt
Quoted 10 lines
Documentation/admin-guide/kernel-parameters.txt +10
-0+ rcutorture.gpwrap_lag= [KNL] + Enable grace-period wrap lag testing. Setting + to false prevents the gpwrap lag test from + running. + + rcutorture.gpwrap_lag_gps= [KNL] + Set the value for grace-period wrap lag during + active lag testing periods. This controls how many + grace periods differences we tolerate between + rdp and rnp's gp_seq before setting overflow flag.
I suggest adding the default, as well as the default when no testing is taking place.
Thanx, Paul
Quoted 20 lines
(quoted diff) +13
-0+ rcutorture.gpwrap_lag_cycle_mins= [KNL] + Set the total cycle duration for gpwrap lag + testing in minutes. This is the total time for + one complete cycle of active and inactive + testing periods. Default is 30 minutes. + + rcutorture.gpwrap_lag_active_mins= [KNL] + Set the duration for which gpwrap lag is active + within each cycle, in minutes. During this time, + the grace-period wrap lag will be set to the + value specified by gpwrap_lag_gps. Default is + 5 minutes. +Will push this to my rcu/torture-for-6.16 and also update my rcu/for-next branch.
- Joel
Joel Fernandes
maintainerQuoted 62 lines · Paul E. McKenney
Quoted 41 lines · Joel Fernandes
Quoted 40 lines · Joel Fernandes
Currently, the ->gpwrap is not tested (at all per my testing) due to the requirement of a large delta between a CPU's
rdp->gp_seqand its node'srnp->gpseq.This results in no testing of ->gpwrap being set. This patch by default adds 5 minutes of testing with ->gpwrap forced by lowering the delta between
rdp->gp_seqandrnp->gp_seqto just 8 GPs. All of this is configurable, including the active time for the setting and a full testing cycle.By default, the first 25 minutes of a test will have the _default_ behavior there is right now (
ULONG_MAX/ 4) delta. Then for 5 minutes, we switch to a smaller delta causing 1-2 wraps in 5 minutes. I believe this is reasonable since we at least add a little bit of testing for usecases where ->gpwrap is set.Tested-by Paul E. McKenney <[email protected]>Signed-off-by Joel Fernandes <[email protected]>---
v4->v5
- Addedgpwrap_lagtorture param to turn off entire test.
- replaced references to 'ovf' with 'gpwrap lag'.Will move this to my rcu/torture-for-6.16 and update my rcu/for-next branches.
.../admin-guide/kernel-parameters.txt | 5 ++ kernel/rcu/rcu.h | 4 ++ kernel/rcu/rcutorture.c | 72 ++++++++++++++++++- kernel/rcu/tree.c | 34 ++++++++- kernel/rcu/tree.h | 1 + 5 files changed, 113 insertions(+), 3 deletions(-)Documentation/admin-guide/kernel-parameters.txt +0
-0@@ -5657,6 +5657,11 @@ are zero, rcutorture acts as if is interpreted they are all non-zero.Quoted 6 lines
Documentation/admin-guide/kernel-parameters.txt line 5664
Quoted 5 lines
Documentation/admin-guide/kernel-parameters.txt +5
-0+ rcutorture.gpwrap_lag= [KNL] + Enable grace-period wrap lag testing. Setting + to false prevents the gpwrap lag test from + running. +FYI, I added docs for the additional params here as well:
Even better, thank you!
Documentation/admin-guide/kernel-parameters.txt
Quoted 10 lines
Documentation/admin-guide/kernel-parameters.txt +10
-0+ rcutorture.gpwrap_lag= [KNL] + Enable grace-period wrap lag testing. Setting + to false prevents the gpwrap lag test from + running. + + rcutorture.gpwrap_lag_gps= [KNL] + Set the value for grace-period wrap lag during + active lag testing periods. This controls how many + grace periods differences we tolerate between + rdp and rnp's gp_seq before setting overflow flag.
Quoted 2 lines
I suggest adding the default, as well as the default when no testing is taking place.
Will do, thanks.
- Joel
[Trimmed most CCs]
Hi Joel,
I've got a warning from "make htmldocs" on top of rcu/next:
[...]/kernel/rcu/tree.c:775: warning: cannot understand function prototype: 'unsigned long seq_gpwrap_lag = ULONG_MAX / 4; '
On Mon, 21 Apr 2025 13:47:15 -0400, Joel Fernandes wrote:
[...]
Quoted 4 lines
kernel/rcu/tree.c +0
-0
[...]
kernel/rcu/tree.c void rcu_request_urgent_qs_task(struct task_struct *t) · line 774
Quoted 10 lines
kernel/rcu/tree.c +6
-0@@ -757,6 +766,25 @@ void rcu_request_urgent_qs_task(struct task_struct *t)smp_store_release (per_cpu_ptr (&rcu_data.rcu_urgent_qs, cpu), true); } +/** +* rcu_set_gpwrap_lag - Set RCU GP sequence overflow lag value. +* @lag_gps: Set overflow lag to this many grace period worth of counters +* which is used by rcutorture to quickly force a gpwrap situation. +* @lag_gps = 0 means we reset it back to the boot-time value. +*/
This kernel-doc comment should be in front of its corresponding function prototype so that it is recognized as such.
kernel/rcu/tree.c void rcu_request_urgent_qs_task(struct task_struct *t) · line 776
Quoted 2 lines
kernel/rcu/tree.c +2
-0+static unsigned long seq_gpwrap_lag =ULONG_MAX /4 ; +
, so this static variable needs to go above the kernel-doc comment.
kernel/rcu/tree.c void rcu_request_urgent_qs_task(struct task_struct *t) · line 787
Quoted 11 lines
kernel/rcu/tree.c +11
-0+void rcu_set_gpwrap_lag (unsigned long lag_gps) +{ +unsigned long lag_seq_count; + + lag_seq_count = (lag_gps ==0 ) + ?ULONG_MAX /4 + : lag_gps <<RCU_SEQ_CTR_SHIFT ; +WRITE_ONCE (seq_gpwrap_lag, lag_seq_count); +} +EXPORT_SYMBOL_GPL (rcu_set_gpwrap_lag); +
You can test it by saying:
./scripts/kernel-doc -none kernel/rcu/tree.c
Thanks,
Akira
Joel Fernandes
maintainerQuoted 14 lines · Akira Yokosawa
kernel/rcu/tree.c void rcu_request_urgent_qs_task(struct task_struct *t) · line 774
Quoted 11 lines
kernel/rcu/tree.c +6
-0@@ -757,6 +766,25 @@ void rcu_request_urgent_qs_task(struct task_struct *t)smp_store_release (per_cpu_ptr (&rcu_data.rcu_urgent_qs, cpu), true); } +/** +* rcu_set_gpwrap_lag - Set RCU GP sequence overflow lag value. +* @lag_gps: Set overflow lag to this many grace period worth of counters +* which is used by rcutorture to quickly force a gpwrap situation. +* @lag_gps = 0 means we reset it back to the boot-time value. +*/ This kernel-doc comment should be in front of its corresponding function prototype so that it is recognized as such.
Quoted 3 lines
Review void rcu_request_urgent_qs_task(struct task_struct *t) · line 776
Quoted 2 lines
(quoted diff) +2
-0+static unsigned long seq_gpwrap_lag = ULONG_MAX / 4; +, so this static variable needs to go above the kernel-doc comment.
Thanks a lot Akira, I will fix this now.
- Joel