Torture-test updates
Subsystems (6)
Paul E. McKenney
maintainercover Torture-test updates
Hello!
This series contains torture-test updates:
1. Add get_torture_init_jiffies() for test-start time.
2. Add a test_boost_holdoff module parameter.
3. Include grace-period sequence numbers in failure/close-call.
4. Expand failure/close-call grace-period output.
5. Trace expedited grace-period numbers in hexadecimal.
6. Add ftrace-compatible timestamp to GP# failure/close-call output.
7. Make cur_ops->format_gp_seqs take buffer length.
8. Move RCU_TORTURE_TEST_{CHK_RDR_STATE,LOG_CPU} to bool.
9. Complain when invalid SRCU reader_flavor is specified.
10. Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing.
11. Make SRCU lockdep testing use srcu_read_lock_nmisafe().
Thanx, Paul
------------------------------------------------------------------------
b/Documentation/admin-guide/kernel-parameters.txt | 5 + b/include/linux/torture.h | 1 b/include/trace/events/rcu.h | 2 b/kernel/rcu/Kconfig | 11 ++ b/kernel/rcu/Kconfig.debug | 14 +++ b/kernel/rcu/rcu.h | 2 b/kernel/rcu/rcutorture.c | 19 +++- b/kernel/rcu/tiny.c | 14 +++ b/kernel/rcu/tree.c | 20 ++++ b/kernel/torture.c | 12 ++ b/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh | 2 kernel/rcu/Kconfig.debug | 4 kernel/rcu/rcu.h | 6 - kernel/rcu/rcutorture.c | 64 ++++++++++++--- kernel/rcu/tiny.c | 12 +- kernel/rcu/tree.c | 22 ++--- 16 files changed, 173 insertions(+), 37 deletions(-)
Paul E. McKenney
maintainerPATCH 1/11 torture: Add get_torture_init_jiffies() for test-start time
This commit adds a get_torture_init_jiffies() function that returns the value of the jiffies counter at the start of the test, that is, at the point where torture_init_begin() was invoked.
This will be used to enable torture-test holdoffs for tests implemented using per-CPU kthreads, which are created and deleted by CPU-hotplug operations, and thus (unlike normal kthreads) don't automatically know when the test started.
--- include/linux/torture.h | 1 + kernel/torture.c | 12 ++++++++++++ 2 files changed, 13 insertions(+)
include/linux/torture.h +1 -0
@@ -104,6 +104,7 @@ int torture_stutter_init(int s, int sgap);/* Initialization and cleanup. */ bool torture_init_begin (char *ttype,int v);void torture_init_end (void ); +unsigned long get_torture_init_jiffies (void );bool torture_cleanup_begin (void );void torture_cleanup_end (void );bool torture_must_stop (void );
kernel/torture.c +12 -0
@@ -792,6 +792,8 @@ static void torture_stutter_cleanup(void) stutter_task =NULL ; } +static unsigned long torture_init_jiffies; +static void torture_print_module_parms (void ) {
@@ -821,6 +823,7 @@ bool torture_init_begin(char *ttype, int v) torture_type = ttype; verbose = v; fullstop =FULLSTOP_DONTSTOP ; +WRITE_ONCE (torture_init_jiffies, jiffies);// Lockless reads. torture_print_module_parms ();return true; }
@@ -836,6 +839,15 @@ void torture_init_end(void) }EXPORT_SYMBOL_GPL (torture_init_end); +/* +* Get the torture_init_begin()-time value of the jiffies counter. +*/ +unsigned long get_torture_init_jiffies (void ) +{ +return READ_ONCE (torture_init_jiffies); +} +EXPORT_SYMBOL_GPL (get_torture_init_jiffies); +/* * Clean up torture module. Please note that this is -not- invoked via * the usual module_exit() mechanism, but rather by an explicit call from
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerPATCH 2/11 rcutorture: Add a test_boost_holdoff module parameter
In reply to Paul E. McKenneyThis commit adds a test_boost_holdoff module parameter that tells the RCU priority-boosting tests to wait for the specified number of seconds past the start of the rcutorture test. This can be useful when rcutorture is built into the kernel (as opposed to being modprobed), especially on large systems where early start of RCU priority boosting can delay the boot sequence, which adds a full CPU's worth of load onto the system. This can in turn result in pointless stall warnings.
--- .../admin-guide/kernel-parameters.txt | 5 +++++ kernel/rcu/rcutorture.c | 19 ++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +5 -0
@@ -5592,6 +5592,11 @@ rcutorture.test_boost_duration= [KNL] Duration (s) of each individual boost test. + rcutorture.test_boost_holdoff= [KNL] + Holdoff time (s) from start of test to the start + of RCU priority-boost testing. Defaults to zero, + that is, no holdoff. + rcutorture.test_boost_interval= [KNL] Interval (s) between each boost test.
kernel/rcu/rcutorture.c +16 -3
@@ -135,6 +135,7 @@ torture_param(int, stat_interval, 60, "Number of seconds between stats printk()storture_param (int, stutter,5 ,"Number of seconds to run/halt test" );torture_param (int, test_boost,1 ,"Test RCU prio boost: 0=no, 1=maybe, 2=yes." );torture_param (int, test_boost_duration,4 ,"Duration of each boost test, seconds." ); +torture_param (int, test_boost_holdoff,0 ,"Holdoff time from rcutorture start, seconds." );torture_param (int, test_boost_interval,7 ,"Interval between boost tests, seconds." );torture_param (int, test_nmis,0 ,"End-test NMI tests, 0 to disable." );torture_param (bool, test_no_idle_hz, true,"Test support for tickless idle CPUs" );
@@ -1159,8 +1160,19 @@ static int rcu_torture_boost(void *arg)unsigned long gp_state;unsigned long gp_state_time;unsigned long oldstarttime; +unsigned long booststarttime =get_torture_init_jiffies () + test_boost_holdoff *HZ ; -VERBOSE_TOROUT_STRING ("rcu_torture_boost started" ); +if (test_boost_holdoff <=0 ||time_after (jiffies, booststarttime)) { +VERBOSE_TOROUT_STRING ("rcu_torture_boost started" ); + }else { +VERBOSE_TOROUT_STRING ("rcu_torture_boost started holdoff period" ); +while (time_before (jiffies, booststarttime)) { +schedule_timeout_idle (HZ ); +if (kthread_should_stop ()) + goto cleanup; + } +VERBOSE_TOROUT_STRING ("rcu_torture_boost finished holdoff period" ); + }/* Set real-time priority. */ sched_set_fifo_low (current);
@@ -1236,6 +1248,7 @@ checkwait: if (stutter_wait("rcu_torture_boost"))sched_set_fifo_low (current); }while (!torture_must_stop ()); +cleanup:/* Clean up and exit. */ while (!kthread_should_stop ()) {torture_shutdown_absorb ("rcu_torture_boost" );
@@ -2523,7 +2536,7 @@ rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, const char *tag)"shuffle_interval=%d stutter=%d irqreader=%d " "fqs_duration=%d fqs_holdoff=%d fqs_stutter=%d " "test_boost=%d/%d test_boost_interval=%d " -"test_boost_duration=%d shutdown_secs=%d " +"test_boost_duration=%d test_boost_holdoff=%d shutdown_secs=%d " "stall_cpu=%d stall_cpu_holdoff=%d stall_cpu_irqsoff=%d " "stall_cpu_block=%d stall_cpu_repeat=%d " "n_barrier_cbs=%d "
@@ -2537,7 +2550,7 @@ rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, const char *tag) stat_interval, verbose, test_no_idle_hz, shuffle_interval, stutter, irqreader, fqs_duration, fqs_holdoff, fqs_stutter, test_boost, cur_ops->can_boost, - test_boost_interval, test_boost_duration, shutdown_secs, + test_boost_interval, test_boost_duration, test_boost_holdoff, shutdown_secs, stall_cpu, stall_cpu_holdoff, stall_cpu_irqsoff, stall_cpu_block, stall_cpu_repeat, n_barrier_cbs,
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerPATCH 3/11 rcutorture: Include grace-period sequence numbers in failure/close-call
In reply to Paul E. McKenneyThis commit includes the grace-period sequence numbers at the beginning and end of each segment in the "Failure/close-call rcutorture reader segments" list. These are in hexadecimal, and only the bottom byte. Currently, only RCU is supported, with its three sequence numbers (normal, expedited, and polled).
Note that if all the grace-period sequence numbers remain the same across a given reader segement, only one copy of the number will be printed. Of course, if there is a change, both sets of values will be printed.
Because the overhead of collecting this information can suppress heisenbugs, this information is collected and printed only in kernels built with CONFIG_RCU_TORTURE_TEST_LOG_GP=y.
[ paulmck: Apply Nathan Chancellor feedback for IS_ENABLED(). ] [ paulmck: Apply feedback from kernel test robot. ]
--- kernel/rcu/Kconfig.debug | 14 ++++++++++++++ kernel/rcu/rcu.h | 2 ++ kernel/rcu/rcutorture.c | 34 ++++++++++++++++++++++++++++++++++ kernel/rcu/tiny.c | 14 ++++++++++++++ kernel/rcu/tree.c | 20 ++++++++++++++++++++ 5 files changed, 84 insertions(+)
kernel/rcu/Kconfig.debug +14 -0
@@ -84,6 +84,20 @@ config RCU_TORTURE_TEST_LOG_CPU Say Y here if you want CPU IDs logged. Say N if you are unsure. +config RCU_TORTURE_TEST_LOG_GP + bool "Log grace-period numbers for rcutorture failures" + depends on RCU_TORTURE_TEST + default n + help + This option causes rcutorture to decorate each entry of its + log of failure/close-call rcutorture reader segments with the + corresponding grace-period sequence numbers. This information + can be useful, but it does incur additional overhead, overhead + that can make both failures and close calls less probable. + + Say Y here if you want grace-period sequence numbers logged. + Say N if you are unsure. + config RCU_REF_SCALE_TEST tristate "Scalability tests for read-side synchronization (RCU and others)" depends on DEBUG_KERNEL
kernel/rcu/rcu.h +2 -0
@@ -590,6 +590,8 @@ void do_trace_rcu_torture_read(const char *rcutorturename,#endif static inline void rcu_gp_set_torture_wait (int duration) { }#endif +unsigned long rcutorture_gather_gp_seqs (void ); +void rcutorture_format_gp_seqs (unsigned long seqs,char *cp);#ifdef CONFIG_TINY_SRCU
kernel/rcu/rcutorture.c +34 -0
@@ -273,6 +273,8 @@ struct rt_read_seg {bool rt_preempted;int rt_cpu;int rt_end_cpu; +unsigned long rt_gp_seq; +unsigned long rt_gp_seq_end; };static int err_segs_recorded;static struct rt_read_seg err_segs[RCUTORTURE_RDR_MAX_SEGS ];
@@ -407,6 +409,8 @@ struct rcu_torture_ops {void (*gp_slow_register)(atomic_t *rgssp);void (*gp_slow_unregister)(atomic_t *rgssp);bool (*reader_blocked)(void ); +unsigned long (*gather_gp_seqs)(void ); +void (*format_gp_seqs)(unsigned long seqs,char *cp);long cbflood_max;int irq_capable;int can_boost;
@@ -611,6 +615,8 @@ static struct rcu_torture_ops rcu_ops = { .reader_blocked = IS_ENABLED(CONFIG_RCU_TORTURE_TEST_LOG_CPU) ? has_rcu_reader_blocked : NULL, + .gather_gp_seqs = rcutorture_gather_gp_seqs, + .format_gp_seqs = rcutorture_format_gp_seqs, .irq_capable = 1, .can_boost = IS_ENABLED(CONFIG_RCU_BOOST), .extendables = RCUTORTURE_MAX_EXTEND,
@@ -656,6 +662,8 @@ static struct rcu_torture_ops rcu_busted_ops = { .sync = synchronize_rcu_busted, .exp_sync = synchronize_rcu_busted, .call = call_rcu_busted, + .gather_gp_seqs = rcutorture_gather_gp_seqs, + .format_gp_seqs = rcutorture_format_gp_seqs, .irq_capable = 1, .extendables =RCUTORTURE_MAX_EXTEND , .name = "busted"
@@ -1989,6 +1997,12 @@ static void rcutorture_one_extend(int *readstate, int newstate, bool insoftirq, rtrsp[-1 ].rt_preempted = cur_ops->reader_blocked (); } } +// Sample grace-period sequence number, as good a place as any. +if (IS_ENABLED (CONFIG_RCU_TORTURE_TEST_LOG_GP ) && cur_ops->gather_gp_seqs) { + rtrsp->rt_gp_seq = cur_ops->gather_gp_seqs (); +if (!first) + rtrsp[-1 ].rt_gp_seq_end = rtrsp->rt_gp_seq; + }/* * Next, remove old protection, in decreasing order of strength
@@ -3577,6 +3591,7 @@ rcu_torture_cleanup(void)int flags =0 ;unsigned long gp_seq =0 ;int i; +int j;if (torture_cleanup_begin ()) {if (cur_ops->cb_barrier !=NULL ) {
@@ -3672,6 +3687,25 @@ rcu_torture_cleanup(void)else pr_cont (" ..." ); } +if (IS_ENABLED (CONFIG_RCU_TORTURE_TEST_LOG_GP ) && + cur_ops->gather_gp_seqs && cur_ops->format_gp_seqs) { +char buf1[16 +1 ]; +char buf2[16 +1 ]; +char sepchar ='-' ; + + cur_ops->format_gp_seqs (err_segs[i].rt_gp_seq, buf1); + cur_ops->format_gp_seqs (err_segs[i].rt_gp_seq_end, buf2); +if (err_segs[i].rt_gp_seq == err_segs[i].rt_gp_seq_end) { +if (buf2[0 ]) { +for (j =0 ; buf2[j]; j++) + buf2[j] ='.' ; +if (j) + buf2[j -1 ] =' ' ; + } + sepchar =' ' ; + } +pr_cont (" %s%c%s" , buf1, sepchar, buf2); + }if (err_segs[i].rt_delay_ms !=0 ) {pr_cont (" %s%ldms" , firsttime ?"" :"+" , err_segs[i].rt_delay_ms);
kernel/rcu/tiny.c +14 -0
@@ -257,6 +257,20 @@ void kvfree_call_rcu(struct rcu_head *head, void *ptr)EXPORT_SYMBOL_GPL (kvfree_call_rcu);#endif +#if IS_ENABLED (CONFIG_RCU_TORTURE_TEST ) +unsigned long rcutorture_gather_gp_seqs (void ) +{ +return READ_ONCE (rcu_ctrlblk.gp_seq) &0xff ; +} +EXPORT_SYMBOL_GPL (rcutorture_gather_gp_seqs); + +void rcutorture_format_gp_seqs (unsigned long seqs,char *cp) +{ +snprintf (cp,8 ,"g%02lx" , seqs &0xff ); +} +EXPORT_SYMBOL_GPL (rcutorture_format_gp_seqs); +#endif +void __init rcu_init (void ) {open_softirq (RCU_SOFTIRQ , rcu_process_callbacks);
kernel/rcu/tree.c +20 -0
@@ -559,6 +559,26 @@ void rcutorture_get_gp_data(int *flags, unsigned long *gp_seq) }EXPORT_SYMBOL_GPL (rcutorture_get_gp_data); +/* Gather grace-period sequence numbers for rcutorture diagnostics. */ +unsigned long rcutorture_gather_gp_seqs (void ) +{ +return ((READ_ONCE (rcu_state.gp_seq) &0xff ) <<16 ) | + ((READ_ONCE (rcu_state.expedited_sequence) &0xff ) <<8 ) | + (READ_ONCE (rcu_state.gp_seq_polled) &0xff ); +} +EXPORT_SYMBOL_GPL (rcutorture_gather_gp_seqs); + +/* Format grace-period sequence numbers for rcutorture diagnostics. */ +void rcutorture_format_gp_seqs (unsigned long seqs,char *cp) +{ +unsigned int egp = (seqs >>8 ) &0xff ; +unsigned int ggp = (seqs >>16 ) &0xff ; +unsigned int pgp = seqs &0xff ; + +snprintf (cp,16 ,"g%02x:e%02x:p%02x" , ggp, egp, pgp); +} +EXPORT_SYMBOL_GPL (rcutorture_format_gp_seqs); +#if defined(CONFIG_NO_HZ_FULL ) && (!defined(CONFIG_GENERIC_ENTRY ) || !defined(CONFIG_KVM_XFER_TO_GUEST_WORK ))/* * An empty function that will trigger a reschedule on
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerPATCH 4/11 rcutorture: Expand failure/close-call grace-period output
In reply to Paul E. McKenneyWith only eight bits per grace-period sequence number, wrap can happen in 64 grace periods. This commit therefore increases this to sixteen bits for normal grace-period sequence numbers and the combined short-form polling sequence numbers, thus deferring wrap for at least 16,384 grace periods. Because expedited grace periods go faster, expand these to 24 bits, deferring wrap for at least 4,194,304 expedited grace periods. These longer wrap times makes it easier to correlate these numbers to trace-event output.
Note that the low-order two bits are reserved for intra-grace-period state, hence the above wrap numbers being a factor of four smaller than you might expect.
--- kernel/rcu/rcu.h | 4 ++-- kernel/rcu/rcutorture.c | 12 ++++++------ kernel/rcu/tiny.c | 8 ++++---- kernel/rcu/tree.c | 18 +++++++++--------- 4 files changed, 21 insertions(+), 21 deletions(-)
kernel/rcu/rcu.h +2 -2
@@ -590,8 +590,8 @@ void do_trace_rcu_torture_read(const char *rcutorturename,#endif static inline void rcu_gp_set_torture_wait (int duration) { }#endif -unsigned long rcutorture_gather_gp_seqs (void ); -void rcutorture_format_gp_seqs (unsigned long seqs,char *cp); +unsigned long long rcutorture_gather_gp_seqs (void ); +void rcutorture_format_gp_seqs (unsigned long long seqs,char *cp);#ifdef CONFIG_TINY_SRCU
kernel/rcu/rcutorture.c +6 -6
@@ -273,8 +273,8 @@ struct rt_read_seg {bool rt_preempted;int rt_cpu;int rt_end_cpu; -unsigned long rt_gp_seq; -unsigned long rt_gp_seq_end; +unsigned long long rt_gp_seq; +unsigned long long rt_gp_seq_end; };static int err_segs_recorded;static struct rt_read_seg err_segs[RCUTORTURE_RDR_MAX_SEGS ];
@@ -409,8 +409,8 @@ struct rcu_torture_ops {void (*gp_slow_register)(atomic_t *rgssp);void (*gp_slow_unregister)(atomic_t *rgssp);bool (*reader_blocked)(void ); -unsigned long (*gather_gp_seqs)(void ); -void (*format_gp_seqs)(unsigned long seqs,char *cp); +unsigned long long (*gather_gp_seqs)(void ); +void (*format_gp_seqs)(unsigned long long seqs,char *cp);long cbflood_max;int irq_capable;int can_boost;
@@ -3689,8 +3689,8 @@ rcu_torture_cleanup(void) }if (IS_ENABLED (CONFIG_RCU_TORTURE_TEST_LOG_GP ) && cur_ops->gather_gp_seqs && cur_ops->format_gp_seqs) { -char buf1[16 +1 ]; -char buf2[16 +1 ]; +char buf1[20 +1 ]; +char buf2[20 +1 ];char sepchar ='-' ; cur_ops->format_gp_seqs (err_segs[i].rt_gp_seq, buf1);
kernel/rcu/tiny.c +4 -4
@@ -258,15 +258,15 @@ EXPORT_SYMBOL_GPL(kvfree_call_rcu);#endif #if IS_ENABLED (CONFIG_RCU_TORTURE_TEST ) -unsigned long rcutorture_gather_gp_seqs (void ) +unsigned long long rcutorture_gather_gp_seqs (void ) { -return READ_ONCE (rcu_ctrlblk.gp_seq) &0xff ; +return READ_ONCE (rcu_ctrlblk.gp_seq) &0xffffULL ; }EXPORT_SYMBOL_GPL (rcutorture_gather_gp_seqs); -void rcutorture_format_gp_seqs (unsigned long seqs,char *cp) +void rcutorture_format_gp_seqs (unsigned long long seqs,char *cp) { -snprintf (cp,8 ,"g%02lx" , seqs &0xff ); +snprintf (cp,8 ,"g%04llx" , seqs &0xffffULL ); }EXPORT_SYMBOL_GPL (rcutorture_format_gp_seqs);#endif
kernel/rcu/tree.c +9 -9
@@ -560,22 +560,22 @@ void rcutorture_get_gp_data(int *flags, unsigned long *gp_seq)EXPORT_SYMBOL_GPL (rcutorture_get_gp_data);/* Gather grace-period sequence numbers for rcutorture diagnostics. */ -unsigned long rcutorture_gather_gp_seqs (void ) +unsigned long long rcutorture_gather_gp_seqs (void ) { -return ((READ_ONCE (rcu_state.gp_seq) &0xff ) <<16 ) | - ((READ_ONCE (rcu_state.expedited_sequence) &0xff ) <<8 ) | - (READ_ONCE (rcu_state.gp_seq_polled) &0xff ); +return ((READ_ONCE (rcu_state.gp_seq) &0xffffULL ) <<40 ) | + ((READ_ONCE (rcu_state.expedited_sequence) &0xffffffULL ) <<16 ) | + (READ_ONCE (rcu_state.gp_seq_polled) &0xffffULL ); }EXPORT_SYMBOL_GPL (rcutorture_gather_gp_seqs);/* Format grace-period sequence numbers for rcutorture diagnostics. */ -void rcutorture_format_gp_seqs (unsigned long seqs,char *cp) +void rcutorture_format_gp_seqs (unsigned long long seqs,char *cp) { -unsigned int egp = (seqs >>8 ) &0xff ; -unsigned int ggp = (seqs >>16 ) &0xff ; -unsigned int pgp = seqs &0xff ; +unsigned int egp = (seqs >>16 ) &0xffffffULL ; +unsigned int ggp = (seqs >>40 ) &0xffffULL ; +unsigned int pgp = seqs &0xffffULL ; -snprintf (cp,16 ,"g%02x:e%02x:p%02x" , ggp, egp, pgp); +snprintf (cp,20 ,"g%04x:e%06x:p%04x" , ggp, egp, pgp); }EXPORT_SYMBOL_GPL (rcutorture_format_gp_seqs);
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerPATCH 5/11 rcu: Trace expedited grace-period numbers in hexadecimal
In reply to Paul E. McKenneyThis commit reformats the expedited grace-period numbers into hexadecimal for easier decoding and comparison. The normal grace-period numbers remain in decimal for the time being.
--- include/trace/events/rcu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/trace/events/rcu.h +1 -1
@@ -207,7 +207,7 @@ TRACE_EVENT_RCU(rcu_exp_grace_period, __entry->gpevent = gpevent; ), -TP_printk ("%s %ld %s" , +TP_printk ("%s %#lx %s" , __entry->rcuname, __entry->gpseq, __entry->gpevent) );
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerPATCH 6/11 rcutorture: Add ftrace-compatible timestamp to GP# failure/close-call output
In reply to Paul E. McKenneyThis commit adds an ftrace-compatible microsecond-scale timestamp to the failure/close-call output, but only in kernels built with CONFIG_RCU_TORTURE_TEST_LOG_GP=y.
--- kernel/rcu/rcutorture.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
kernel/rcu/rcutorture.c +7 -1
@@ -275,6 +275,7 @@ struct rt_read_seg {int rt_end_cpu;unsigned long long rt_gp_seq;unsigned long long rt_gp_seq_end; +u64 rt_ts; };static int err_segs_recorded;static struct rt_read_seg err_segs[RCUTORTURE_RDR_MAX_SEGS ];
@@ -2000,6 +2001,7 @@ static void rcutorture_one_extend(int *readstate, int newstate, bool insoftirq,// Sample grace-period sequence number, as good a place as any. if (IS_ENABLED (CONFIG_RCU_TORTURE_TEST_LOG_GP ) && cur_ops->gather_gp_seqs) { rtrsp->rt_gp_seq = cur_ops->gather_gp_seqs (); + rtrsp->rt_ts =ktime_get_mono_fast_ns ();if (!first) rtrsp[-1 ].rt_gp_seq_end = rtrsp->rt_gp_seq; }
@@ -3674,7 +3676,11 @@ rcu_torture_cleanup(void)pr_alert ("\t: No segments recorded!!!\n" ); firsttime =1 ;for (i =0 ; i < rt_read_nsegs; i++) { -pr_alert ("\t%d: %#4x" , i, err_segs[i].rt_readstate); +if (IS_ENABLED (CONFIG_RCU_TORTURE_TEST_LOG_GP )) +pr_alert ("\t%lluus " ,div64_u64 (err_segs[i].rt_ts,1000ULL )); +else +pr_alert ("\t" ); +pr_cont ("%d: %#4x" , i, err_segs[i].rt_readstate);if (err_segs[i].rt_delay_jiffies !=0 ) {pr_cont ("%s%ldjiffies" , firsttime ?"" :"+" , err_segs[i].rt_delay_jiffies);
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerPATCH 7/11 rcutorture: Make cur_ops->format_gp_seqs take buffer length
In reply to Paul E. McKenneyThe Tree and Tiny implementations of rcutorture_format_gp_seqs() use hard-coded constants for the length of the buffer that they format into. This is of course an accident waiting to happen, so this commit therefore makes them take a length argument. The rcutorture calling code uses ARRAY_SIZE() to safely compute this new argument.
--- kernel/rcu/rcu.h | 2 +- kernel/rcu/rcutorture.c | 8 +++++--- kernel/rcu/tiny.c | 4 ++-- kernel/rcu/tree.c | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-)
kernel/rcu/rcu.h +1 -1
@@ -591,7 +591,7 @@ void do_trace_rcu_torture_read(const char *rcutorturename,static inline void rcu_gp_set_torture_wait (int duration) { }#endif unsigned long long rcutorture_gather_gp_seqs (void ); -void rcutorture_format_gp_seqs (unsigned long long seqs,char *cp); +void rcutorture_format_gp_seqs (unsigned long long seqs,char *cp,size_t len);#ifdef CONFIG_TINY_SRCU
kernel/rcu/rcutorture.c +5 -3
@@ -411,7 +411,7 @@ struct rcu_torture_ops {void (*gp_slow_unregister)(atomic_t *rgssp);bool (*reader_blocked)(void );unsigned long long (*gather_gp_seqs)(void ); -void (*format_gp_seqs)(unsigned long long seqs,char *cp); +void (*format_gp_seqs)(unsigned long long seqs,char *cp,size_t len);long cbflood_max;int irq_capable;int can_boost;
@@ -3699,8 +3699,10 @@ rcu_torture_cleanup(void)char buf2[20 +1 ];char sepchar ='-' ; - cur_ops->format_gp_seqs (err_segs[i].rt_gp_seq, buf1); - cur_ops->format_gp_seqs (err_segs[i].rt_gp_seq_end, buf2); + cur_ops->format_gp_seqs (err_segs[i].rt_gp_seq, + buf1,ARRAY_SIZE (buf1)); + cur_ops->format_gp_seqs (err_segs[i].rt_gp_seq_end, + buf2,ARRAY_SIZE (buf2));if (err_segs[i].rt_gp_seq == err_segs[i].rt_gp_seq_end) {if (buf2[0 ]) {for (j =0 ; buf2[j]; j++)
kernel/rcu/tiny.c +2 -2
@@ -264,9 +264,9 @@ unsigned long long rcutorture_gather_gp_seqs(void) }EXPORT_SYMBOL_GPL (rcutorture_gather_gp_seqs); -void rcutorture_format_gp_seqs (unsigned long long seqs,char *cp) +void rcutorture_format_gp_seqs (unsigned long long seqs,char *cp,size_t len) { -snprintf (cp,8 ,"g%04llx" , seqs &0xffffULL ); +snprintf (cp, len,"g%04llx" , seqs &0xffffULL ); }EXPORT_SYMBOL_GPL (rcutorture_format_gp_seqs);#endif
kernel/rcu/tree.c +2 -2
@@ -569,13 +569,13 @@ unsigned long long rcutorture_gather_gp_seqs(void)EXPORT_SYMBOL_GPL (rcutorture_gather_gp_seqs);/* Format grace-period sequence numbers for rcutorture diagnostics. */ -void rcutorture_format_gp_seqs (unsigned long long seqs,char *cp) +void rcutorture_format_gp_seqs (unsigned long long seqs,char *cp,size_t len) {unsigned int egp = (seqs >>16 ) &0xffffffULL ;unsigned int ggp = (seqs >>40 ) &0xffffULL ;unsigned int pgp = seqs &0xffffULL ; -snprintf (cp,20 ,"g%04x:e%06x:p%04x" , ggp, egp, pgp); +snprintf (cp, len,"g%04x:e%06x:p%04x" , ggp, egp, pgp); }EXPORT_SYMBOL_GPL (rcutorture_format_gp_seqs);
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerPATCH 8/11 rcutorture: Move RCU_TORTURE_TEST_{CHK_RDR_STATE,LOG_CPU} to bool
In reply to Paul E. McKenneyThe RCU_TORTURE_TEST_CHK_RDR_STATE and RCU_TORTURE_TEST_LOG_CPU Kconfig options are pointlessly defined as tristate. This commit therefore converts them to bool.
--- kernel/rcu/Kconfig.debug | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/Kconfig.debug +2 -2
@@ -54,7 +54,7 @@ config RCU_TORTURE_TEST Say N if you are unsure. config RCU_TORTURE_TEST_CHK_RDR_STATE - tristate "Check rcutorture reader state" + bool "Check rcutorture reader state" depends on RCU_TORTURE_TEST default n help
@@ -70,7 +70,7 @@ config RCU_TORTURE_TEST_CHK_RDR_STATE Say N if you are unsure. config RCU_TORTURE_TEST_LOG_CPU - tristate "Log CPU for rcutorture failures" + bool "Log CPU for rcutorture failures" depends on RCU_TORTURE_TEST default n help
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerPATCH 9/11 rcutorture: Complain when invalid SRCU reader_flavor is specified
In reply to Paul E. McKenneyCurrently, rcutorture ignores reader_flavor bits that are not in the SRCU_READ_FLAVOR_ALL bitmask, which could confuse rcutorture users into believing buggy patches had been fully tested. This commit therefore produces a splat in this case.
--- kernel/rcu/rcutorture.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/rcu/rcutorture.c +2 -0
@@ -690,6 +690,8 @@ static int srcu_torture_read_lock(void)struct srcu_ctr __percpu *scp;int ret =0 ; +WARN_ON_ONCE (reader_flavor & ~SRCU_READ_FLAVOR_ALL ); +if ((reader_flavor &SRCU_READ_FLAVOR_NORMAL ) || !(reader_flavor &SRCU_READ_FLAVOR_ALL )) { idx =srcu_read_lock (srcu_ctlp);WARN_ON_ONCE (idx & ~0x1 );
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerPATCH 10/11 srcu: Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing
In reply to Paul E. McKenneyThe srcu_read_lock_nmisafe() and srcu_read_unlock_nmisafe() functions map to __srcu_read_lock() and __srcu_read_unlock() on systems like x86 that have NMI-safe this_cpu_inc() operations. This makes the underlying __srcu_read_lock_nmisafe() and __srcu_read_unlock_nmisafe() functions difficult to test on (for example) x86 systems, allowing bugs to creep in.
This commit therefore creates a FORCE_NEED_SRCU_NMI_SAFE Kconfig that forces those underlying functions to be used even on systems where they are not needed, thus providing better testing coverage.
--- kernel/rcu/Kconfig | 11 +++++++++++ 1 file changed, 11 insertions(+)
kernel/rcu/Kconfig +11 -0
@@ -65,6 +65,17 @@ config TREE_SRCU help This option selects the full-fledged version of SRCU. +config FORCE_NEED_SRCU_NMI_SAFE + bool "Force selection of NEED_SRCU_NMI_SAFE" + depends on !TINY_SRCU + select NEED_SRCU_NMI_SAFE + default n + help + This option forces selection of the NEED_SRCU_NMI_SAFE + Kconfig option, allowing testing of srcu_read_lock_nmisafe() + and srcu_read_unlock_nmisafe() on architectures (like x86) + that select the ARCH_HAS_NMI_SAFE_THIS_CPU_OPS Kconfig option. + config NEED_SRCU_NMI_SAFE def_bool HAVE_NMI && !ARCH_HAS_NMI_SAFE_THIS_CPU_OPS && !TINY_SRCU
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerPATCH 11/11 torture: Make SRCU lockdep testing use srcu_read_lock_nmisafe()
In reply to Paul E. McKenneyRecent experience shows that the srcu_read_lock_nmisafe() and srcu_read_unlock_nmisafe() functions are not sufficiently tested. This commit therefore causes the torture.sh script's SRCU lockdep testing to use these two functions. This will cause these two functions to be regularly tested by several developers (myself included) who use torture.sh as an RCU acceptance test.
--- tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh +1 -1
@@ -49,7 +49,7 @@ do do err= val=$((d*1000+t*10+c)) - tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 5s --configs "SRCU-P" --bootargs "rcutorture.test_srcu_lockdep=$val" --trust-make --datestamp "$ds/$val" > "$T/kvm.sh.out" 2>&1 + tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 5s --configs "SRCU-P" --kconfig "CONFIG_FORCE_NEED_SRCU_NMI_SAFE=y" --bootargs "rcutorture.test_srcu_lockdep=$val rcutorture.reader_flavor=0x2" --trust-make --datestamp "$ds/$val" > "$T/kvm.sh.out" 2>&1 ret=$? mv "$T/kvm.sh.out" "$RCUTORTURE/res/$ds/$val" if test "$d" -ne 0 && test "$ret" -eq 0
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerHello!
This series contains torture-test updates:
1. Add get_torture_init_jiffies() for test-start time.
2. Add a test_boost_holdoff module parameter.
3. Include grace-period sequence numbers in failure/close-call.
4. Expand failure/close-call grace-period output.
5. Trace expedited grace-period numbers in hexadecimal.
6. Add ftrace-compatible timestamp to GP# failure/close-call output.
7. Make cur_ops->format_gp_seqs take buffer length.
8. Move RCU_TORTURE_TEST_{CHK_RDR_STATE,LOG_CPU} to bool.
9. Complain when invalid SRCU reader_flavor is specified.
10. Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing.
11. Make SRCU lockdep testing use srcu_read_lock_nmisafe().
Changes since v1:
o Fix "segement" typo in commit log.
Thanx, Paul
------------------------------------------------------------------------
b/Documentation/admin-guide/kernel-parameters.txt | 5 + b/include/linux/torture.h | 1 b/include/trace/events/rcu.h | 2 b/kernel/rcu/Kconfig | 11 ++ b/kernel/rcu/Kconfig.debug | 14 +++ b/kernel/rcu/rcu.h | 2 b/kernel/rcu/rcutorture.c | 19 +++- b/kernel/rcu/tiny.c | 14 +++ b/kernel/rcu/tree.c | 20 ++++ b/kernel/torture.c | 12 ++ b/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh | 2 kernel/rcu/Kconfig.debug | 4 kernel/rcu/rcu.h | 6 - kernel/rcu/rcutorture.c | 64 ++++++++++++--- kernel/rcu/tiny.c | 12 +- kernel/rcu/tree.c | 22 ++--- 16 files changed, 173 insertions(+), 37 deletions(-)
Paul E. McKenney
maintainerPATCH v2 1/1 01/11] torture: Add get_torture_init_jiffies() for test-start time
This commit adds a get_torture_init_jiffies() function that returns the value of the jiffies counter at the start of the test, that is, at the point where torture_init_begin() was invoked.
This will be used to enable torture-test holdoffs for tests implemented using per-CPU kthreads, which are created and deleted by CPU-hotplug operations, and thus (unlike normal kthreads) don't automatically know when the test started.
--- include/linux/torture.h | 1 + kernel/torture.c | 12 ++++++++++++ 2 files changed, 13 insertions(+)
include/linux/torture.h +1 -0
@@ -104,6 +104,7 @@ int torture_stutter_init(int s, int sgap);/* Initialization and cleanup. */ bool torture_init_begin (char *ttype,int v);void torture_init_end (void ); +unsigned long get_torture_init_jiffies (void );bool torture_cleanup_begin (void );void torture_cleanup_end (void );bool torture_must_stop (void );
kernel/torture.c +12 -0
@@ -792,6 +792,8 @@ static void torture_stutter_cleanup(void) stutter_task =NULL ; } +static unsigned long torture_init_jiffies; +static void torture_print_module_parms (void ) {
@@ -821,6 +823,7 @@ bool torture_init_begin(char *ttype, int v) torture_type = ttype; verbose = v; fullstop =FULLSTOP_DONTSTOP ; +WRITE_ONCE (torture_init_jiffies, jiffies);// Lockless reads. torture_print_module_parms ();return true; }
@@ -836,6 +839,15 @@ void torture_init_end(void) }EXPORT_SYMBOL_GPL (torture_init_end); +/* +* Get the torture_init_begin()-time value of the jiffies counter. +*/ +unsigned long get_torture_init_jiffies (void ) +{ +return READ_ONCE (torture_init_jiffies); +} +EXPORT_SYMBOL_GPL (get_torture_init_jiffies); +/* * Clean up torture module. Please note that this is -not- invoked via * the usual module_exit() mechanism, but rather by an explicit call from
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerPATCH v2 1/1 02/11] rcutorture: Add a test_boost_holdoff module parameter
In reply to Paul E. McKenneyThis commit adds a test_boost_holdoff module parameter that tells the RCU priority-boosting tests to wait for the specified number of seconds past the start of the rcutorture test. This can be useful when rcutorture is built into the kernel (as opposed to being modprobed), especially on large systems where early start of RCU priority boosting can delay the boot sequence, which adds a full CPU's worth of load onto the system. This can in turn result in pointless stall warnings.
--- .../admin-guide/kernel-parameters.txt | 5 +++++ kernel/rcu/rcutorture.c | 19 ++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +5 -0
@@ -5592,6 +5592,11 @@ rcutorture.test_boost_duration= [KNL] Duration (s) of each individual boost test. + rcutorture.test_boost_holdoff= [KNL] + Holdoff time (s) from start of test to the start + of RCU priority-boost testing. Defaults to zero, + that is, no holdoff. + rcutorture.test_boost_interval= [KNL] Interval (s) between each boost test.
kernel/rcu/rcutorture.c +16 -3
@@ -135,6 +135,7 @@ torture_param(int, stat_interval, 60, "Number of seconds between stats printk()storture_param (int, stutter,5 ,"Number of seconds to run/halt test" );torture_param (int, test_boost,1 ,"Test RCU prio boost: 0=no, 1=maybe, 2=yes." );torture_param (int, test_boost_duration,4 ,"Duration of each boost test, seconds." ); +torture_param (int, test_boost_holdoff,0 ,"Holdoff time from rcutorture start, seconds." );torture_param (int, test_boost_interval,7 ,"Interval between boost tests, seconds." );torture_param (int, test_nmis,0 ,"End-test NMI tests, 0 to disable." );torture_param (bool, test_no_idle_hz, true,"Test support for tickless idle CPUs" );
@@ -1159,8 +1160,19 @@ static int rcu_torture_boost(void *arg)unsigned long gp_state;unsigned long gp_state_time;unsigned long oldstarttime; +unsigned long booststarttime =get_torture_init_jiffies () + test_boost_holdoff *HZ ; -VERBOSE_TOROUT_STRING ("rcu_torture_boost started" ); +if (test_boost_holdoff <=0 ||time_after (jiffies, booststarttime)) { +VERBOSE_TOROUT_STRING ("rcu_torture_boost started" ); + }else { +VERBOSE_TOROUT_STRING ("rcu_torture_boost started holdoff period" ); +while (time_before (jiffies, booststarttime)) { +schedule_timeout_idle (HZ ); +if (kthread_should_stop ()) + goto cleanup; + } +VERBOSE_TOROUT_STRING ("rcu_torture_boost finished holdoff period" ); + }/* Set real-time priority. */ sched_set_fifo_low (current);
@@ -1236,6 +1248,7 @@ checkwait: if (stutter_wait("rcu_torture_boost"))sched_set_fifo_low (current); }while (!torture_must_stop ()); +cleanup:/* Clean up and exit. */ while (!kthread_should_stop ()) {torture_shutdown_absorb ("rcu_torture_boost" );
@@ -2523,7 +2536,7 @@ rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, const char *tag)"shuffle_interval=%d stutter=%d irqreader=%d " "fqs_duration=%d fqs_holdoff=%d fqs_stutter=%d " "test_boost=%d/%d test_boost_interval=%d " -"test_boost_duration=%d shutdown_secs=%d " +"test_boost_duration=%d test_boost_holdoff=%d shutdown_secs=%d " "stall_cpu=%d stall_cpu_holdoff=%d stall_cpu_irqsoff=%d " "stall_cpu_block=%d stall_cpu_repeat=%d " "n_barrier_cbs=%d "
@@ -2537,7 +2550,7 @@ rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, const char *tag) stat_interval, verbose, test_no_idle_hz, shuffle_interval, stutter, irqreader, fqs_duration, fqs_holdoff, fqs_stutter, test_boost, cur_ops->can_boost, - test_boost_interval, test_boost_duration, shutdown_secs, + test_boost_interval, test_boost_duration, test_boost_holdoff, shutdown_secs, stall_cpu, stall_cpu_holdoff, stall_cpu_irqsoff, stall_cpu_block, stall_cpu_repeat, n_barrier_cbs,
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerPATCH v2 1/1 03/11] rcutorture: Include grace-period sequence numbers in failure/close-call
In reply to Paul E. McKenneyThis commit includes the grace-period sequence numbers at the beginning and end of each segment in the "Failure/close-call rcutorture reader segments" list. These are in hexadecimal, and only the bottom byte. Currently, only RCU is supported, with its three sequence numbers (normal, expedited, and polled).
Note that if all the grace-period sequence numbers remain the same across a given reader segment, only one copy of the number will be printed. Of course, if there is a change, both sets of values will be printed.
Because the overhead of collecting this information can suppress heisenbugs, this information is collected and printed only in kernels built with CONFIG_RCU_TORTURE_TEST_LOG_GP=y.
[ paulmck: Apply Nathan Chancellor feedback for IS_ENABLED(). ] [ paulmck: Apply feedback from kernel test robot. ]
--- kernel/rcu/Kconfig.debug | 14 ++++++++++++++ kernel/rcu/rcu.h | 2 ++ kernel/rcu/rcutorture.c | 34 ++++++++++++++++++++++++++++++++++ kernel/rcu/tiny.c | 14 ++++++++++++++ kernel/rcu/tree.c | 20 ++++++++++++++++++++ 5 files changed, 84 insertions(+)
kernel/rcu/Kconfig.debug +14 -0
@@ -84,6 +84,20 @@ config RCU_TORTURE_TEST_LOG_CPU Say Y here if you want CPU IDs logged. Say N if you are unsure. +config RCU_TORTURE_TEST_LOG_GP + bool "Log grace-period numbers for rcutorture failures" + depends on RCU_TORTURE_TEST + default n + help + This option causes rcutorture to decorate each entry of its + log of failure/close-call rcutorture reader segments with the + corresponding grace-period sequence numbers. This information + can be useful, but it does incur additional overhead, overhead + that can make both failures and close calls less probable. + + Say Y here if you want grace-period sequence numbers logged. + Say N if you are unsure. + config RCU_REF_SCALE_TEST tristate "Scalability tests for read-side synchronization (RCU and others)" depends on DEBUG_KERNEL
kernel/rcu/rcu.h +2 -0
@@ -590,6 +590,8 @@ void do_trace_rcu_torture_read(const char *rcutorturename,#endif static inline void rcu_gp_set_torture_wait (int duration) { }#endif +unsigned long rcutorture_gather_gp_seqs (void ); +void rcutorture_format_gp_seqs (unsigned long seqs,char *cp);#ifdef CONFIG_TINY_SRCU
kernel/rcu/rcutorture.c +34 -0
@@ -273,6 +273,8 @@ struct rt_read_seg {bool rt_preempted;int rt_cpu;int rt_end_cpu; +unsigned long rt_gp_seq; +unsigned long rt_gp_seq_end; };static int err_segs_recorded;static struct rt_read_seg err_segs[RCUTORTURE_RDR_MAX_SEGS ];
@@ -407,6 +409,8 @@ struct rcu_torture_ops {void (*gp_slow_register)(atomic_t *rgssp);void (*gp_slow_unregister)(atomic_t *rgssp);bool (*reader_blocked)(void ); +unsigned long (*gather_gp_seqs)(void ); +void (*format_gp_seqs)(unsigned long seqs,char *cp);long cbflood_max;int irq_capable;int can_boost;
@@ -611,6 +615,8 @@ static struct rcu_torture_ops rcu_ops = { .reader_blocked = IS_ENABLED(CONFIG_RCU_TORTURE_TEST_LOG_CPU) ? has_rcu_reader_blocked : NULL, + .gather_gp_seqs = rcutorture_gather_gp_seqs, + .format_gp_seqs = rcutorture_format_gp_seqs, .irq_capable = 1, .can_boost = IS_ENABLED(CONFIG_RCU_BOOST), .extendables = RCUTORTURE_MAX_EXTEND,
@@ -656,6 +662,8 @@ static struct rcu_torture_ops rcu_busted_ops = { .sync = synchronize_rcu_busted, .exp_sync = synchronize_rcu_busted, .call = call_rcu_busted, + .gather_gp_seqs = rcutorture_gather_gp_seqs, + .format_gp_seqs = rcutorture_format_gp_seqs, .irq_capable = 1, .extendables =RCUTORTURE_MAX_EXTEND , .name = "busted"
@@ -1989,6 +1997,12 @@ static void rcutorture_one_extend(int *readstate, int newstate, bool insoftirq, rtrsp[-1 ].rt_preempted = cur_ops->reader_blocked (); } } +// Sample grace-period sequence number, as good a place as any. +if (IS_ENABLED (CONFIG_RCU_TORTURE_TEST_LOG_GP ) && cur_ops->gather_gp_seqs) { + rtrsp->rt_gp_seq = cur_ops->gather_gp_seqs (); +if (!first) + rtrsp[-1 ].rt_gp_seq_end = rtrsp->rt_gp_seq; + }/* * Next, remove old protection, in decreasing order of strength
@@ -3577,6 +3591,7 @@ rcu_torture_cleanup(void)int flags =0 ;unsigned long gp_seq =0 ;int i; +int j;if (torture_cleanup_begin ()) {if (cur_ops->cb_barrier !=NULL ) {
@@ -3672,6 +3687,25 @@ rcu_torture_cleanup(void)else pr_cont (" ..." ); } +if (IS_ENABLED (CONFIG_RCU_TORTURE_TEST_LOG_GP ) && + cur_ops->gather_gp_seqs && cur_ops->format_gp_seqs) { +char buf1[16 +1 ]; +char buf2[16 +1 ]; +char sepchar ='-' ; + + cur_ops->format_gp_seqs (err_segs[i].rt_gp_seq, buf1); + cur_ops->format_gp_seqs (err_segs[i].rt_gp_seq_end, buf2); +if (err_segs[i].rt_gp_seq == err_segs[i].rt_gp_seq_end) { +if (buf2[0 ]) { +for (j =0 ; buf2[j]; j++) + buf2[j] ='.' ; +if (j) + buf2[j -1 ] =' ' ; + } + sepchar =' ' ; + } +pr_cont (" %s%c%s" , buf1, sepchar, buf2); + }if (err_segs[i].rt_delay_ms !=0 ) {pr_cont (" %s%ldms" , firsttime ?"" :"+" , err_segs[i].rt_delay_ms);
kernel/rcu/tiny.c +14 -0
@@ -257,6 +257,20 @@ void kvfree_call_rcu(struct rcu_head *head, void *ptr)EXPORT_SYMBOL_GPL (kvfree_call_rcu);#endif +#if IS_ENABLED (CONFIG_RCU_TORTURE_TEST ) +unsigned long rcutorture_gather_gp_seqs (void ) +{ +return READ_ONCE (rcu_ctrlblk.gp_seq) &0xff ; +} +EXPORT_SYMBOL_GPL (rcutorture_gather_gp_seqs); + +void rcutorture_format_gp_seqs (unsigned long seqs,char *cp) +{ +snprintf (cp,8 ,"g%02lx" , seqs &0xff ); +} +EXPORT_SYMBOL_GPL (rcutorture_format_gp_seqs); +#endif +void __init rcu_init (void ) {open_softirq (RCU_SOFTIRQ , rcu_process_callbacks);
kernel/rcu/tree.c +20 -0
@@ -559,6 +559,26 @@ void rcutorture_get_gp_data(int *flags, unsigned long *gp_seq) }EXPORT_SYMBOL_GPL (rcutorture_get_gp_data); +/* Gather grace-period sequence numbers for rcutorture diagnostics. */ +unsigned long rcutorture_gather_gp_seqs (void ) +{ +return ((READ_ONCE (rcu_state.gp_seq) &0xff ) <<16 ) | + ((READ_ONCE (rcu_state.expedited_sequence) &0xff ) <<8 ) | + (READ_ONCE (rcu_state.gp_seq_polled) &0xff ); +} +EXPORT_SYMBOL_GPL (rcutorture_gather_gp_seqs); + +/* Format grace-period sequence numbers for rcutorture diagnostics. */ +void rcutorture_format_gp_seqs (unsigned long seqs,char *cp) +{ +unsigned int egp = (seqs >>8 ) &0xff ; +unsigned int ggp = (seqs >>16 ) &0xff ; +unsigned int pgp = seqs &0xff ; + +snprintf (cp,16 ,"g%02x:e%02x:p%02x" , ggp, egp, pgp); +} +EXPORT_SYMBOL_GPL (rcutorture_format_gp_seqs); +#if defined(CONFIG_NO_HZ_FULL ) && (!defined(CONFIG_GENERIC_ENTRY ) || !defined(CONFIG_KVM_XFER_TO_GUEST_WORK ))/* * An empty function that will trigger a reschedule on
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerPATCH v2 1/1 04/11] rcutorture: Expand failure/close-call grace-period output
In reply to Paul E. McKenneyWith only eight bits per grace-period sequence number, wrap can happen in 64 grace periods. This commit therefore increases this to sixteen bits for normal grace-period sequence numbers and the combined short-form polling sequence numbers, thus deferring wrap for at least 16,384 grace periods. Because expedited grace periods go faster, expand these to 24 bits, deferring wrap for at least 4,194,304 expedited grace periods. These longer wrap times makes it easier to correlate these numbers to trace-event output.
Note that the low-order two bits are reserved for intra-grace-period state, hence the above wrap numbers being a factor of four smaller than you might expect.
--- kernel/rcu/rcu.h | 4 ++-- kernel/rcu/rcutorture.c | 12 ++++++------ kernel/rcu/tiny.c | 8 ++++---- kernel/rcu/tree.c | 18 +++++++++--------- 4 files changed, 21 insertions(+), 21 deletions(-)
kernel/rcu/rcu.h +2 -2
@@ -590,8 +590,8 @@ void do_trace_rcu_torture_read(const char *rcutorturename,#endif static inline void rcu_gp_set_torture_wait (int duration) { }#endif -unsigned long rcutorture_gather_gp_seqs (void ); -void rcutorture_format_gp_seqs (unsigned long seqs,char *cp); +unsigned long long rcutorture_gather_gp_seqs (void ); +void rcutorture_format_gp_seqs (unsigned long long seqs,char *cp);#ifdef CONFIG_TINY_SRCU
kernel/rcu/rcutorture.c +6 -6
@@ -273,8 +273,8 @@ struct rt_read_seg {bool rt_preempted;int rt_cpu;int rt_end_cpu; -unsigned long rt_gp_seq; -unsigned long rt_gp_seq_end; +unsigned long long rt_gp_seq; +unsigned long long rt_gp_seq_end; };static int err_segs_recorded;static struct rt_read_seg err_segs[RCUTORTURE_RDR_MAX_SEGS ];
@@ -409,8 +409,8 @@ struct rcu_torture_ops {void (*gp_slow_register)(atomic_t *rgssp);void (*gp_slow_unregister)(atomic_t *rgssp);bool (*reader_blocked)(void ); -unsigned long (*gather_gp_seqs)(void ); -void (*format_gp_seqs)(unsigned long seqs,char *cp); +unsigned long long (*gather_gp_seqs)(void ); +void (*format_gp_seqs)(unsigned long long seqs,char *cp);long cbflood_max;int irq_capable;int can_boost;
@@ -3689,8 +3689,8 @@ rcu_torture_cleanup(void) }if (IS_ENABLED (CONFIG_RCU_TORTURE_TEST_LOG_GP ) && cur_ops->gather_gp_seqs && cur_ops->format_gp_seqs) { -char buf1[16 +1 ]; -char buf2[16 +1 ]; +char buf1[20 +1 ]; +char buf2[20 +1 ];char sepchar ='-' ; cur_ops->format_gp_seqs (err_segs[i].rt_gp_seq, buf1);
kernel/rcu/tiny.c +4 -4
@@ -258,15 +258,15 @@ EXPORT_SYMBOL_GPL(kvfree_call_rcu);#endif #if IS_ENABLED (CONFIG_RCU_TORTURE_TEST ) -unsigned long rcutorture_gather_gp_seqs (void ) +unsigned long long rcutorture_gather_gp_seqs (void ) { -return READ_ONCE (rcu_ctrlblk.gp_seq) &0xff ; +return READ_ONCE (rcu_ctrlblk.gp_seq) &0xffffULL ; }EXPORT_SYMBOL_GPL (rcutorture_gather_gp_seqs); -void rcutorture_format_gp_seqs (unsigned long seqs,char *cp) +void rcutorture_format_gp_seqs (unsigned long long seqs,char *cp) { -snprintf (cp,8 ,"g%02lx" , seqs &0xff ); +snprintf (cp,8 ,"g%04llx" , seqs &0xffffULL ); }EXPORT_SYMBOL_GPL (rcutorture_format_gp_seqs);#endif
kernel/rcu/tree.c +9 -9
@@ -560,22 +560,22 @@ void rcutorture_get_gp_data(int *flags, unsigned long *gp_seq)EXPORT_SYMBOL_GPL (rcutorture_get_gp_data);/* Gather grace-period sequence numbers for rcutorture diagnostics. */ -unsigned long rcutorture_gather_gp_seqs (void ) +unsigned long long rcutorture_gather_gp_seqs (void ) { -return ((READ_ONCE (rcu_state.gp_seq) &0xff ) <<16 ) | - ((READ_ONCE (rcu_state.expedited_sequence) &0xff ) <<8 ) | - (READ_ONCE (rcu_state.gp_seq_polled) &0xff ); +return ((READ_ONCE (rcu_state.gp_seq) &0xffffULL ) <<40 ) | + ((READ_ONCE (rcu_state.expedited_sequence) &0xffffffULL ) <<16 ) | + (READ_ONCE (rcu_state.gp_seq_polled) &0xffffULL ); }EXPORT_SYMBOL_GPL (rcutorture_gather_gp_seqs);/* Format grace-period sequence numbers for rcutorture diagnostics. */ -void rcutorture_format_gp_seqs (unsigned long seqs,char *cp) +void rcutorture_format_gp_seqs (unsigned long long seqs,char *cp) { -unsigned int egp = (seqs >>8 ) &0xff ; -unsigned int ggp = (seqs >>16 ) &0xff ; -unsigned int pgp = seqs &0xff ; +unsigned int egp = (seqs >>16 ) &0xffffffULL ; +unsigned int ggp = (seqs >>40 ) &0xffffULL ; +unsigned int pgp = seqs &0xffffULL ; -snprintf (cp,16 ,"g%02x:e%02x:p%02x" , ggp, egp, pgp); +snprintf (cp,20 ,"g%04x:e%06x:p%04x" , ggp, egp, pgp); }EXPORT_SYMBOL_GPL (rcutorture_format_gp_seqs);
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerPATCH v2 1/1 05/11] rcu: Trace expedited grace-period numbers in hexadecimal
In reply to Paul E. McKenneyThis commit reformats the expedited grace-period numbers into hexadecimal for easier decoding and comparison. The normal grace-period numbers remain in decimal for the time being.
--- include/trace/events/rcu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/trace/events/rcu.h +1 -1
@@ -207,7 +207,7 @@ TRACE_EVENT_RCU(rcu_exp_grace_period, __entry->gpevent = gpevent; ), -TP_printk ("%s %ld %s" , +TP_printk ("%s %#lx %s" , __entry->rcuname, __entry->gpseq, __entry->gpevent) );
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerPATCH v2 1/1 10/11] srcu: Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing
In reply to Paul E. McKenneyThe srcu_read_lock_nmisafe() and srcu_read_unlock_nmisafe() functions map to __srcu_read_lock() and __srcu_read_unlock() on systems like x86 that have NMI-safe this_cpu_inc() operations. This makes the underlying __srcu_read_lock_nmisafe() and __srcu_read_unlock_nmisafe() functions difficult to test on (for example) x86 systems, allowing bugs to creep in.
This commit therefore creates a FORCE_NEED_SRCU_NMI_SAFE Kconfig that forces those underlying functions to be used even on systems where they are not needed, thus providing better testing coverage.
--- kernel/rcu/Kconfig | 11 +++++++++++ 1 file changed, 11 insertions(+)
kernel/rcu/Kconfig +11 -0
@@ -65,6 +65,17 @@ config TREE_SRCU help This option selects the full-fledged version of SRCU. +config FORCE_NEED_SRCU_NMI_SAFE + bool "Force selection of NEED_SRCU_NMI_SAFE" + depends on !TINY_SRCU + select NEED_SRCU_NMI_SAFE + default n + help + This option forces selection of the NEED_SRCU_NMI_SAFE + Kconfig option, allowing testing of srcu_read_lock_nmisafe() + and srcu_read_unlock_nmisafe() on architectures (like x86) + that select the ARCH_HAS_NMI_SAFE_THIS_CPU_OPS Kconfig option. + config NEED_SRCU_NMI_SAFE def_bool HAVE_NMI && !ARCH_HAS_NMI_SAFE_THIS_CPU_OPS && !TINY_SRCU
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerPATCH v2 1/1 11/11] torture: Make SRCU lockdep testing use srcu_read_lock_nmisafe()
In reply to Paul E. McKenneyRecent experience shows that the srcu_read_lock_nmisafe() and srcu_read_unlock_nmisafe() functions are not sufficiently tested. This commit therefore causes the torture.sh script's SRCU lockdep testing to use these two functions. This will cause these two functions to be regularly tested by several developers (myself included) who use torture.sh as an RCU acceptance test.
--- tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh +1 -1
@@ -49,7 +49,7 @@ do do err= val=$((d*1000+t*10+c)) - tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 5s --configs "SRCU-P" --bootargs "rcutorture.test_srcu_lockdep=$val" --trust-make --datestamp "$ds/$val" > "$T/kvm.sh.out" 2>&1 + tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 5s --configs "SRCU-P" --kconfig "CONFIG_FORCE_NEED_SRCU_NMI_SAFE=y" --bootargs "rcutorture.test_srcu_lockdep=$val rcutorture.reader_flavor=0x2" --trust-make --datestamp "$ds/$val" > "$T/kvm.sh.out" 2>&1 ret=$? mv "$T/kvm.sh.out" "$RCUTORTURE/res/$ds/$val" if test "$d" -ne 0 && test "$ret" -eq 0
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerPATCH v2 1/1 06/11] rcutorture: Add ftrace-compatible timestamp to GP# failure/close-call output
In reply to Paul E. McKenneyThis commit adds an ftrace-compatible microsecond-scale timestamp to the failure/close-call output, but only in kernels built with CONFIG_RCU_TORTURE_TEST_LOG_GP=y.
--- kernel/rcu/rcutorture.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
kernel/rcu/rcutorture.c +7 -1
@@ -275,6 +275,7 @@ struct rt_read_seg {int rt_end_cpu;unsigned long long rt_gp_seq;unsigned long long rt_gp_seq_end; +u64 rt_ts; };static int err_segs_recorded;static struct rt_read_seg err_segs[RCUTORTURE_RDR_MAX_SEGS ];
@@ -2000,6 +2001,7 @@ static void rcutorture_one_extend(int *readstate, int newstate, bool insoftirq,// Sample grace-period sequence number, as good a place as any. if (IS_ENABLED (CONFIG_RCU_TORTURE_TEST_LOG_GP ) && cur_ops->gather_gp_seqs) { rtrsp->rt_gp_seq = cur_ops->gather_gp_seqs (); + rtrsp->rt_ts =ktime_get_mono_fast_ns ();if (!first) rtrsp[-1 ].rt_gp_seq_end = rtrsp->rt_gp_seq; }
@@ -3674,7 +3676,11 @@ rcu_torture_cleanup(void)pr_alert ("\t: No segments recorded!!!\n" ); firsttime =1 ;for (i =0 ; i < rt_read_nsegs; i++) { -pr_alert ("\t%d: %#4x" , i, err_segs[i].rt_readstate); +if (IS_ENABLED (CONFIG_RCU_TORTURE_TEST_LOG_GP )) +pr_alert ("\t%lluus " ,div64_u64 (err_segs[i].rt_ts,1000ULL )); +else +pr_alert ("\t" ); +pr_cont ("%d: %#4x" , i, err_segs[i].rt_readstate);if (err_segs[i].rt_delay_jiffies !=0 ) {pr_cont ("%s%ldjiffies" , firsttime ?"" :"+" , err_segs[i].rt_delay_jiffies);
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerPATCH v2 1/1 08/11] rcutorture: Move RCU_TORTURE_TEST_{CHK_RDR_STATE,LOG_CPU} to bool
In reply to Paul E. McKenneyThe RCU_TORTURE_TEST_CHK_RDR_STATE and RCU_TORTURE_TEST_LOG_CPU Kconfig options are pointlessly defined as tristate. This commit therefore converts them to bool.
--- kernel/rcu/Kconfig.debug | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/Kconfig.debug +2 -2
@@ -54,7 +54,7 @@ config RCU_TORTURE_TEST Say N if you are unsure. config RCU_TORTURE_TEST_CHK_RDR_STATE - tristate "Check rcutorture reader state" + bool "Check rcutorture reader state" depends on RCU_TORTURE_TEST default n help
@@ -70,7 +70,7 @@ config RCU_TORTURE_TEST_CHK_RDR_STATE Say N if you are unsure. config RCU_TORTURE_TEST_LOG_CPU - tristate "Log CPU for rcutorture failures" + bool "Log CPU for rcutorture failures" depends on RCU_TORTURE_TEST default n help
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerPATCH v2 1/1 09/11] rcutorture: Complain when invalid SRCU reader_flavor is specified
In reply to Paul E. McKenneyCurrently, rcutorture ignores reader_flavor bits that are not in the SRCU_READ_FLAVOR_ALL bitmask, which could confuse rcutorture users into believing buggy patches had been fully tested. This commit therefore produces a splat in this case.
--- kernel/rcu/rcutorture.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/rcu/rcutorture.c +2 -0
@@ -690,6 +690,8 @@ static int srcu_torture_read_lock(void)struct srcu_ctr __percpu *scp;int ret =0 ; +WARN_ON_ONCE (reader_flavor & ~SRCU_READ_FLAVOR_ALL ); +if ((reader_flavor &SRCU_READ_FLAVOR_NORMAL ) || !(reader_flavor &SRCU_READ_FLAVOR_ALL )) { idx =srcu_read_lock (srcu_ctlp);WARN_ON_ONCE (idx & ~0x1 );
Signature · 1 line
2.40.1
Paul E. McKenney
maintainerPATCH v2 1/1 07/11] rcutorture: Make cur_ops->format_gp_seqs take buffer length
In reply to Paul E. McKenneyThe Tree and Tiny implementations of rcutorture_format_gp_seqs() use hard-coded constants for the length of the buffer that they format into. This is of course an accident waiting to happen, so this commit therefore makes them take a length argument. The rcutorture calling code uses ARRAY_SIZE() to safely compute this new argument.
--- kernel/rcu/rcu.h | 2 +- kernel/rcu/rcutorture.c | 8 +++++--- kernel/rcu/tiny.c | 4 ++-- kernel/rcu/tree.c | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-)
kernel/rcu/rcu.h +1 -1
@@ -591,7 +591,7 @@ void do_trace_rcu_torture_read(const char *rcutorturename,static inline void rcu_gp_set_torture_wait (int duration) { }#endif unsigned long long rcutorture_gather_gp_seqs (void ); -void rcutorture_format_gp_seqs (unsigned long long seqs,char *cp); +void rcutorture_format_gp_seqs (unsigned long long seqs,char *cp,size_t len);#ifdef CONFIG_TINY_SRCU
kernel/rcu/rcutorture.c +5 -3
@@ -411,7 +411,7 @@ struct rcu_torture_ops {void (*gp_slow_unregister)(atomic_t *rgssp);bool (*reader_blocked)(void );unsigned long long (*gather_gp_seqs)(void ); -void (*format_gp_seqs)(unsigned long long seqs,char *cp); +void (*format_gp_seqs)(unsigned long long seqs,char *cp,size_t len);long cbflood_max;int irq_capable;int can_boost;
@@ -3699,8 +3699,10 @@ rcu_torture_cleanup(void)char buf2[20 +1 ];char sepchar ='-' ; - cur_ops->format_gp_seqs (err_segs[i].rt_gp_seq, buf1); - cur_ops->format_gp_seqs (err_segs[i].rt_gp_seq_end, buf2); + cur_ops->format_gp_seqs (err_segs[i].rt_gp_seq, + buf1,ARRAY_SIZE (buf1)); + cur_ops->format_gp_seqs (err_segs[i].rt_gp_seq_end, + buf2,ARRAY_SIZE (buf2));if (err_segs[i].rt_gp_seq == err_segs[i].rt_gp_seq_end) {if (buf2[0 ]) {for (j =0 ; buf2[j]; j++)
kernel/rcu/tiny.c +2 -2
@@ -264,9 +264,9 @@ unsigned long long rcutorture_gather_gp_seqs(void) }EXPORT_SYMBOL_GPL (rcutorture_gather_gp_seqs); -void rcutorture_format_gp_seqs (unsigned long long seqs,char *cp) +void rcutorture_format_gp_seqs (unsigned long long seqs,char *cp,size_t len) { -snprintf (cp,8 ,"g%04llx" , seqs &0xffffULL ); +snprintf (cp, len,"g%04llx" , seqs &0xffffULL ); }EXPORT_SYMBOL_GPL (rcutorture_format_gp_seqs);#endif
kernel/rcu/tree.c +2 -2
@@ -569,13 +569,13 @@ unsigned long long rcutorture_gather_gp_seqs(void)EXPORT_SYMBOL_GPL (rcutorture_gather_gp_seqs);/* Format grace-period sequence numbers for rcutorture diagnostics. */ -void rcutorture_format_gp_seqs (unsigned long long seqs,char *cp) +void rcutorture_format_gp_seqs (unsigned long long seqs,char *cp,size_t len) {unsigned int egp = (seqs >>16 ) &0xffffffULL ;unsigned int ggp = (seqs >>40 ) &0xffffULL ;unsigned int pgp = seqs &0xffffULL ; -snprintf (cp,20 ,"g%04x:e%06x:p%04x" , ggp, egp, pgp); +snprintf (cp, len,"g%04x:e%06x:p%04x" , ggp, egp, pgp); }EXPORT_SYMBOL_GPL (rcutorture_format_gp_seqs);
Signature · 1 line
2.40.1