rcutorture: Perform more frequent testing of ->gpwrap
Subsystems (2)
Joel Fernandes
maintainerPATCH 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.
--- kernel/rcu/rcu.h | 4 +++ kernel/rcu/rcutorture.c | 64 +++++++++++++++++++++++++++++++++++++++++ kernel/rcu/tree.c | 34 ++++++++++++++++++++-- kernel/rcu/tree.h | 1 + 4 files changed, 101 insertions(+), 2 deletions(-)
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_torture_ovf_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_torture_ovf_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 +64 -0
106 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 ,
@@ -778,6 +787,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_torture_ovf_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_ovf_lag =ULONG_MAX /4 ; + +void rcu_set_torture_ovf_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_ovf_lag, lag_seq_count); +} +EXPORT_SYMBOL_GPL (rcu_set_torture_ovf_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
@@ -788,9 +816,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_ovf_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
Paul E. McKenney
maintainerQuoted 10 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.
Quoted 7 lines
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.Signed-off-by Joel Fernandes <[email protected]>
I ran this as follows:
tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 10m --configs "TREE01" --bootargs "rcutorture.ovf_cycle_mins=7" --trust-make
Once I actually applied your patch, I did get this:
[ 601.891042] gpwraps: 13745
Which seems to indicate some testing. ;-)
Additional comments inline.
Thanx, Paul
Quoted 21 lines
--- kernel/rcu/rcu.h | 4 +++ kernel/rcu/rcutorture.c | 64 +++++++++++++++++++++++++++++++++++++++++ kernel/rcu/tree.c | 34 ++++++++++++++++++++-- kernel/rcu/tree.h | 1 + 4 files changed, 101 insertions(+), 2 deletions(-)kernel/rcu/rcu.h +2
-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_torture_ovf_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) {
kernel/rcu/rcu.h void do_trace_rcu_torture_read(const char *rcutorturename, · line 595
Quoted 5 lines
kernel/rcu/rcu.h +2
-0@@ -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_torture_ovf_lag (unsigned long lag) { } +static inline int rcu_get_gpwrap_count (int cpu) {return 0 ; }
Very good, you did remember CONFIG_SMP=n. And yes, I did try it. ;-)
But shouldn't these be function pointers in rcu_torture_ops? That way if some other flavor of RCU starts doing wrap protection for its grace-period sequence numbers, this testing can apply directly to that flavor as well.
Then the pointers can simply be NULL in kernels built with CONFIG_SMP=n.
Quoted 8 lines
kernel/rcu/rcu.h +0
-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 +0
-0
kernel/rcu/rcutorture.c torture_param(int, nreaders, -1, "Number of RCU reader threads"); · line 123
Quoted 6 lines
kernel/rcu/rcutorture.c +3
-0@@ -118,6 +118,9 @@ torture_param(int, nreaders, -1, "Number of RCU reader threads");torture_param (int, object_debug,0 ,"Enable debug-object double call_rcu() testing" );torture_param (int, onoff_holdoff,0 ,"Time after boot before CPU hotplugs (s)" );torture_param (int, onoff_interval,0 ,"Time between CPU hotplugs (jiffies), 0=disable" ); +torture_param (int, ovf_cycle_mins,30 ,"Total cycle duration for ovf lag testing (in minutes)" ); +torture_param (int, ovf_active_mins,5 ,"Duration for which ovf lag is active within each cycle (in minutes)" ); +torture_param (int, ovf_lag_gps,8 ,"Value to set for set_torture_ovf_lag during an active testing period." );
Given that "ovf" means just "overflow", would it make sense to get a "gp" in there? Maybe just "gpwrap_..."?
"What is in a name?" ;-)
I could argue with the defaults, but I run long tests often enough that I am not worried about coverage. As long as we remember to either run long tests or specify appropriate rcutorture.ovf_cycle_mins when messing with ->gpwrap code.
Quoted 20 lines
kernel/rcu/rcutorture.c +2
-0torture_param (int, nocbs_nthreads,0 ,"Number of NOCB toggle threads, 0 to disable" );torture_param (int, nocbs_toggle,1000 ,"Time between toggling nocb state (ms)" );torture_param (int, preempt_duration,0 ,"Preemption duration (ms), zero to disable" );@@ -2629,6 +2632,7 @@ rcu_torture_stats_print(void)int i;long pipesummary[RCU_TORTURE_PIPE_LEN +1 ] = {0 };long batchsummary[RCU_TORTURE_PIPE_LEN +1 ] = {0 }; +long n_gpwraps =0 ;struct rcu_torture *rtcp;static unsigned long rtcv_snap =ULONG_MAX ;static bool splatted;@@ -2639,6 +2643,7 @@ rcu_torture_stats_print(void) pipesummary[i] +=READ_ONCE (per_cpu (rcu_torture_count, cpu)[i]); batchsummary[i] +=READ_ONCE (per_cpu (rcu_torture_batch, cpu)[i]); } + n_gpwraps +=rcu_get_gpwrap_count (cpu); }for (i =RCU_TORTURE_PIPE_LEN ; i >=0 ; i--) {if (pipesummary[i] !=0 )
kernel/rcu/rcutorture.c rcu_torture_stats_print(void) · line 2678
Quoted 2 lines
kernel/rcu/rcutorture.c +0
-0@@ -2672,6 +2677,7 @@ rcu_torture_stats_print(void)pr_cont ("read-exits: %ld " ,data_race (n_read_exits));// Statistic. pr_cont("nocb-toggles: %ld:%ld\n",
The "\n" on the above line needs to be deleted.
kernel/rcu/rcutorture.c static int rcu_torture_preempt(void *unused) · line 3852
Quoted 11 lines
kernel/rcu/rcutorture.c +3
-0atomic_long_read(&n_nocb_offload), atomic_long_read(&n_nocb_deoffload)); +pr_cont ("gpwraps: %ld\n" , n_gpwraps);pr_alert ("%s%s " , torture_type,TORTURE_FLAG ); if (atomic_read(&n_rcu_torture_mberror) ||@@ -3842,6 +3848,58 @@ static int rcu_torture_preempt(void *unused)static enum cpuhp_state rcutor_hp; +static struct hrtimer ovf_lag_timer; +static bool ovf_lag_active;
Same "ovf" naming complaint as before.
Quoted 13 lines
kernel/rcu/rcutorture.c +13
-0+ +/* Timer handler for toggling RCU grace-period sequence overflow test lag value */ +static enum hrtimer_restart rcu_torture_ovf_lag_timer (struct hrtimer *timer) +{ +ktime_t next_delay; + +if (ovf_lag_active) { +pr_alert ("rcu-torture: Disabling ovf lag (value=0)\n" ); +rcu_set_torture_ovf_lag (0 ); + ovf_lag_active = false; + next_delay =ktime_set ((ovf_cycle_mins - ovf_active_mins) *60 ,0 ); + }else { +pr_alert ("rcu-torture: Enabling ovf lag (value=%d)\n" , ovf_lag_gps);
kernel/rcu/rcutorture.c static int rcu_torture_preempt(void *unused) · line 3875
Quoted 10 lines
kernel/rcu/rcutorture.c +10
-0+rcu_set_torture_ovf_lag (ovf_lag_gps); + ovf_lag_active = true; + next_delay =ktime_set (ovf_active_mins *60 ,0 ); + } + +if (torture_must_stop ()) +return HRTIMER_NORESTART ; + +hrtimer_forward_now (timer, next_delay); +return HRTIMER_RESTART ;
OK, this does look to do cycles.
kernel/rcu/rcutorture.c static int rcu_torture_preempt(void *unused) · line 3883
Quoted 8 lines
kernel/rcu/rcutorture.c +8
-0+} + +static int rcu_torture_ovf_lag_init (void ) +{ +if (ovf_cycle_mins <=0 || ovf_active_mins <=0 ) { +pr_alert ("rcu-torture: lag timing parameters must be positive\n" ); +return -EINVAL ; + }
Why not refuse to start this portion of the test when testing CONFIG_SMP=n or something other than vanilla RCU? No need to fail the test, just print something saying that this testing won't be happening.
kernel/rcu/rcutorture.c static int rcu_torture_preempt(void *unused) · line 3892
Quoted 8 lines
kernel/rcu/rcutorture.c +8
-0+hrtimer_init (&ovf_lag_timer,CLOCK_MONOTONIC ,HRTIMER_MODE_REL ); + ovf_lag_timer.function = rcu_torture_ovf_lag_timer; + ovf_lag_active = false; +hrtimer_start (&ovf_lag_timer, +ktime_set ((ovf_cycle_mins - ovf_active_mins) *60 ,0 ),HRTIMER_MODE_REL ); + +return 0 ; +}
All hrtimers, no kthreads. Nice!
kernel/rcu/rcutorture.c static int rcu_torture_preempt(void *unused) · line 3902
Quoted 10 lines
kernel/rcu/rcutorture.c +10
-0+ +static void rcu_torture_ovf_lag_cleanup (void ) +{ +hrtimer_cancel (&ovf_lag_timer); + +if (ovf_lag_active) { +rcu_set_torture_ovf_lag (0 ); + ovf_lag_active = false; + } +}
Did you try the modprobe/rmmod testing to verify that this cleans up appropriately? You could use the drgn tool to check. See tools/rcu//rcu-cbs.py for an example drgn script that digs into the rcu_data structures.
Quoted 73 lines
kernel/rcu/rcutorture.c +6
-0static void rcu_torture_cleanup (void ) {@@ -4015,6 +4073,8 @@ rcu_torture_cleanup(void)torture_cleanup_end ();if (cur_ops->gp_slow_unregister) cur_ops->gp_slow_unregister (NULL ); + +rcu_torture_ovf_lag_cleanup (); }static void rcu_torture_leak_cb (struct rcu_head *rhp)@@ -4508,6 +4568,10 @@ rcu_torture_init(void)torture_init_end ();if (cur_ops->gp_slow_register && !WARN_ON_ONCE (!cur_ops->gp_slow_unregister)) cur_ops->gp_slow_register (&rcu_fwd_cb_nodelay); + +if (rcu_torture_ovf_lag_init ()) + goto unwind; +return 0 ; unwind:kernel/rcu/tree.c +28
-0@@ -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 ,@@ -778,6 +787,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_torture_ovf_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_ovf_lag =ULONG_MAX /4 ; + +void rcu_set_torture_ovf_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_ovf_lag, lag_seq_count); +} +EXPORT_SYMBOL_GPL (rcu_set_torture_ovf_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 @@ -788,9 +816,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);
kernel/rcu/tree.c void rcu_request_urgent_qs_task(struct task_struct *t) · line 826
Quoted 10 lines
kernel/rcu/tree.c +4
-2-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_ovf_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 ; }
Looks plausible.
Quoted 15 lines
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
maintainerHello, Paul,
Quoted 21 lines · Paul E. McKenney
Quoted 10 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.Quoted 7 lines
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.Signed-off-by Joel Fernandes <[email protected]>I ran this as follows:
Quoted 7 lines
tools/testing/selftests/rcutorture/bin/kvm.sh--allcpus --duration 10m --configs "TREE01" --bootargs "rcutorture.ovf_cycle_mins=7" --trust-makeOnce I actually applied your patch, I did get this:
[ 601.891042] gpwraps: 13745Which seems to indicate some testing. ;-)
Thanks a lot for running it. I am wondering if I should check in tree.c (only in testing mode), if the wraps are too many and restrict testing if so. Otherwise, it is hard to come up with a constant that ensures the wraps are under control. On the other hand, since this is only for 5 minutes every 30 minutes, we can leave it as is and avoid the complexity.
Quoted 34 lines
Additional comments inline.
Thanx, Paul
Quoted 21 lines
--- kernel/rcu/rcu.h | 4 +++ kernel/rcu/rcutorture.c | 64 +++++++++++++++++++++++++++++++++++++++++ kernel/rcu/tree.c | 34 ++++++++++++++++++++-- kernel/rcu/tree.h | 1 + 4 files changed, 101 insertions(+), 2 deletions(-)kernel/rcu/rcu.h +2
-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_torture_ovf_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) {kernel/rcu/rcu.h void do_trace_rcu_torture_read(const char *rcutorturename, · line 595
Quoted 5 lines
kernel/rcu/rcu.h +2
-0@@ -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_torture_ovf_lag (unsigned long lag) { } +static inline int rcu_get_gpwrap_count (int cpu) {return 0 ; }Very good, you did remember
CONFIG_SMP=n. And yes, I did try it. ;-)
Quoted 3 lines
But shouldn't these be function pointers in
rcu_torture_ops? That way if some other flavor of RCU starts doing wrap protection for its grace-period sequence numbers, this testing can apply directly to that flavor as well.
These are here because 'rdp' is not accessible AFAIK from rcutorture.c. I could add wrappers to these and include them as pointers the a struct as well. But I think these will still stay to access rdp.
Quoted 21 lines
Then the pointers can simply be NULL in kernels built with
CONFIG_SMP=n.Quoted 8 lines
kernel/rcu/rcu.h +0
-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 +0
-0kernel/rcu/rcutorture.c torture_param(int, nreaders, -1, "Number of RCU reader threads"); · line 123
Quoted 6 lines
kernel/rcu/rcutorture.c +3
-0@@ -118,6 +118,9 @@ torture_param(int, nreaders, -1, "Number of RCU reader threads");torture_param (int, object_debug,0 ,"Enable debug-object double call_rcu() testing" );torture_param (int, onoff_holdoff,0 ,"Time after boot before CPU hotplugs (s)" );torture_param (int, onoff_interval,0 ,"Time between CPU hotplugs (jiffies), 0=disable" ); +torture_param (int, ovf_cycle_mins,30 ,"Total cycle duration for ovf lag testing (in minutes)" ); +torture_param (int, ovf_active_mins,5 ,"Duration for which ovf lag is active within each cycle (in minutes)" ); +torture_param (int, ovf_lag_gps,8 ,"Value to set for set_torture_ovf_lag during an active testing period." );Given that "ovf" means just "overflow", would it make sense to get a "gp" in there? Maybe just "
gpwrap_..."?
Quoted 1 line
"What is in a name?" ;-)
Sure, makes sense I will rename.
Quoted 22 lines
I could argue with the defaults, but I run long tests often enough that I am not worried about coverage. As long as we remember to either run long tests or specify appropriate rcutorture.ovf_cycle_mins when messing with ->gpwrap code.
Quoted 16 lines
kernel/rcu/rcutorture.c +2
-0torture_param (int, nocbs_nthreads,0 ,"Number of NOCB toggle threads, 0 to disable" );torture_param (int, nocbs_toggle,1000 ,"Time between toggling nocb state (ms)" );torture_param (int, preempt_duration,0 ,"Preemption duration (ms), zero to disable" );@@ -2629,6 +2632,7 @@ rcu_torture_stats_print(void)int i;long pipesummary[RCU_TORTURE_PIPE_LEN +1 ] = {0 };long batchsummary[RCU_TORTURE_PIPE_LEN +1 ] = {0 }; +long n_gpwraps =0 ;struct rcu_torture *rtcp;static unsigned long rtcv_snap =ULONG_MAX ;static bool splatted;@@ -2639,6 +2643,7 @@ rcu_torture_stats_print(void) pipesummary[i] +=READ_ONCE (per_cpu (rcu_torture_count, cpu)[i]); batchsummary[i] +=READ_ONCE (per_cpu (rcu_torture_batch, cpu)[i]); } + n_gpwraps +=rcu_get_gpwrap_count (cpu);
Quoted 8 lines
kernel/rcu/rcutorture.c rcu_torture_stats_print(void) · line 2678
Quoted 6 lines
kernel/rcu/rcutorture.c +0
-0}for (i =RCU_TORTURE_PIPE_LEN ; i >=0 ; i--) {if (pipesummary[i] !=0 )@@ -2672,6 +2677,7 @@ rcu_torture_stats_print(void)pr_cont ("read-exits: %ld " ,data_race (n_read_exits));// Statistic. pr_cont("nocb-toggles: %ld:%ld\n",The "\n" on the above line needs to be deleted.
Ok.
Quoted 7 lines
Quoted 7 lines
kernel/rcu/rcutorture.c +1
-0atomic_long_read(&n_nocb_offload), atomic_long_read(&n_nocb_deoffload)); +pr_cont ("gpwraps: %ld\n" , n_gpwraps);pr_alert ("%s%s " , torture_type,TORTURE_FLAG ); if (atomic_read(&n_rcu_torture_mberror) ||@@ -3842,6 +3848,58 @@ static int rcu_torture_preempt(void *unused)
Quoted 6 lines
kernel/rcu/rcutorture.c static int rcu_torture_preempt(void *unused) · line 3852
Quoted 4 lines
kernel/rcu/rcutorture.c +2
-0static enum cpuhp_state rcutor_hp; +static struct hrtimer ovf_lag_timer; +static bool ovf_lag_active;Same "ovf" naming complaint as before.
Ok.
Quoted 4 lines
Quoted 4 lines
kernel/rcu/rcutorture.c +4
-0+} + +static int rcu_torture_ovf_lag_init (void ) +{
Quoted 8 lines
kernel/rcu/rcutorture.c static int rcu_torture_preempt(void *unused) · line 3883
Quoted 4 lines
kernel/rcu/rcutorture.c +4
-0+if (ovf_cycle_mins <=0 || ovf_active_mins <=0 ) { +pr_alert ("rcu-torture: lag timing parameters must be positive\n" ); +return -EINVAL ; + }Why not refuse to start this portion of the test when testing
CONFIG_SMP=nor something other than vanilla RCU? No need to fail the test, just print something saying that this testing won't be happening.
Got it, will do.
Quoted 7 lines
Quoted 7 lines
kernel/rcu/rcutorture.c +7
-0+ +static void rcu_torture_ovf_lag_cleanup (void ) +{ +hrtimer_cancel (&ovf_lag_timer); + +if (ovf_lag_active) { +rcu_set_torture_ovf_lag (0 );
Quoted 8 lines
kernel/rcu/rcutorture.c static int rcu_torture_preempt(void *unused) · line 3876
Quoted 3 lines
kernel/rcu/rcutorture.c +3
-0+ ovf_lag_active = false; + } +}Did you try the modprobe/rmmod testing to verify that this cleans up appropriately? You could use the drgn tool to check. See tools/rcu//rcu-cbs.py for an example drgn script that digs into the
rcu_datastructures.
Nice, will check!
Will work on this and provide v2.
thanks,
- Joel
Paul E. McKenney
maintainerQuoted 30 lines · Joel Fernandes
Hello, Paul,
Quoted 27 lines · Paul E. McKenney
Quoted 10 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.Quoted 7 lines
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.Signed-off-by Joel Fernandes <[email protected]>I ran this as follows:
tools/testing/selftests/rcutorture/bin/kvm.sh--allcpus --duration 10m --configs "TREE01" --bootargs "rcutorture.ovf_cycle_mins=7" --trust-makeOnce I actually applied your patch, I did get this:
[ 601.891042] gpwraps: 13745
Quoted 7 lines
Quoted 1 line
Which seems to indicate some testing. ;-)
Thanks a lot for running it. I am wondering if I should check in
tree.c(only in testing mode), if the wraps are too many and restrict testing if so. Otherwise, it is hard to come up with a constant that ensures the wraps are under control. On the other hand, since this is only for 5 minutes every 30 minutes, we can leave it as is and avoid the complexity.
I don't (yet) see a problem with lots of wraps.
Quoted 33 lines
Quoted 33 lines
Additional comments inline.
Thanx, Paul
Quoted 21 lines
--- kernel/rcu/rcu.h | 4 +++ kernel/rcu/rcutorture.c | 64 +++++++++++++++++++++++++++++++++++++++++ kernel/rcu/tree.c | 34 ++++++++++++++++++++-- kernel/rcu/tree.h | 1 + 4 files changed, 101 insertions(+), 2 deletions(-)kernel/rcu/rcu.h +2
-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_torture_ovf_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) {kernel/rcu/rcu.h void do_trace_rcu_torture_read(const char *rcutorturename, · line 595
Quoted 5 lines
kernel/rcu/rcu.h +2
-0@@ -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_torture_ovf_lag (unsigned long lag) { } +static inline int rcu_get_gpwrap_count (int cpu) {return 0 ; }Very good, you did remember
CONFIG_SMP=n. And yes, I did try it. ;-)
Quoted 7 lines
Quoted 3 lines
But shouldn't these be function pointers in
rcu_torture_ops? That way if some other flavor of RCU starts doing wrap protection for its grace-period sequence numbers, this testing can apply directly to that flavor as well.These are here because 'rdp' is not accessible AFAIK from
rcutorture.c. I could add wrappers to these and include them as pointers the a struct as well. But I think these will still stay to access rdp.
Why not just pass in the CPU number and let the pointed-to function find the rdp?
Quoted 20 lines
Quoted 20 lines
Then the pointers can simply be NULL in kernels built with
CONFIG_SMP=n.Quoted 8 lines
kernel/rcu/rcu.h +0
-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 +0
-0kernel/rcu/rcutorture.c torture_param(int, nreaders, -1, "Number of RCU reader threads"); · line 123
Quoted 6 lines
kernel/rcu/rcutorture.c +3
-0@@ -118,6 +118,9 @@ torture_param(int, nreaders, -1, "Number of RCU reader threads");torture_param (int, object_debug,0 ,"Enable debug-object double call_rcu() testing" );torture_param (int, onoff_holdoff,0 ,"Time after boot before CPU hotplugs (s)" );torture_param (int, onoff_interval,0 ,"Time between CPU hotplugs (jiffies), 0=disable" ); +torture_param (int, ovf_cycle_mins,30 ,"Total cycle duration for ovf lag testing (in minutes)" ); +torture_param (int, ovf_active_mins,5 ,"Duration for which ovf lag is active within each cycle (in minutes)" ); +torture_param (int, ovf_lag_gps,8 ,"Value to set for set_torture_ovf_lag during an active testing period." );Given that "ovf" means just "overflow", would it make sense to get a "gp" in there? Maybe just "
gpwrap_..."?
Quoted 3 lines
Quoted 1 line
"What is in a name?" ;-)
Sure, makes sense I will rename.
Thank you!
Quoted 61 lines
Quoted 21 lines
I could argue with the defaults, but I run long tests often enough that I am not worried about coverage. As long as we remember to either run long tests or specify appropriate rcutorture.ovf_cycle_mins when messing with ->gpwrap code.
Quoted 16 lines
kernel/rcu/rcutorture.c +2
-0torture_param (int, nocbs_nthreads,0 ,"Number of NOCB toggle threads, 0 to disable" );torture_param (int, nocbs_toggle,1000 ,"Time between toggling nocb state (ms)" );torture_param (int, preempt_duration,0 ,"Preemption duration (ms), zero to disable" );@@ -2629,6 +2632,7 @@ rcu_torture_stats_print(void)int i;long pipesummary[RCU_TORTURE_PIPE_LEN +1 ] = {0 };long batchsummary[RCU_TORTURE_PIPE_LEN +1 ] = {0 }; +long n_gpwraps =0 ;struct rcu_torture *rtcp;static unsigned long rtcv_snap =ULONG_MAX ;static bool splatted;@@ -2639,6 +2643,7 @@ rcu_torture_stats_print(void) pipesummary[i] +=READ_ONCE (per_cpu (rcu_torture_count, cpu)[i]); batchsummary[i] +=READ_ONCE (per_cpu (rcu_torture_batch, cpu)[i]); } + n_gpwraps +=rcu_get_gpwrap_count (cpu);Quoted 8 lines
kernel/rcu/rcutorture.c rcu_torture_stats_print(void) · line 2678
Quoted 6 lines
kernel/rcu/rcutorture.c +0
-0}for (i =RCU_TORTURE_PIPE_LEN ; i >=0 ; i--) {if (pipesummary[i] !=0 )@@ -2672,6 +2677,7 @@ rcu_torture_stats_print(void)pr_cont ("read-exits: %ld " ,data_race (n_read_exits));// Statistic. pr_cont("nocb-toggles: %ld:%ld\n",The "\n" on the above line needs to be deleted.
Ok.
Quoted 7 lines
Quoted 7 lines
kernel/rcu/rcutorture.c +1
-0atomic_long_read(&n_nocb_offload), atomic_long_read(&n_nocb_deoffload)); +pr_cont ("gpwraps: %ld\n" , n_gpwraps);pr_alert ("%s%s " , torture_type,TORTURE_FLAG ); if (atomic_read(&n_rcu_torture_mberror) ||@@ -3842,6 +3848,58 @@ static int rcu_torture_preempt(void *unused)Quoted 6 lines
kernel/rcu/rcutorture.c static int rcu_torture_preempt(void *unused) · line 3852
Quoted 4 lines
kernel/rcu/rcutorture.c +2
-0static enum cpuhp_state rcutor_hp; +static struct hrtimer ovf_lag_timer; +static bool ovf_lag_active;Same "ovf" naming complaint as before.
Ok.
Quoted 4 lines
Quoted 4 lines
kernel/rcu/rcutorture.c +4
-0+} + +static int rcu_torture_ovf_lag_init (void ) +{Quoted 8 lines
kernel/rcu/rcutorture.c static int rcu_torture_preempt(void *unused) · line 3883
Quoted 4 lines
kernel/rcu/rcutorture.c +4
-0+if (ovf_cycle_mins <=0 || ovf_active_mins <=0 ) { +pr_alert ("rcu-torture: lag timing parameters must be positive\n" ); +return -EINVAL ; + }Why not refuse to start this portion of the test when testing
CONFIG_SMP=nor something other than vanilla RCU? No need to fail the test, just print something saying that this testing won't be happening.
Quoted 1 line
Got it, will do.
Again, thank you!
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
kernel/rcu/rcutorture.c +6
-0+static void rcu_torture_ovf_lag_cleanup (void ) +{ +hrtimer_cancel (&ovf_lag_timer); + +if (ovf_lag_active) { +rcu_set_torture_ovf_lag (0 );Quoted 8 lines
kernel/rcu/rcutorture.c static int rcu_torture_preempt(void *unused) · line 3876
Quoted 3 lines
kernel/rcu/rcutorture.c +3
-0+ ovf_lag_active = false; + } +}Did you try the modprobe/rmmod testing to verify that this cleans up appropriately? You could use the drgn tool to check. See tools/rcu//rcu-cbs.py for an example drgn script that digs into the
rcu_datastructures.
Quoted 3 lines
Nice, will check!
Will work on this and provide v2.
Looking forward to it!
Thanx, Paul
Joel Fernandes
maintainerQuoted 82 lines · Paul E. McKenney
Quoted 30 lines · Joel Fernandes
Hello, Paul,
Quoted 28 lines · Paul E. McKenney
Quoted 10 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.Quoted 7 lines
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.Signed-off-by Joel Fernandes <[email protected]>I ran this as follows:
tools/testing/selftests/rcutorture/bin/kvm.sh--allcpus --duration 10m --configs "TREE01" --bootargs "rcutorture.ovf_cycle_mins=7" --trust-makeOnce I actually applied your patch, I did get this:
[ 601.891042] gpwraps: 13745Quoted 7 lines
Quoted 1 line
Which seems to indicate some testing. ;-)
Thanks a lot for running it. I am wondering if I should check in
tree.c(only in testing mode), if the wraps are too many and restrict testing if so. Otherwise, it is hard to come up with a constant that ensures the wraps are under control. On the other hand, since this is only for 5 minutes every 30 minutes, we can leave it as is and avoid the complexity.I don't (yet) see a problem with lots of wraps.
Quoted 37 lines
Quoted 36 lines
Additional comments inline.
Thanx, Paul
Quoted 21 lines
---
kernel/rcu/rcu.h | 4 +++ kernel/rcu/rcutorture.c | 64 +++++++++++++++++++++++++++++++++++++++++ kernel/rcu/tree.c | 34 ++++++++++++++++++++-- kernel/rcu/tree.h | 1 + 4 files changed, 101 insertions(+), 2 deletions(-)kernel/rcu/rcu.h +2
-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_torture_ovf_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) {kernel/rcu/rcu.h void do_trace_rcu_torture_read(const char *rcutorturename, · line 595
Quoted 5 lines
kernel/rcu/rcu.h +2
-0@@ -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_torture_ovf_lag (unsigned long lag) { } +static inline int rcu_get_gpwrap_count (int cpu) {return 0 ; }Very good, you did remember
CONFIG_SMP=n. And yes, I did try it. ;-)But shouldn't these be function pointers in
rcu_torture_ops? That way if some other flavor of RCU starts doing wrap protection for its grace-period sequence numbers, this testing can apply directly to that flavor as well.
Quoted 6 lines
Quoted 3 lines
These are here because 'rdp' is not accessible AFAIK from
rcutorture.c. I could add wrappers to these and include them as pointers the a struct as well. But I think these will still stay to access rdp.Why not just pass in the CPU number and let the pointed-to function find the rdp?
You mean provide a helper from tree.c that is called in rcutorture, then helper function returning an rdp?
If so, I can certainly do that, was just not sure if this sort of thing was ok since nothing else in rcutorture accesses rdp directly :)
Thanks,
- Joel
Quoted 114 lines
Quoted 21 lines
Quoted 21 lines
Then the pointers can simply be NULL in kernels built with
CONFIG_SMP=n.Quoted 8 lines
kernel/rcu/rcu.h +0
-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 +0
-0kernel/rcu/rcutorture.c torture_param(int, nreaders, -1, "Number of RCU reader threads"); · line 123
Quoted 6 lines
kernel/rcu/rcutorture.c +3
-0@@ -118,6 +118,9 @@ torture_param(int, nreaders, -1, "Number of RCU reader threads");torture_param (int, object_debug,0 ,"Enable debug-object double call_rcu() testing" );torture_param (int, onoff_holdoff,0 ,"Time after boot before CPU hotplugs (s)" );torture_param (int, onoff_interval,0 ,"Time between CPU hotplugs (jiffies), 0=disable" ); +torture_param (int, ovf_cycle_mins,30 ,"Total cycle duration for ovf lag testing (in minutes)" ); +torture_param (int, ovf_active_mins,5 ,"Duration for which ovf lag is active within each cycle (in minutes)" ); +torture_param (int, ovf_lag_gps,8 ,"Value to set for set_torture_ovf_lag during an active testing period." );Given that "ovf" means just "overflow", would it make sense to get a "gp" in there? Maybe just "
gpwrap_..."?Quoted 3 lines
Quoted 1 line
"What is in a name?" ;-)
Sure, makes sense I will rename.
Thank you!
Quoted 61 lines
Quoted 21 lines
I could argue with the defaults, but I run long tests often enough that I am not worried about coverage. As long as we remember to either run long tests or specify appropriate rcutorture.ovf_cycle_mins when messing with ->gpwrap code.
Quoted 16 lines
kernel/rcu/rcutorture.c +2
-0torture_param (int, nocbs_nthreads,0 ,"Number of NOCB toggle threads, 0 to disable" );torture_param (int, nocbs_toggle,1000 ,"Time between toggling nocb state (ms)" );torture_param (int, preempt_duration,0 ,"Preemption duration (ms), zero to disable" );@@ -2629,6 +2632,7 @@ rcu_torture_stats_print(void)int i;long pipesummary[RCU_TORTURE_PIPE_LEN +1 ] = {0 };long batchsummary[RCU_TORTURE_PIPE_LEN +1 ] = {0 }; +long n_gpwraps =0 ;struct rcu_torture *rtcp;static unsigned long rtcv_snap =ULONG_MAX ;static bool splatted;@@ -2639,6 +2643,7 @@ rcu_torture_stats_print(void) pipesummary[i] +=READ_ONCE (per_cpu (rcu_torture_count, cpu)[i]); batchsummary[i] +=READ_ONCE (per_cpu (rcu_torture_batch, cpu)[i]); } + n_gpwraps +=rcu_get_gpwrap_count (cpu);Quoted 8 lines
kernel/rcu/rcutorture.c rcu_torture_stats_print(void) · line 2678
Quoted 6 lines
kernel/rcu/rcutorture.c +0
-0}for (i =RCU_TORTURE_PIPE_LEN ; i >=0 ; i--) {if (pipesummary[i] !=0 )@@ -2672,6 +2677,7 @@ rcu_torture_stats_print(void)pr_cont ("read-exits: %ld " ,data_race (n_read_exits));// Statistic. pr_cont("nocb-toggles: %ld:%ld\n",The "\n" on the above line needs to be deleted.
Ok.
Quoted 7 lines
Quoted 7 lines
kernel/rcu/rcutorture.c +1
-0atomic_long_read(&n_nocb_offload), atomic_long_read(&n_nocb_deoffload)); +pr_cont ("gpwraps: %ld\n" , n_gpwraps);pr_alert ("%s%s " , torture_type,TORTURE_FLAG ); if (atomic_read(&n_rcu_torture_mberror) ||@@ -3842,6 +3848,58 @@ static int rcu_torture_preempt(void *unused)Quoted 6 lines
kernel/rcu/rcutorture.c static int rcu_torture_preempt(void *unused) · line 3852
Quoted 4 lines
kernel/rcu/rcutorture.c +2
-0static enum cpuhp_state rcutor_hp; +static struct hrtimer ovf_lag_timer; +static bool ovf_lag_active;Same "ovf" naming complaint as before.
Ok.
Quoted 4 lines
Quoted 4 lines
kernel/rcu/rcutorture.c +4
-0+} + +static int rcu_torture_ovf_lag_init (void ) +{Quoted 8 lines
kernel/rcu/rcutorture.c static int rcu_torture_preempt(void *unused) · line 3883
Quoted 4 lines
kernel/rcu/rcutorture.c +4
-0+if (ovf_cycle_mins <=0 || ovf_active_mins <=0 ) { +pr_alert ("rcu-torture: lag timing parameters must be positive\n" ); +return -EINVAL ; + }Why not refuse to start this portion of the test when testing
CONFIG_SMP=nor something other than vanilla RCU? No need to fail the test, just print something saying that this testing won't be happening.Quoted 1 line
Got it, will do.
Again, thank you!
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
kernel/rcu/rcutorture.c +6
-0+static void rcu_torture_ovf_lag_cleanup (void ) +{ +hrtimer_cancel (&ovf_lag_timer); + +if (ovf_lag_active) { +rcu_set_torture_ovf_lag (0 );Quoted 8 lines
kernel/rcu/rcutorture.c static int rcu_torture_preempt(void *unused) · line 3876
Quoted 3 lines
kernel/rcu/rcutorture.c +3
-0+ ovf_lag_active = false; + } +}Did you try the modprobe/rmmod testing to verify that this cleans up appropriately? You could use the drgn tool to check. See tools/rcu//rcu-cbs.py for an example drgn script that digs into the
rcu_datastructures.Quoted 3 lines
Nice, will check!
Will work on this and provide v2.
Looking forward to it!
Thanx, Paul
Paul E. McKenney
maintainerQuoted 84 lines · Joel Fernandes
Quoted 84 lines · Paul E. McKenney
Quoted 30 lines · Joel Fernandes
Hello, Paul,
Quoted 28 lines · Paul E. McKenney
Quoted 10 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.Quoted 7 lines
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.Signed-off-by Joel Fernandes <[email protected]>I ran this as follows:
tools/testing/selftests/rcutorture/bin/kvm.sh--allcpus --duration 10m --configs "TREE01" --bootargs "rcutorture.ovf_cycle_mins=7" --trust-makeOnce I actually applied your patch, I did get this:
[ 601.891042] gpwraps: 13745Quoted 7 lines
Quoted 1 line
Which seems to indicate some testing. ;-)
Thanks a lot for running it. I am wondering if I should check in
tree.c(only in testing mode), if the wraps are too many and restrict testing if so. Otherwise, it is hard to come up with a constant that ensures the wraps are under control. On the other hand, since this is only for 5 minutes every 30 minutes, we can leave it as is and avoid the complexity.I don't (yet) see a problem with lots of wraps.
Quoted 40 lines
Quoted 33 lines
Additional comments inline.
Thanx, Paul
Quoted 21 lines
---
kernel/rcu/rcu.h | 4 +++ kernel/rcu/rcutorture.c | 64 +++++++++++++++++++++++++++++++++++++++++ kernel/rcu/tree.c | 34 ++++++++++++++++++++-- kernel/rcu/tree.h | 1 + 4 files changed, 101 insertions(+), 2 deletions(-)kernel/rcu/rcu.h +2
-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_torture_ovf_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) {kernel/rcu/rcu.h void do_trace_rcu_torture_read(const char *rcutorturename, · line 595
Quoted 5 lines
kernel/rcu/rcu.h +2
-0@@ -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_torture_ovf_lag (unsigned long lag) { } +static inline int rcu_get_gpwrap_count (int cpu) {return 0 ; }Very good, you did remember
CONFIG_SMP=n. And yes, I did try it. ;-)Quoted 3 lines
But shouldn't these be function pointers in
rcu_torture_ops? That way if some other flavor of RCU starts doing wrap protection for its grace-period sequence numbers, this testing can apply directly to that flavor as well.These are here because 'rdp' is not accessible AFAIK from
rcutorture.c. I could add wrappers to these and include them as pointers the a struct as well. But I think these will still stay to access rdp.
Quoted 6 lines
Quoted 2 lines
Why not just pass in the CPU number and let the pointed-to function find the rdp?
You mean provide a helper from
tree.cthat is called in rcutorture, then helper function returning an rdp?If so, I can certainly do that, was just not sure if this sort of thing was ok since nothing else in rcutorture accesses rdp directly :)
Actually, this is done quite a bit.
For example, the "rcu" .gp_kthread_dbg() function pointer is set to show_rcu_gp_kthreads(), which is defined either in rcu.h (for Tiny) or in tree_stall.h (for Tree). Alternatively, sometimes a small wrapper function is defined in rcutorture.c which calls functions defined differently for different RCU flavors.
So please feel free to create a function pointer and to define the function in tree.c. But learn from my many mistakes and make sure to provide a suitable definition for Tiny RCU! ;-)
Thanx, Paul
Quoted 119 lines
Thanks,
- Joel
Quoted 114 lines
Quoted 21 lines
Quoted 21 lines
Then the pointers can simply be NULL in kernels built with
CONFIG_SMP=n.Quoted 8 lines
kernel/rcu/rcu.h +0
-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 +0
-0kernel/rcu/rcutorture.c torture_param(int, nreaders, -1, "Number of RCU reader threads"); · line 123
Quoted 6 lines
kernel/rcu/rcutorture.c +3
-0@@ -118,6 +118,9 @@ torture_param(int, nreaders, -1, "Number of RCU reader threads");torture_param (int, object_debug,0 ,"Enable debug-object double call_rcu() testing" );torture_param (int, onoff_holdoff,0 ,"Time after boot before CPU hotplugs (s)" );torture_param (int, onoff_interval,0 ,"Time between CPU hotplugs (jiffies), 0=disable" ); +torture_param (int, ovf_cycle_mins,30 ,"Total cycle duration for ovf lag testing (in minutes)" ); +torture_param (int, ovf_active_mins,5 ,"Duration for which ovf lag is active within each cycle (in minutes)" ); +torture_param (int, ovf_lag_gps,8 ,"Value to set for set_torture_ovf_lag during an active testing period." );Given that "ovf" means just "overflow", would it make sense to get a "gp" in there? Maybe just "
gpwrap_..."?Quoted 3 lines
Quoted 1 line
"What is in a name?" ;-)
Sure, makes sense I will rename.
Thank you!
Quoted 61 lines
Quoted 21 lines
I could argue with the defaults, but I run long tests often enough that I am not worried about coverage. As long as we remember to either run long tests or specify appropriate rcutorture.ovf_cycle_mins when messing with ->gpwrap code.
Quoted 16 lines
kernel/rcu/rcutorture.c +2
-0torture_param (int, nocbs_nthreads,0 ,"Number of NOCB toggle threads, 0 to disable" );torture_param (int, nocbs_toggle,1000 ,"Time between toggling nocb state (ms)" );torture_param (int, preempt_duration,0 ,"Preemption duration (ms), zero to disable" );@@ -2629,6 +2632,7 @@ rcu_torture_stats_print(void)int i;long pipesummary[RCU_TORTURE_PIPE_LEN +1 ] = {0 };long batchsummary[RCU_TORTURE_PIPE_LEN +1 ] = {0 }; +long n_gpwraps =0 ;struct rcu_torture *rtcp;static unsigned long rtcv_snap =ULONG_MAX ;static bool splatted;@@ -2639,6 +2643,7 @@ rcu_torture_stats_print(void) pipesummary[i] +=READ_ONCE (per_cpu (rcu_torture_count, cpu)[i]); batchsummary[i] +=READ_ONCE (per_cpu (rcu_torture_batch, cpu)[i]); } + n_gpwraps +=rcu_get_gpwrap_count (cpu);Quoted 8 lines
kernel/rcu/rcutorture.c rcu_torture_stats_print(void) · line 2678
Quoted 6 lines
kernel/rcu/rcutorture.c +0
-0}for (i =RCU_TORTURE_PIPE_LEN ; i >=0 ; i--) {if (pipesummary[i] !=0 )@@ -2672,6 +2677,7 @@ rcu_torture_stats_print(void)pr_cont ("read-exits: %ld " ,data_race (n_read_exits));// Statistic. pr_cont("nocb-toggles: %ld:%ld\n",The "\n" on the above line needs to be deleted.
Ok.
Quoted 7 lines
Quoted 7 lines
kernel/rcu/rcutorture.c +1
-0atomic_long_read(&n_nocb_offload), atomic_long_read(&n_nocb_deoffload)); +pr_cont ("gpwraps: %ld\n" , n_gpwraps);pr_alert ("%s%s " , torture_type,TORTURE_FLAG ); if (atomic_read(&n_rcu_torture_mberror) ||@@ -3842,6 +3848,58 @@ static int rcu_torture_preempt(void *unused)Quoted 6 lines
kernel/rcu/rcutorture.c static int rcu_torture_preempt(void *unused) · line 3852
Quoted 4 lines
kernel/rcu/rcutorture.c +2
-0static enum cpuhp_state rcutor_hp; +static struct hrtimer ovf_lag_timer; +static bool ovf_lag_active;Same "ovf" naming complaint as before.
Ok.
Quoted 4 lines
Quoted 4 lines
kernel/rcu/rcutorture.c +4
-0+} + +static int rcu_torture_ovf_lag_init (void ) +{Quoted 8 lines
kernel/rcu/rcutorture.c static int rcu_torture_preempt(void *unused) · line 3883
Quoted 4 lines
kernel/rcu/rcutorture.c +4
-0+if (ovf_cycle_mins <=0 || ovf_active_mins <=0 ) { +pr_alert ("rcu-torture: lag timing parameters must be positive\n" ); +return -EINVAL ; + }Why not refuse to start this portion of the test when testing
CONFIG_SMP=nor something other than vanilla RCU? No need to fail the test, just print something saying that this testing won't be happening.Quoted 1 line
Got it, will do.
Again, thank you!
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
kernel/rcu/rcutorture.c +6
-0+static void rcu_torture_ovf_lag_cleanup (void ) +{ +hrtimer_cancel (&ovf_lag_timer); + +if (ovf_lag_active) { +rcu_set_torture_ovf_lag (0 );Quoted 8 lines
kernel/rcu/rcutorture.c static int rcu_torture_preempt(void *unused) · line 3876
Quoted 3 lines
kernel/rcu/rcutorture.c +3
-0+ ovf_lag_active = false; + } +}Did you try the modprobe/rmmod testing to verify that this cleans up appropriately? You could use the drgn tool to check. See tools/rcu//rcu-cbs.py for an example drgn script that digs into the
rcu_datastructures.Quoted 3 lines
Nice, will check!
Will work on this and provide v2.
Looking forward to it!
Thanx, Paul
Joel Fernandes
maintainerHello, Paul,
On Thu, 10 Apr 2025 13:35:35 GMT, "Paul E. McKenney" wrote:
[...]
Quoted 32 lines
Quoted 32 lines
Quoted 31 lines
Quoted 20 lines
kernel/rcu/rcu.h | 4 +++ kernel/rcu/rcutorture.c | 64 ++++++++++++++++++++++++++++++++++++++++ kernel/rcu/tree.c | 34 ++++++++++++++++++++-- kernel/rcu/tree.h | 1 + 4 files changed, 101 insertions(+), 2 deletions(-)kernel/rcu/rcu.h +2
-0@@ -572,6 +572,8 @@ void do_trace_rcu_torture_read(const char *rcutortunsigned long c_old, unsigned long c);void rcu_gp_set_torture_wait (int duration); +void rcu_set_torture_ovf_lag (unsigned long lag); +int rcu_get_gpwrap_count (int cpu);#else static inline void rcutorture_get_gp_data(int *flags, unsigned long * {kernel/rcu/rcu.h void do_trace_rcu_torture_read(const char *rcutort · line 595
Quoted 5 lines
kernel/rcu/rcu.h +2
-0@@ -589,6 +591,8 @@ void do_trace_rcu_torture_read(const char *rcutort do { } while (0)#endif static inline void rcu_gp_set_torture_wait (int duration) { } +static inline void rcu_set_torture_ovf_lag (unsigned long lag) { } +static inline int rcu_get_gpwrap_count (int cpu) {return 0 ; }Very good, you did remember
CONFIG_SMP=n. And yes, I did try it. ;-)But shouldn't these be function pointers in
rcu_torture_ops? That way if some other flavor of RCU starts doing wrap protection for its grace-period sequence numbers, this testing can apply directly to that flavor as well.
Quoted 6 lines
Quoted 3 lines
These are here because 'rdp' is not accessible AFAIK from
rcutorture.c. I could add wrappers to these and include them as pointers the a struct as well. But I think these will still stay to access rdp.Why not just pass in the CPU number and let the pointed-to function find the rdp?
Great, I did this and it looks good now, will post v2 shortly.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
I could argue with the defaults, but I run long tests often enough that I am not worried about coverage. As long as we remember to either run long tests or specify appropriate rcutorture.ovf_cycle_mins when messing with ->gpwrap code.
Quoted 27 lines
Quoted 2 lines
Quoted 2 lines
kernel/rcu/rcu.h void do_trace_rcu_torture_read(const char *rcutort · line 597
Quoted 2 lines
kernel/rcu/rcu.h +0
-0torture_param(int, nocbs_nthreads, 0, "Number of NOCB toggle threads, torture_param(int, nocbs_toggle, 1000, "Time between toggling nocb state (ms)");
Quoted 24 lines
Quoted 14 lines
Quoted 14 lines
kernel/rcu/rcu.h +2
-0torture_param(int, preempt_duration, 0, "Preemption duration (ms), ze@@ -2629,6 +2632,7 @@ rcu_torture_stats_print(void)int i;long pipesummary[RCU_TORTURE_PIPE_LEN +1 ] = {0 };long batchsummary[RCU_TORTURE_PIPE_LEN +1 ] = {0 }; +long n_gpwraps =0 ;struct rcu_torture *rtcp;static unsigned long rtcv_snap =ULONG_MAX ;static bool splatted;@@ -2639,6 +2643,7 @@ rcu_torture_stats_print(void) pipesummary[i] +=READ_ONCE (per_cpu (rcu_torture_count, cpu)[i]); batchsummary[i] +=READ_ONCE (per_cpu (rcu_torture_batch, cpu)[i]); } + n_gpwraps +=rcu_get_gpwrap_count (cpu);Quoted 8 lines
kernel/rcu/rcu.h rcu_torture_stats_print(void) · line 2678
Quoted 6 lines
kernel/rcu/rcu.h +0
-0}for (i =RCU_TORTURE_PIPE_LEN ; i >=0 ; i--) {if (pipesummary[i] !=0 )@@ -2672,6 +2677,7 @@ rcu_torture_stats_print(void)pr_cont ("read-exits: %ld " ,data_race (n_read_exits));// Statistic. pr_cont("nocb-toggles: %ld:%ld\n",The "\n" on the above line needs to be deleted.
Ok.
Done.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
kernel/rcu/rcu.h +1
-0atomic_long_read(&n_nocb_offload), atomic_long_read(&n_nocb_deofflo + pr_cont("gpwraps: %ld\n", n_gpwraps);pr_alert ("%s%s " , torture_type,TORTURE_FLAG ); if (atomic_read(&n_rcu_torture_mberror) ||@@ -3842,6 +3848,58 @@ static int rcu_torture_preempt(void *unused)
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
kernel/rcu/rcu.h static int rcu_torture_preempt(void *unused) · line 3852
Quoted 4 lines
kernel/rcu/rcu.h +2
-0static enum cpuhp_state rcutor_hp; +static struct hrtimer ovf_lag_timer; +static bool ovf_lag_active;Same "ovf" naming complaint as before.
Ok.
Done.
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
kernel/rcu/rcu.h static int rcu_torture_preempt(void *unused) · line 3860
Quoted 9 lines
kernel/rcu/rcu.h +8
-0+} + +static int rcu_torture_ovf_lag_init (void ) +{ +if (ovf_cycle_mins <=0 || ovf_active_mins <=0 ) { +pr_alert ("rcu-torture: lag timing parameters must be positive\n" ); +return -EINVAL ; + }Why not refuse to start this portion of the test when
CONFIG_SMP=n or something other than vanilla RCU? No need to fail the test, just print something saying that this testing won't be happening.
Quoted 3 lines
Quoted 1 line
Got it, will do.
Again, thank you!
I changed this to, something like:
if (cur_ops->set_gpwrap_lag && rcu_gpwrap_lag_init()) goto unwind;
So it will only test RCU flavor.
However, to your point - for TINY, we would still start the timer which will be a NOOP. But considering it is 5 minutes every 30 minutes, maybe that's Ok? ;-) We could also have a ops pointer ->can_test_gpwrap_lag() which returns FALSE for Tiny, but then it is adding more ops pointers.
thanks,
- Joel
Joel Fernandes
maintainerHello, Paul,
On Thu, 10 Apr 2025 13:35:35 GMT, "Paul E. McKenney" wrote:
[...]
Quoted 32 lines
Quoted 32 lines
Quoted 31 lines
Quoted 20 lines
kernel/rcu/rcu.h | 4 +++ kernel/rcu/rcutorture.c | 64 ++++++++++++++++++++++++++++++++++++++++ kernel/rcu/tree.c | 34 ++++++++++++++++++++-- kernel/rcu/tree.h | 1 + 4 files changed, 101 insertions(+), 2 deletions(-)kernel/rcu/rcu.h +2
-0@@ -572,6 +572,8 @@ void do_trace_rcu_torture_read(const char *rcutortunsigned long c_old, unsigned long c);void rcu_gp_set_torture_wait (int duration); +void rcu_set_torture_ovf_lag (unsigned long lag); +int rcu_get_gpwrap_count (int cpu);#else static inline void rcutorture_get_gp_data(int *flags, unsigned long * {kernel/rcu/rcu.h void do_trace_rcu_torture_read(const char *rcutort · line 595
Quoted 5 lines
kernel/rcu/rcu.h +2
-0@@ -589,6 +591,8 @@ void do_trace_rcu_torture_read(const char *rcutort do { } while (0)#endif static inline void rcu_gp_set_torture_wait (int duration) { } +static inline void rcu_set_torture_ovf_lag (unsigned long lag) { } +static inline int rcu_get_gpwrap_count (int cpu) {return 0 ; }Very good, you did remember
CONFIG_SMP=n. And yes, I did try it. ;-)But shouldn't these be function pointers in
rcu_torture_ops? That way if some other flavor of RCU starts doing wrap protection for its grace-period sequence numbers, this testing can apply directly to that flavor as well.
Quoted 6 lines
Quoted 3 lines
These are here because 'rdp' is not accessible AFAIK from
rcutorture.c. I could add wrappers to these and include them as pointers the a struct as well. But I think these will still stay to access rdp.Why not just pass in the CPU number and let the pointed-to function find the rdp?
Great, I did this and it looks good now, will post v2 shortly.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
I could argue with the defaults, but I run long tests often enough that I am not worried about coverage. As long as we remember to either run long tests or specify appropriate rcutorture.ovf_cycle_mins when messing with ->gpwrap code.
Quoted 27 lines
Quoted 2 lines
Quoted 2 lines
kernel/rcu/rcu.h void do_trace_rcu_torture_read(const char *rcutort · line 597
Quoted 2 lines
kernel/rcu/rcu.h +0
-0torture_param(int, nocbs_nthreads, 0, "Number of NOCB toggle threads, torture_param(int, nocbs_toggle, 1000, "Time between toggling nocb state (ms)");
Quoted 24 lines
Quoted 14 lines
Quoted 14 lines
kernel/rcu/rcu.h +2
-0torture_param(int, preempt_duration, 0, "Preemption duration (ms), ze@@ -2629,6 +2632,7 @@ rcu_torture_stats_print(void)int i;long pipesummary[RCU_TORTURE_PIPE_LEN +1 ] = {0 };long batchsummary[RCU_TORTURE_PIPE_LEN +1 ] = {0 }; +long n_gpwraps =0 ;struct rcu_torture *rtcp;static unsigned long rtcv_snap =ULONG_MAX ;static bool splatted;@@ -2639,6 +2643,7 @@ rcu_torture_stats_print(void) pipesummary[i] +=READ_ONCE (per_cpu (rcu_torture_count, cpu)[i]); batchsummary[i] +=READ_ONCE (per_cpu (rcu_torture_batch, cpu)[i]); } + n_gpwraps +=rcu_get_gpwrap_count (cpu);Quoted 8 lines
kernel/rcu/rcu.h rcu_torture_stats_print(void) · line 2678
Quoted 6 lines
kernel/rcu/rcu.h +0
-0}for (i =RCU_TORTURE_PIPE_LEN ; i >=0 ; i--) {if (pipesummary[i] !=0 )@@ -2672,6 +2677,7 @@ rcu_torture_stats_print(void)pr_cont ("read-exits: %ld " ,data_race (n_read_exits));// Statistic. pr_cont("nocb-toggles: %ld:%ld\n",The "\n" on the above line needs to be deleted.
Ok.
Done.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
kernel/rcu/rcu.h +1
-0atomic_long_read(&n_nocb_offload), atomic_long_read(&n_nocb_deofflo + pr_cont("gpwraps: %ld\n", n_gpwraps);pr_alert ("%s%s " , torture_type,TORTURE_FLAG ); if (atomic_read(&n_rcu_torture_mberror) ||@@ -3842,6 +3848,58 @@ static int rcu_torture_preempt(void *unused)
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
kernel/rcu/rcu.h static int rcu_torture_preempt(void *unused) · line 3852
Quoted 4 lines
kernel/rcu/rcu.h +2
-0static enum cpuhp_state rcutor_hp; +static struct hrtimer ovf_lag_timer; +static bool ovf_lag_active;Same "ovf" naming complaint as before.
Ok.
Done.
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
kernel/rcu/rcu.h static int rcu_torture_preempt(void *unused) · line 3860
Quoted 9 lines
kernel/rcu/rcu.h +8
-0+} + +static int rcu_torture_ovf_lag_init (void ) +{ +if (ovf_cycle_mins <=0 || ovf_active_mins <=0 ) { +pr_alert ("rcu-torture: lag timing parameters must be positive\n" ); +return -EINVAL ; + }Why not refuse to start this portion of the test when
CONFIG_SMP=n or something other than vanilla RCU? No need to fail the test, just print something saying that this testing won't be happening.
Quoted 3 lines
Quoted 1 line
Got it, will do.
Again, thank you!
I changed this to, something like:
if (cur_ops->set_gpwrap_lag && rcu_gpwrap_lag_init()) goto unwind;
So it will only test RCU flavor.
However, to your point - for TINY, we would still start the timer which will be a NOOP. But considering it is 5 minutes every 30 minutes, maybe that's Ok? ;-) We could also have a ops pointer ->can_test_gpwrap_lag() which returns FALSE for Tiny, but then it is adding more ops pointers.
thanks,
- Joel