Torture-test updates for v5.11
Subsystems (5)
Paul E. McKenney
maintainercover Torture-test updates for v5.11
Hello!
This series contains torture-test updates:
1. Bounds-check module parameters.
2. Don't kill gdb sessions.
3. Track time of last ->writeunlock().
4. Periodically pause in stutter_wait().
5. Make torture_stutter() use hrtimer.
6. Add an alternative IPI vector.
7. Add RCU Tasks Trace.
8. Avoid divide by zero.
9. Exclude "NOHZ tick-stop error" from fatal errors.
10. Prevent hangs for invalid arguments.
11. Prevent hangs for invalid arguments.
12. Adjust scenarios SRCU-t and SRCU-u to make kconfig happy.
13. Ignore nreaders_stress if no readlock support, courtesy of
Hou Tao.
14. Prevent hangs for invalid arguments.
15. Prevent jitter processes from delaying failed run.
16. Prevent hangs for invalid arguments.
17. Force weak-hashed pointers on console log.
18. Make stutter_wait() caller restore priority.
19. Accept time units on kvm.sh --duration argument.
20. Small code cleanups.
21. Allow alternative forms of kvm.sh command-line arguments.
22. Add full-test stutter capability.
23. Invoke percpu_free_rwsem() to do percpu-rwsem cleanup, courtesy
of Hou Tao.
24. Don't do need_resched() testing if ->sync is NULL.
25. Fix a typo in header file, courtesy of Samuel Hernandez.
26. Make kvm-check-branches.sh use --allcpus.
27. Fix a spelling error in a comment, courtesy of Bhaskar Chowdhury.
28. Fix BUG parsing of console.log, courtesy of Anna-Maria Behnsen.
Thanx, Paul
------------------------------------------------------------------------
kernel/locking/locktorture.c | 36 +++++- kernel/rcu/rcuscale.c | 37 ++++++ kernel/rcu/rcutorture.c | 41 +++++-- kernel/rcu/refscale.c | 11 +- kernel/scftorture.c | 53 +++++++--- kernel/torture.c | 42 +++++-- tools/include/nolibc/nolibc.h | 4 tools/testing/selftests/rcutorture/bin/console-badness.sh | 3 tools/testing/selftests/rcutorture/bin/functions.sh | 1 tools/testing/selftests/rcutorture/bin/kvm-check-branches.sh | 5 tools/testing/selftests/rcutorture/bin/kvm-recheck-rcuscale.sh | 2 tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 19 +++ tools/testing/selftests/rcutorture/bin/kvm.sh | 29 ++++- tools/testing/selftests/rcutorture/bin/parse-console.sh | 2 tools/testing/selftests/rcutorture/configs/rcu/SRCU-t | 3 tools/testing/selftests/rcutorture/configs/rcu/SRCU-u | 3 tools/testing/selftests/rcutorture/configs/rcuscale/CFcommon | 3 tools/testing/selftests/rcutorture/configs/rcuscale/TRACE01 | 15 ++ tools/testing/selftests/rcutorture/configs/rcuscale/TRACE01.boot | 1 19 files changed, 246 insertions(+), 64 deletions(-)
[email protected]
maintainerPATCH 1/28 refscale: Bounds-check module parameters
From: "Paul E. McKenney" <[email protected]>
The default value for refscale.nreaders is -1, which results in the code setting the value to three-quarters of the number of CPUs. On single-CPU systems, this results in three-quarters of the value one, which the C language's integer arithmetic rounds to zero. This in turn results in a divide-by-zero error.
This commit therefore adds bounds checking to the refscale module parameters, so that if they are less than one, they are set to the value one.
Tested-by "Chen, Rong A" <[email protected]>
--- kernel/rcu/refscale.c | 6 ++++++ 1 file changed, 6 insertions(+)
kernel/rcu/refscale.c +6 -0
@@ -681,6 +681,12 @@ ref_scale_init(void)// Reader tasks (default to ~75% of online CPUs). if (nreaders <0 ) nreaders = (num_online_cpus () >>1 ) + (num_online_cpus () >>2 ); +if (WARN_ONCE (loops <=0 ,"%s: loops = %ld, adjusted to 1\n" , __func__, loops)) + loops =1 ; +if (WARN_ONCE (nreaders <=0 ,"%s: nreaders = %d, adjusted to 1\n" , __func__, nreaders)) + nreaders =1 ; +if (WARN_ONCE (nruns <=0 ,"%s: nruns = %d, adjusted to 1\n" , __func__, nruns)) + nruns =1 ; reader_tasks =kcalloc (nreaders,sizeof (reader_tasks[0 ]),GFP_KERNEL );if (!reader_tasks) {
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 2/28 torture: Don't kill gdb sessions
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The rcutorture scripting will do a "kill -9" on any guest OS that exceeds its --duration by more than a few minutes, which is very valuable when bugs result in hangs. However, this is a problem when the "hang" was due to a --gdb debugging session.
This commit therefore refrains from killing the guest OS when a debugging session is in progress. This means that the user must manually kill the kvm.sh process group if a hang really does occur.
--- tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +4 -1
@@ -206,7 +206,10 @@ do kruntime=`gawk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null` if test -z "$qemu_pid" || kill -0 "$qemu_pid" > /dev/null 2>&1 then - if test $kruntime -ge $seconds -o -f "$TORTURE_STOPFILE" + if test -n "$TORTURE_KCONFIG_GDB_ARG" + then + : + elif test $kruntime -ge $seconds || test -f "$TORTURE_STOPFILE" then break; fi
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 3/28 locktorture: Track time of last ->writeunlock()
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit adds a last_lock_release variable that tracks the time of the last ->writeunlock() call, which allows easier diagnosing of lock hangs when using a kernel debugger.
--- kernel/locking/locktorture.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/locking/locktorture.c +2 -0
@@ -60,6 +60,7 @@ static struct task_struct **reader_tasks;static bool lock_is_write_held;static bool lock_is_read_held; +static unsigned long last_lock_release;struct lock_stress_stats {long n_lock_fail;
@@ -632,6 +633,7 @@ static int lock_torture_writer(void *arg) lwsp->n_lock_acquired++; cxt.cur_ops->write_delay (&rand); lock_is_write_held = false; +WRITE_ONCE (last_lock_release, jiffies); cxt.cur_ops->writeunlock ();stutter_wait ("lock_torture_writer" );
Signature · 1 line
2.9.5
Re: [PATCH tip/core/rcu 03/28] locktorture: Track time of last ->writeunlock()
Quoted 5 lines · On Thu, 05 Nov 2020, [email protected] wrote:
From: "Paul E. McKenney" <[email protected]>
This commit adds a
last_lock_releasevariable that tracks the time of the last ->writeunlock() call, which allows easier diagnosing of lock hangs when using a kernel debugger.
This makes sense to have.
Quoted 30 lines
Cc Davidlohr Bueso <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>---
kernel/locking/locktorture.c| 2 ++1 file changed, 2 insertions(+)kernel/locking/locktorture.c +2
-0@@ -60,6 +60,7 @@ static struct task_struct **reader_tasks;static bool lock_is_write_held;static bool lock_is_read_held; +static unsigned long last_lock_release;struct lock_stress_stats {long n_lock_fail;@@ -632,6 +633,7 @@ static int lock_torture_writer(void *arg) lwsp->n_lock_acquired++; cxt.cur_ops->write_delay (&rand); lock_is_write_held = false; +WRITE_ONCE (last_lock_release, jiffies); cxt.cur_ops->writeunlock ();stutter_wait ("lock_torture_writer" );Signature · 1 line
2.9.5
Paul E. McKenney
maintainerRe: [PATCH tip/core/rcu 03/28] locktorture: Track time of last ->writeunlock()
Quoted 11 lines · Davidlohr Bueso
Quoted 5 lines · On Thu, 05 Nov 2020, [email protected] wrote:
From: "Paul E. McKenney" <[email protected]>
This commit adds a
last_lock_releasevariable that tracks the time of the last ->writeunlock() call, which allows easier diagnosing of lock hangs when using a kernel debugger.This makes sense to have.
Acked-by Davidlohr Bueso <[email protected]>
Will apply, thank you!
Thanx, Paul
Quoted 29 lines
Quoted 29 lines
Cc Davidlohr Bueso <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>---
kernel/locking/locktorture.c| 2 ++1 file changed, 2 insertions(+)kernel/locking/locktorture.c +2
-0@@ -60,6 +60,7 @@ static struct task_struct **reader_tasks;static bool lock_is_write_held;static bool lock_is_read_held; +static unsigned long last_lock_release;struct lock_stress_stats {long n_lock_fail;@@ -632,6 +633,7 @@ static int lock_torture_writer(void *arg) lwsp->n_lock_acquired++; cxt.cur_ops->write_delay (&rand); lock_is_write_held = false; +WRITE_ONCE (last_lock_release, jiffies); cxt.cur_ops->writeunlock ();stutter_wait ("lock_torture_writer" );Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 4/28 torture: Periodically pause in stutter_wait()
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
Running locktorture scenario LOCK05 results in hangs:
tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --torture lock --duration 3 --configs LOCK05
The lock_torture_writer() kthreads set themselves to MAX_NICE while running SCHED_OTHER. Other locktorture kthreads run at default niceness, also SCHED_OTHER. This results in these other locktorture kthreads indefinitely preempting the lock_torture_writer() kthreads. Note that the cond_resched() in the stutter_wait() function's loop is ineffective because this scenario is built with CONFIG_PREEMPT=y.
It is not clear that such indefinite preemption is supposed to happen, but in the meantime this commit prevents kthreads running in stutter_wait() from being completely CPU-bound, thus allowing the other threads to get some CPU in a timely fashion. This commit also uses hrtimers to provide very short sleeps to avoid degrading the sudden-on testing that stutter is supposed to provide.
--- kernel/torture.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
kernel/torture.c +14 -2
@@ -602,8 +602,11 @@ static int stutter_gap;*/ bool stutter_wait (const char *title) { -int spt; +ktime_t delay; +unsigned i =0 ; +int oldnice;bool ret = false; +int spt;cond_resched_tasks_rcu_qs (); spt =READ_ONCE (stutter_pause_test);
@@ -612,8 +615,17 @@ bool stutter_wait(const char *title)if (spt ==1 ) {schedule_timeout_interruptible (1 ); }else if (spt ==2 ) { -while (READ_ONCE (stutter_pause_test)) + oldnice =task_nice (current); +set_user_nice (current,MAX_NICE ); +while (READ_ONCE (stutter_pause_test)) { +if (!(i++ &0xffff )) { +set_current_state (TASK_INTERRUPTIBLE ); + delay =10 *NSEC_PER_USEC ; +schedule_hrtimeout (&delay,HRTIMER_MODE_REL ); + }cond_resched (); + } +set_user_nice (current, oldnice); }else {schedule_timeout_interruptible (round_jiffies_relative (HZ )); }
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 5/28 torture: Make torture_stutter() use hrtimer
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The torture_stutter() function uses schedule_timeout_interruptible() to time the stutter duration, but this can miss race conditions due to its being time-synchronized with everything else that is based on the timer wheels. This commit therefore converts torture_stutter() to use the high-resolution timers via schedule_hrtimeout(), and also to fuzz the stutter interval. While in the area, this commit also limits the spin-loop portion of the stutter_wait() function's wait loop to two jiffies, down from about one second.
--- kernel/torture.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
kernel/torture.c +12 -5
@@ -641,20 +641,27 @@ EXPORT_SYMBOL_GPL(stutter_wait);*/ static int torture_stutter (void *arg) { +ktime_t delay; +DEFINE_TORTURE_RANDOM (rand);int wtime;VERBOSE_TOROUT_STRING ("torture_stutter task started" ); do { if (!torture_must_stop() && stutter > 1) { wtime = stutter; - if (stutter > HZ + 1) { + if (stutter > 2) { WRITE_ONCE(stutter_pause_test, 1); - wtime = stutter - HZ - 1; - schedule_timeout_interruptible(wtime); - wtime = HZ + 1; + wtime = stutter - 3; + delay = ktime_divns(NSEC_PER_SEC * wtime, HZ); + delay += (torture_random(&rand) >> 3) % NSEC_PER_MSEC; + set_current_state(TASK_INTERRUPTIBLE); + schedule_hrtimeout(&delay, HRTIMER_MODE_REL); + wtime = 2; } WRITE_ONCE(stutter_pause_test, 2); - schedule_timeout_interruptible(wtime); + delay = ktime_divns(NSEC_PER_SEC * wtime, HZ); + set_current_state(TASK_INTERRUPTIBLE); + schedule_hrtimeout(&delay, HRTIMER_MODE_REL); } WRITE_ONCE(stutter_pause_test, 0); if (!torture_must_stop())
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 6/28 scftorture: Add an alternative IPI vector
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The scftorture tests currently use only smp_call_function() and friends, which means that these tests cannot locate bugs caused by interactions between different IPI vectors. This commit therefore adds the rescheduling IPI to the mix.
Note that this commit permits resched_cpus() only when scftorture is built in. This is a workaround. Longer term, this will use real wakeups rather than resched_cpu().
--- kernel/scftorture.c | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-)
kernel/scftorture.c +32 -9
@@ -62,6 +62,7 @@ torture_param(int, stat_interval, 60, "Number of seconds between stats printk()storture_param (int, stutter_cpus,5 ,"Number of jiffies to change CPUs under test, 0=disable" );torture_param (bool, use_cpus_read_lock,0 ,"Use cpus_read_lock() to exclude CPU hotplug." );torture_param (int, verbose,0 ,"Enable verbose debugging printk()s" ); +torture_param (int, weight_resched,-1 ,"Testing weight for resched_cpu() operations." );torture_param (int, weight_single,-1 ,"Testing weight for single-CPU no-wait operations." );torture_param (int, weight_single_wait,-1 ,"Testing weight for single-CPU operations." );torture_param (int, weight_many,-1 ,"Testing weight for multi-CPU no-wait operations." );
@@ -82,6 +83,7 @@ torture_param(bool, shutdown, SCFTORT_SHUTDOWN, "Shutdown at end of torture teststruct scf_statistics {struct task_struct *task;int cpu; +long long n_resched;long long n_single;long long n_single_ofl;long long n_single_wait;
@@ -97,12 +99,15 @@ static struct task_struct *scf_torture_stats_task; static DEFINE_PER_CPU(long long, scf_invoked_count);// Data for random primitive selection -#define SCF_PRIM_SINGLE 0 -#define SCF_PRIM_MANY 1 -#define SCF_PRIM_ALL 2 -#define SCF_NPRIMS (2 * 3) // Need wait and no-wait versions of each. +#define SCF_PRIM_RESCHED 0 +#define SCF_PRIM_SINGLE 1 +#define SCF_PRIM_MANY 2 +#define SCF_PRIM_ALL 3 +#define SCF_NPRIMS 7 // Need wait and no-wait versions of each, +// except for SCF_PRIM_RESCHED. static char *scf_prim_name[] = { +"resched_cpu" ,"smp_call_function_single" ,"smp_call_function_many" ,"smp_call_function" ,
@@ -136,6 +141,8 @@ static char *bangstr = "";static DEFINE_TORTURE_RANDOM_PERCPU (scf_torture_rand); +extern void resched_cpu (int cpu);// An alternative IPI vector. +// Print torture statistics. Caller must ensure serialization. static void scf_torture_stats_print (void ) {
@@ -148,6 +155,7 @@ static void scf_torture_stats_print(void)for_each_possible_cpu (cpu) invoked_count +=data_race (per_cpu (scf_invoked_count, cpu));for (i =0 ; i < nthreads; i++) { + scfs.n_resched += scf_stats_p[i].n_resched; scfs.n_single += scf_stats_p[i].n_single; scfs.n_single_ofl += scf_stats_p[i].n_single_ofl; scfs.n_single_wait += scf_stats_p[i].n_single_wait;
@@ -160,8 +168,8 @@ static void scf_torture_stats_print(void)if (atomic_read (&n_errs) ||atomic_read (&n_mb_in_errs) ||atomic_read (&n_mb_out_errs) ||atomic_read (&n_alloc_errs)) bangstr ="!!! " ; -pr_alert ("%s %sscf_invoked_count %s: %lld single: %lld/%lld single_ofl: %lld/%lld many: %lld/%lld all: %lld/%lld " , -SCFTORT_FLAG , bangstr, isdone ?"VER" :"ver" , invoked_count, +pr_alert ("%s %sscf_invoked_count %s: %lld resched: %lld single: %lld/%lld single_ofl: %lld/%lld many: %lld/%lld all: %lld/%lld " , +SCFTORT_FLAG , bangstr, isdone ?"VER" :"ver" , invoked_count, scfs.n_resched, scfs.n_single, scfs.n_single_wait, scfs.n_single_ofl, scfs.n_single_wait_ofl, scfs.n_many, scfs.n_many_wait, scfs.n_all, scfs.n_all_wait);torture_onoff_stats ();
@@ -314,6 +322,13 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra } }switch (scfsp->scfs_prim) { +case SCF_PRIM_RESCHED : +if (IS_BUILTIN (CONFIG_SCF_TORTURE_TEST )) { + cpu =torture_random (trsp) % nr_cpu_ids; + scfp->n_resched++; +resched_cpu (cpu); + } +break ;case SCF_PRIM_SINGLE : cpu =torture_random (trsp) % nr_cpu_ids;if (scfsp->scfs_wait)
@@ -433,8 +448,8 @@ static void scftorture_print_module_parms(const char *tag) {pr_alert (SCFTORT_FLAG -"--- %s: verbose=%d holdoff=%d longwait=%d nthreads=%d onoff_holdoff=%d onoff_interval=%d shutdown_secs=%d stat_interval=%d stutter_cpus=%d use_cpus_read_lock=%d, weight_single=%d, weight_single_wait=%d, weight_many=%d, weight_many_wait=%d, weight_all=%d, weight_all_wait=%d\n" , tag, - verbose, holdoff, longwait, nthreads, onoff_holdoff, onoff_interval, shutdown, stat_interval, stutter_cpus, use_cpus_read_lock, weight_single, weight_single_wait, weight_many, weight_many_wait, weight_all, weight_all_wait); +"--- %s: verbose=%d holdoff=%d longwait=%d nthreads=%d onoff_holdoff=%d onoff_interval=%d shutdown_secs=%d stat_interval=%d stutter_cpus=%d use_cpus_read_lock=%d, weight_resched=%d, weight_single=%d, weight_single_wait=%d, weight_many=%d, weight_many_wait=%d, weight_all=%d, weight_all_wait=%d\n" , tag, + verbose, holdoff, longwait, nthreads, onoff_holdoff, onoff_interval, shutdown, stat_interval, stutter_cpus, use_cpus_read_lock, weight_resched, weight_single, weight_single_wait, weight_many, weight_many_wait, weight_all, weight_all_wait); }static void scf_cleanup_handler (void *unused)
@@ -475,6 +490,7 @@ static int __init scf_torture_init(void) {long i;int firsterr =0 ; +unsigned long weight_resched1 = weight_resched;unsigned long weight_single1 = weight_single;unsigned long weight_single_wait1 = weight_single_wait;unsigned long weight_many1 = weight_many;
@@ -487,9 +503,10 @@ static int __init scf_torture_init(void)scftorture_print_module_parms ("Start of test" ); -if (weight_single ==-1 && weight_single_wait ==-1 && +if (weight_resched ==-1 && weight_single ==-1 && weight_single_wait ==-1 && weight_many ==-1 && weight_many_wait ==-1 && weight_all ==-1 && weight_all_wait ==-1 ) { + weight_resched1 =2 * nr_cpu_ids; weight_single1 =2 * nr_cpu_ids; weight_single_wait1 =2 * nr_cpu_ids; weight_many1 =2 ;
@@ -497,6 +514,8 @@ static int __init scf_torture_init(void) weight_all1 =1 ; weight_all_wait1 =1 ; }else { +if (weight_resched ==-1 ) + weight_resched1 =0 ;if (weight_single ==-1 ) weight_single1 =0 ;if (weight_single_wait ==-1 )
@@ -517,6 +536,10 @@ static int __init scf_torture_init(void) firsterr = -EINVAL ; goto unwind; } +if (IS_BUILTIN (CONFIG_SCF_TORTURE_TEST )) +scf_sel_add (weight_resched1,SCF_PRIM_RESCHED , false); +else if (weight_resched1) +VERBOSE_SCFTORTOUT_ERRSTRING ("built as module, weight_resched ignored" );scf_sel_add (weight_single1,SCF_PRIM_SINGLE , false);scf_sel_add (weight_single_wait1,SCF_PRIM_SINGLE , true);scf_sel_add (weight_many1,SCF_PRIM_MANY , false);
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 7/28 rcuscale: Add RCU Tasks Trace
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit adds the ability to test performance and scalability of RCU Tasks Trace updaters.
--- kernel/rcu/rcuscale.c | 32 +++++++++++++++++++++- .../selftests/rcutorture/configs/rcuscale/CFcommon | 3 ++ .../selftests/rcutorture/configs/rcuscale/TRACE01 | 15 ++++++++++ .../rcutorture/configs/rcuscale/TRACE01.boot | 1 + 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/rcutorture/configs/rcuscale/TRACE01 create mode 100644 tools/testing/selftests/rcutorture/configs/rcuscale/TRACE01.boot
kernel/rcu/rcuscale.c +31 -1
@@ -38,6 +38,7 @@#include <asm/byteorder.h> #include <linux/torture.h> #include <linux/vmalloc.h> +#include <linux/rcupdate_trace.h> #include "rcu.h"
@@ -294,6 +295,35 @@ static struct rcu_scale_ops tasks_ops = { .name = "tasks" }; +/* +* Definitions for RCU-tasks-trace scalability testing. +*/ + +static int tasks_trace_scale_read_lock (void ) +{ +rcu_read_lock_trace (); +return 0 ; +} + +static void tasks_trace_scale_read_unlock (int idx) +{ +rcu_read_unlock_trace (); +} + +static struct rcu_scale_ops tasks_tracing_ops = { + .ptype =RCU_TASKS_FLAVOR , + .init = rcu_sync_scale_init, + .readlock = tasks_trace_scale_read_lock, + .readunlock = tasks_trace_scale_read_unlock, + .get_gp_seq = rcu_no_completed, + .gp_diff = rcu_seq_diff, + .async = call_rcu_tasks_trace, + .gp_barrier = rcu_barrier_tasks_trace, + .sync = synchronize_rcu_tasks_trace, + .exp_sync = synchronize_rcu_tasks_trace, + .name ="tasks-tracing" +}; +static unsigned long rcuscale_seq_diff (unsigned long new,unsigned long old) {if (!cur_ops->gp_diff)
@@ -754,7 +784,7 @@ rcu_scale_init(void)long i;int firsterr =0 ;static struct rcu_scale_ops *scale_ops[] = { - &rcu_ops, &srcu_ops, &srcud_ops, &tasks_ops, + &rcu_ops, &srcu_ops, &srcud_ops, &tasks_ops, &tasks_tracing_ops };if (!torture_init_begin (scale_type, verbose))
tools/testing/selftests/rcutorture/configs/rcuscale/CFcommon +3 -0
@@ -1,2 +1,5 @@ CONFIG_RCU_SCALE_TEST=y CONFIG_PRINTK_TIME=y +CONFIG_TASKS_RCU_GENERIC=y +CONFIG_TASKS_RCU=y +CONFIG_TASKS_TRACE_RCU=y
tools/testing/selftests/rcutorture/configs/rcuscale/TRACE01 new file +15 -0
@@ -0,0 +1,15 @@ +CONFIG_SMP=y +CONFIG_PREEMPT_NONE=y +CONFIG_PREEMPT_VOLUNTARY=n +CONFIG_PREEMPT=n +CONFIG_HZ_PERIODIC=n +CONFIG_NO_HZ_IDLE=y +CONFIG_NO_HZ_FULL=n +CONFIG_RCU_FAST_NO_HZ=n +CONFIG_RCU_NOCB_CPU=n +CONFIG_DEBUG_LOCK_ALLOC=n +CONFIG_PROVE_LOCKING=n +CONFIG_RCU_BOOST=n +CONFIG_DEBUG_OBJECTS_RCU_HEAD=n +CONFIG_RCU_EXPERT=y +CONFIG_RCU_TRACE=y
tools/testing/selftests/rcutorture/configs/rcuscale/TRACE01.boot new file +1 -0
@@ -0,0 +1 @@ +rcuscale.scale_type=tasks-tracing
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 8/28 rcuscale: Avoid divide by zero
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The rcuscale test module does not use batches, so there is only ever one batch. This commit therefore informs the kvm-recheck-rcuscale.sh script of this fact of life.
--- tools/testing/selftests/rcutorture/bin/kvm-recheck-rcuscale.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/kvm-recheck-rcuscale.sh +1 -1
@@ -32,7 +32,7 @@ sed -e 's/^\[[^]]*]//' < $i/console.log | awk ' /-scale: .* gps: .* batches:/ { ngps = $9; - nbatches = $11; + nbatches = 1; } /-scale: .*writer-duration/ {
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 9/28 torture: Exclude "NOHZ tick-stop error" from fatal errors
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The "NOHZ tick-stop error: Non-RCU local softirq work is pending" warning happens frequently and appears to be irrelevant to the various torture tests. This commit therefore filters it out.
If there proves to be a need to pay attention to it a later commit will add an "advice" category to allow the user to immediately see that although something happened, it was not an indictment of the system being tortured.
--- tools/testing/selftests/rcutorture/bin/console-badness.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/console-badness.sh +2 -1
@@ -13,4 +13,5 @@ egrep 'Badness|WARNING:|Warn|BUG|===========|Call Trace:|Oops:|detected stalls on CPUs/tasks:|self-detected stall on CPU|Stall ended before state dump start|\?\?\? Writer stall state|rcu_.*kthread starved for|!!!' | grep -v 'ODEBUG: ' | grep -v 'This means that this is a DEBUG kernel and it is' | -grep -v 'Warning: unable to open an initial console' +grep -v 'Warning: unable to open an initial console' | +grep -v 'NOHZ tick-stop error: Non-RCU local softirq work is pending, handler'
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 10/28 rcuscale: Prevent hangs for invalid arguments
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
If an rcuscale torture-test run is given a bad kvm.sh argument, the test will complain to the console, which is good. What is bad is that from the user's perspective, it will just hang for the time specified by the --duration argument. This commit therefore forces an immediate kernel shutdown if a rcu_scale_init()-time error occurs, thus avoiding the appearance of a hang. It also forces a console splat in this case to clearly indicate the presence of an error.
--- kernel/rcu/rcuscale.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/rcu/rcuscale.c +4 -1
@@ -802,7 +802,6 @@ rcu_scale_init(void)for (i =0 ; i <ARRAY_SIZE (scale_ops); i++)pr_cont (" %s" , scale_ops[i]->name);pr_cont ("\n" ); -WARN_ON (!IS_MODULE (CONFIG_RCU_SCALE_TEST )); firsterr = -EINVAL ; cur_ops =NULL ; goto unwind;
@@ -876,6 +875,10 @@ rcu_scale_init(void) unwind:torture_init_end ();rcu_scale_cleanup (); +if (shutdown) { +WARN_ON (!IS_MODULE (CONFIG_RCU_SCALE_TEST )); +kernel_power_off (); + }return firsterr; }
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 11/28 refscale: Prevent hangs for invalid arguments
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
If an refscale torture-test run is given a bad kvm.sh argument, the test will complain to the console, which is good. What is bad is that from the user's perspective, it will just hang for the time specified by the --duration argument. This commit therefore forces an immediate kernel shutdown if a ref_scale_init()-time error occurs, thus avoiding the appearance of a hang. It also forces a console splat in this case to clearly indicate the presence of an error.
--- kernel/rcu/refscale.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/rcu/refscale.c +4 -1
@@ -658,7 +658,6 @@ ref_scale_init(void)for (i =0 ; i <ARRAY_SIZE (scale_ops); i++)pr_cont (" %s" , scale_ops[i]->name);pr_cont ("\n" ); -WARN_ON (!IS_MODULE (CONFIG_RCU_REF_SCALE_TEST )); firsterr = -EINVAL ; cur_ops =NULL ; goto unwind;
@@ -718,6 +717,10 @@ ref_scale_init(void) unwind:torture_init_end ();ref_scale_cleanup (); +if (shutdown) { +WARN_ON (!IS_MODULE (CONFIG_RCU_REF_SCALE_TEST )); +kernel_power_off (); + }return firsterr; }
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 12/28 rcutorture: Adjust scenarios SRCU-t and SRCU-u to make kconfig happy
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The SRCU-u scenario expects to enable lockdep but to also disable the CONFIG_PREEMPT_COUNT kconfig option. This no longer works. This commit therefore instead enables lockdep in SRCU-t, which then allows SRCU-u to disable CONFIG_PREEMPT_COUNT.
--- tools/testing/selftests/rcutorture/configs/rcu/SRCU-t | 3 ++- tools/testing/selftests/rcutorture/configs/rcu/SRCU-u | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/rcutorture/configs/rcu/SRCU-t +2 -1
@@ -4,7 +4,8 @@ CONFIG_PREEMPT_VOLUNTARY=n CONFIG_PREEMPT=n #CHECK#CONFIG_TINY_SRCU=y CONFIG_RCU_TRACE=n -CONFIG_DEBUG_LOCK_ALLOC=n +CONFIG_DEBUG_LOCK_ALLOC=y +CONFIG_PROVE_LOCKING=y CONFIG_DEBUG_OBJECTS_RCU_HEAD=n CONFIG_DEBUG_ATOMIC_SLEEP=y #CHECK#CONFIG_PREEMPT_COUNT=y
tools/testing/selftests/rcutorture/configs/rcu/SRCU-u +1 -2
@@ -4,7 +4,6 @@ CONFIG_PREEMPT_VOLUNTARY=n CONFIG_PREEMPT=n #CHECK#CONFIG_TINY_SRCU=y CONFIG_RCU_TRACE=n -CONFIG_DEBUG_LOCK_ALLOC=y -CONFIG_PROVE_LOCKING=y +CONFIG_DEBUG_LOCK_ALLOC=n CONFIG_DEBUG_OBJECTS_RCU_HEAD=n CONFIG_PREEMPT_COUNT=n
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 13/28 locktorture: Ignore nreaders_stress if no readlock support
In reply to Paul E. McKenneyFrom: Hou Tao <[email protected]>
Exclusive locks do not have readlock support, which means that a locktorture run with the following module parameters will do nothing:
torture_type=mutex_lock nwriters_stress=0 nreaders_stress=1
This commit therefore rejects this combination for exclusive locks by returning -EINVAL during module init.
--- kernel/locking/locktorture.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/locking/locktorture.c +2 -1
@@ -870,7 +870,8 @@ static int __init lock_torture_init(void) goto unwind; } -if (nwriters_stress ==0 && nreaders_stress ==0 ) { +if (nwriters_stress ==0 && + (!cxt.cur_ops->readlock || nreaders_stress ==0 )) {pr_alert ("lock-torture: must run at least one locking thread\n" ); firsterr = -EINVAL ; goto unwind;
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 14/28 locktorture: Prevent hangs for invalid arguments
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
If an locktorture torture-test run is given a bad kvm.sh argument, the test will complain to the console, which is good. What is bad is that from the user's perspective, it will just hang for the time specified by the --duration argument. This commit therefore forces an immediate kernel shutdown if a lock_torture_init()-time error occurs, thus avoiding the appearance of a hang. It also forces a console splat in this case to clearly indicate the presence of an error.
--- kernel/locking/locktorture.c | 5 +++++ 1 file changed, 5 insertions(+)
kernel/locking/locktorture.c +5 -0
@@ -29,6 +29,7 @@#include <linux/slab.h> #include <linux/percpu-rwsem.h> #include <linux/torture.h> +#include <linux/reboot.h> MODULE_LICENSE ("GPL" );MODULE_AUTHOR ("Paul E. McKenney <[email protected]>" );
@@ -1041,6 +1042,10 @@ static int __init lock_torture_init(void) unwind:torture_init_end ();lock_torture_cleanup (); +if (shutdown_secs) { +WARN_ON (!IS_MODULE (CONFIG_LOCK_TORTURE_TEST )); +kernel_power_off (); + }return firsterr; }
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 15/28 torture: Prevent jitter processes from delaying failed run
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
Even when the kernel panics and qemu dies, runs with jitter enabled will continue uselessly until the jitter.sh processes terminate. This can be annoying if a planned one-hour run instead dies during boot.
This commit therefore kills the jitter.sh processes when the run ends more than one minute prior to the termination time specified by the kvm.sh --duration argument or its default.
--- tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 14 ++++++++++++++ tools/testing/selftests/rcutorture/bin/kvm.sh | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +14 -0
@@ -226,6 +226,20 @@ do echo "ps -fp $killpid" >> $resdir/Warnings 2>&1 ps -fp $killpid >> $resdir/Warnings 2>&1 fi + # Reduce probability of PID reuse by allowing a one-minute buffer + if test $((kruntime + 60)) -lt $seconds && test -s "$resdir/../jitter_pids" + then + awk < "$resdir/../jitter_pids" ' + NF > 0 { + pidlist = pidlist " " $1; + n++; + } + END { + if (n > 0) { + print "kill " pidlist; + } + }' | sh + fi else echo ' ---' `date`: "Kernel done" fi
tools/testing/selftests/rcutorture/bin/kvm.sh +4 -1
@@ -459,8 +459,11 @@ function dump(first, pastlast, batchnum) print "if test -n \"$needqemurun\"" print "then" print "\techo ---- Starting kernels. `date` | tee -a " rd "log"; - for (j = 0; j < njitter; j++) + print "\techo > " rd "jitter_pids" + for (j = 0; j < njitter; j++) { print "\tjitter.sh " j " " dur " " ja[2] " " ja[3] "&" + print "\techo $! >> " rd "jitter_pids" + } print "\twait" print "\techo ---- All kernel runs complete. `date` | tee -a " rd "log"; print "else"
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 16/28 rcutorture: Prevent hangs for invalid arguments
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
If an rcutorture torture-test run is given a bad kvm.sh argument, the test will complain to the console, which is good. What is bad is that from the user's perspective, it will just hang for the time specified by the --duration argument. This commit therefore forces an immediate kernel shutdown if a rcu_torture_init()-time error occurs, thus avoiding the appearance of a hang. It also forces a console splat in this case to clearly indicate the presence of an error.
--- kernel/rcu/rcutorture.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/rcu/rcutorture.c +4 -1
@@ -2647,7 +2647,6 @@ rcu_torture_init(void)for (i =0 ; i <ARRAY_SIZE (torture_ops); i++)pr_cont (" %s" , torture_ops[i]->name);pr_cont ("\n" ); -WARN_ON (!IS_MODULE (CONFIG_RCU_TORTURE_TEST )); firsterr = -EINVAL ; cur_ops =NULL ; goto unwind;
@@ -2815,6 +2814,10 @@ rcu_torture_init(void) unwind:torture_init_end ();rcu_torture_cleanup (); +if (shutdown_secs) { +WARN_ON (!IS_MODULE (CONFIG_RCU_TORTURE_TEST )); +kernel_power_off (); + }return firsterr; }
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 17/28 torture: Force weak-hashed pointers on console log
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
Although the rcutorture scripting now deals correctly with full-up security-induced pointer obfuscation, it is still counter-productive for kernel hackers who are analyzing console output. This commit therefore sets the debug_boot_weak_hash kernel boot parameter, which enables printing of weak-hashed pointers for torture-test runs.
Please note that this change applies only to runs initiated by the kvm.sh scripting. If you are instead using modprobe and rmmod, it is your responsibility to build and boot the underlying kernel to your taste.
Please note further that this change does not result in a security hole in normal use. The rcutorture testing runs with a negligible userspace, no networking, and no user interaction. Besides which, there is no data of value that can be extracted from an rcutorture guest OS that could not also be extracted from the host that this guest is running on.
--- tools/testing/selftests/rcutorture/bin/functions.sh | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/rcutorture/bin/functions.sh +1 -0
@@ -169,6 +169,7 @@ identify_qemu () { # Output arguments for the qemu "-append" string based on CPU type # and the TORTURE_QEMU_INTERACTIVE environment variable. identify_qemu_append () { + echo debug_boot_weak_hash local console=ttyS0 case "$1" in qemu-system-x86_64|qemu-system-i386)
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 18/28 rcutorture: Make stutter_wait() caller restore priority
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
Currently, stutter_wait() will happily spin waiting for the stutter interval to end even if the caller is running at a real-time priority level. This could starve normal-priority tasks for no good reason. This commit therefore drops the calling task's priority to SCHED_OTHER MAX_NICE if stutter_wait() needs to wait. But when it waits, stutter_wait() returns true, which allows the caller to restore the priority if needed. Callers that were already running at SCHED_OTHER MAX_NICE obviously do not need any changes, but this commit also restores priority for higher-priority callers.
--- kernel/rcu/rcutorture.c | 24 ++++++++++++++++++------ kernel/torture.c | 9 ++++----- 2 files changed, 22 insertions(+), 11 deletions(-)
kernel/rcu/rcutorture.c +18 -6
@@ -912,7 +912,8 @@ static int rcu_torture_boost(void *arg) oldstarttime = boost_starttime;while (time_before (jiffies, oldstarttime)) {schedule_timeout_interruptible (oldstarttime - jiffies); -stutter_wait ("rcu_torture_boost" ); +if (stutter_wait ("rcu_torture_boost" )) +sched_set_fifo_low (current);if (torture_must_stop ()) goto checkwait; }
@@ -932,7 +933,8 @@ static int rcu_torture_boost(void *arg) jiffies); call_rcu_time = jiffies; } -stutter_wait ("rcu_torture_boost" ); +if (stutter_wait ("rcu_torture_boost" )) +sched_set_fifo_low (current);if (torture_must_stop ()) goto checkwait; }
@@ -964,7 +966,8 @@ static int rcu_torture_boost(void *arg) }/* Go do the stutter. */ -checkwait:stutter_wait ("rcu_torture_boost" ); +checkwait:if (stutter_wait ("rcu_torture_boost" )) +sched_set_fifo_low (current); }while (!torture_must_stop ());/* Clean up and exit. */
@@ -987,6 +990,7 @@ rcu_torture_fqs(void *arg) {unsigned long fqs_resume_time;int fqs_burst_remaining; +int oldnice =task_nice (current);VERBOSE_TOROUT_STRING ("rcu_torture_fqs task started" ); do {
@@ -1002,7 +1006,8 @@ rcu_torture_fqs(void *arg)udelay (fqs_holdoff); fqs_burst_remaining -= fqs_holdoff; } -stutter_wait ("rcu_torture_fqs" ); +if (stutter_wait ("rcu_torture_fqs" )) +sched_set_normal (current, oldnice); }while (!torture_must_stop ());torture_kthread_stopping ("rcu_torture_fqs" );return 0 ;
@@ -1022,9 +1027,11 @@ rcu_torture_writer(void *arg)bool gp_cond1 = gp_cond, gp_exp1 = gp_exp, gp_normal1 = gp_normal;bool gp_sync1 = gp_sync;int i; +int oldnice =task_nice (current);struct rcu_torture *rp;struct rcu_torture *old_rp;static DEFINE_TORTURE_RANDOM (rand); +bool stutter_waited;int synctype[] = {RTWS_DEF_FREE ,RTWS_EXP_SYNC ,RTWS_COND_GET ,RTWS_SYNC };int nsynctypes =0 ;
@@ -1143,7 +1150,8 @@ rcu_torture_writer(void *arg) !rcu_gp_is_normal (); } rcu_torture_writer_state =RTWS_STUTTER ; - if (stutter_wait("rcu_torture_writer") && + stutter_waited =stutter_wait ("rcu_torture_writer" ); + if (stutter_waited && !READ_ONCE(rcu_fwd_cb_nodelay) && !cur_ops->slow_gps && !torture_must_stop() &&
@@ -1155,6 +1163,8 @@ rcu_torture_writer(void *arg)rcu_ftrace_dump (DUMP_ALL );WARN (1 ,"%s: rtort_pipe_count: %d\n" , __func__, rcu_tortures[i].rtort_pipe_count); } +if (stutter_waited) +sched_set_normal (current, oldnice); }while (!torture_must_stop ()); rcu_torture_current =NULL ;// Let stats task know that we are done. /* Reset expediting back to unexpedited. */
@@ -2103,6 +2113,7 @@ static struct notifier_block rcutorture_oom_nb = {/* Carry out grace-period forward-progress testing. */ static int rcu_torture_fwd_prog (void *args) { +int oldnice =task_nice (current);struct rcu_fwd *rfp = args;int tested =0 ;int tested_tries =0 ;
@@ -2121,7 +2132,8 @@ static int rcu_torture_fwd_prog(void *args)rcu_torture_fwd_prog_cr (rfp);/* Avoid slow periods, better to test when busy. */ -stutter_wait ("rcu_torture_fwd_prog" ); +if (stutter_wait ("rcu_torture_fwd_prog" )) +sched_set_normal (current, oldnice); }while (!torture_must_stop ());/* Short runs might not contain a valid forward-progress attempt. */ WARN_ON (!tested && tested_tries >=5 );
kernel/torture.c +4 -5
@@ -604,19 +604,19 @@ bool stutter_wait(const char *title) {ktime_t delay;unsigned i =0 ; -int oldnice;bool ret = false;int spt;cond_resched_tasks_rcu_qs (); spt =READ_ONCE (stutter_pause_test);for (; spt; spt =READ_ONCE (stutter_pause_test)) { - ret = true; +if (!ret) { +sched_set_normal (current,MAX_NICE ); + ret = true; + }if (spt ==1 ) {schedule_timeout_interruptible (1 ); }else if (spt ==2 ) { - oldnice =task_nice (current); -set_user_nice (current,MAX_NICE );while (READ_ONCE (stutter_pause_test)) {if (!(i++ &0xffff )) {set_current_state (TASK_INTERRUPTIBLE );
@@ -625,7 +625,6 @@ bool stutter_wait(const char *title) }cond_resched (); } -set_user_nice (current, oldnice); }else {schedule_timeout_interruptible (round_jiffies_relative (HZ )); }
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 19/28 torture: Accept time units on kvm.sh --duration argument
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The "--duration <minutes>" has worked well for a very long time, but it can be inconvenient to compute the minutes for (say) a 28-hour run. It can also be annoying to have to let a simple boot test run for a full minute. This commit therefore permits an "s" suffix to specify seconds, "m" to specify minutes (which remains the default), "h" suffix to specify hours, and "d" to specify days.
With this change, "--duration 5" still specifies that each scenario run for five minutes, but "--duration 30s" runs for only 30 seconds, "--duration 8h" runs for eight hours, and "--duration 2d" runs for two days.
--- tools/testing/selftests/rcutorture/bin/kvm.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm.sh +15 -3
@@ -58,7 +58,7 @@ usage () { echo " --datestamp string" echo " --defconfig string" echo " --dryrun sched|script" - echo " --duration minutes" + echo " --duration minutes | <seconds>s | <hours>h | <days>d" echo " --gdb" echo " --help" echo " --interactive"
@@ -128,8 +128,20 @@ do shift ;; --duration) - checkarg --duration "(minutes)" $# "$2" '^[0-9]*$' '^error' - dur=$(($2*60)) + checkarg --duration "(minutes)" $# "$2" '^[0-9][0-9]*\(s\|m\|h\|d\|\)$' '^error' + mult=60 + if echo "$2" | grep -q 's$' + then + mult=1 + elif echo "$2" | grep -q 'h$' + then + mult=3600 + elif echo "$2" | grep -q 'd$' + then + mult=86400 + fi + ts=`echo $2 | sed -e 's/[smhd]$//'` + dur=$(($ts*mult)) shift ;; --gdb)
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 20/28 rcutorture: Small code cleanups
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The rcu_torture_cleanup() function fails to NULL out the reader_tasks pointer after freeing it and its fakewriter_tasks loop has redundant braces. This commit therefore cleans these up.
--- kernel/rcu/rcutorture.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/rcutorture.c +2 -2
@@ -2496,13 +2496,13 @@ rcu_torture_cleanup(void)torture_stop_kthread (rcu_torture_reader, reader_tasks[i]);kfree (reader_tasks); + reader_tasks =NULL ; }if (fakewriter_tasks) { -for (i =0 ; i < nfakewriters; i++) { +for (i =0 ; i < nfakewriters; i++)torture_stop_kthread (rcu_torture_fakewriter, fakewriter_tasks[i]); - }kfree (fakewriter_tasks); fakewriter_tasks =NULL ; }
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 21/28 torture: Allow alternative forms of kvm.sh command-line arguments
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit allows --build-only as a synonym for --buildonly, --kconfigs for --kconfig, and --kmake-args for --kmake-arg.
--- tools/testing/selftests/rcutorture/bin/kvm.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm.sh +3 -3
@@ -93,7 +93,7 @@ do TORTURE_BOOT_IMAGE="$2" shift ;; - --buildonly) + --buildonly|--build-only) TORTURE_BUILDONLY=1 ;; --configs|--config)
@@ -160,7 +160,7 @@ do jitter="$2" shift ;; - --kconfig) + --kconfig|--kconfigs) checkarg --kconfig "(Kconfig options)" $# "$2" '^CONFIG_[A-Z0-9_]\+=\([ynm]\|[0-9]\+\)\( CONFIG_[A-Z0-9_]\+=\([ynm]\|[0-9]\+\)\)*$' '^error$' TORTURE_KCONFIG_ARG="$2" shift
@@ -171,7 +171,7 @@ do --kcsan) TORTURE_KCONFIG_KCSAN_ARG="CONFIG_DEBUG_INFO=y CONFIG_KCSAN=y CONFIG_KCSAN_ASSUME_PLAIN_WRITES_ATOMIC=n CONFIG_KCSAN_REPORT_VALUE_CHANGE_ONLY=n CONFIG_KCSAN_REPORT_ONCE_IN_MS=100000 CONFIG_KCSAN_VERBOSE=y CONFIG_KCSAN_INTERRUPT_WATCHER=y"; export TORTURE_KCONFIG_KCSAN_ARG ;; - --kmake-arg) + --kmake-arg|--kmake-args) checkarg --kmake-arg "(kernel make arguments)" $# "$2" '.*' '^error$' TORTURE_KMAKE_ARG="$2" shift
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 22/28 scftorture: Add full-test stutter capability
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
In virtual environments on systems with hardware assist, inter-processor interrupts must do very different things based on whether the target vCPU is running or not. This commit therefore enables torture-test stuttering to better test these running/not-running transitions.
--- kernel/scftorture.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
kernel/scftorture.c +9 -3
@@ -59,7 +59,7 @@ torture_param(int, onoff_holdoff, 0, "Time after boot before CPU hotplugs (s)");torture_param (int, onoff_interval,0 ,"Time between CPU hotplugs (s), 0=disable" );torture_param (int, shutdown_secs,0 ,"Shutdown time (ms), <= zero to disable." );torture_param (int, stat_interval,60 ,"Number of seconds between stats printk()s." ); -torture_param (int, stutter_cpus,5 ,"Number of jiffies to change CPUs under test, 0=disable" ); +torture_param (int, stutter,5 ,"Number of jiffies to run/halt test, 0=disable" );torture_param (bool, use_cpus_read_lock,0 ,"Use cpus_read_lock() to exclude CPU hotplug." );torture_param (int, verbose,0 ,"Enable verbose debugging printk()s" );torture_param (int, weight_resched,-1 ,"Testing weight for resched_cpu() operations." );
@@ -436,6 +436,7 @@ static int scftorture_invoker(void *arg) was_offline = false; }cond_resched (); +stutter_wait ("scftorture_invoker" ); }while (!torture_must_stop ());VERBOSE_SCFTORTOUT ("scftorture_invoker %d ended" , scfp->cpu);
@@ -448,8 +449,8 @@ static void scftorture_print_module_parms(const char *tag) {pr_alert (SCFTORT_FLAG -"--- %s: verbose=%d holdoff=%d longwait=%d nthreads=%d onoff_holdoff=%d onoff_interval=%d shutdown_secs=%d stat_interval=%d stutter_cpus=%d use_cpus_read_lock=%d, weight_resched=%d, weight_single=%d, weight_single_wait=%d, weight_many=%d, weight_many_wait=%d, weight_all=%d, weight_all_wait=%d\n" , tag, - verbose, holdoff, longwait, nthreads, onoff_holdoff, onoff_interval, shutdown, stat_interval, stutter_cpus, use_cpus_read_lock, weight_resched, weight_single, weight_single_wait, weight_many, weight_many_wait, weight_all, weight_all_wait); +"--- %s: verbose=%d holdoff=%d longwait=%d nthreads=%d onoff_holdoff=%d onoff_interval=%d shutdown_secs=%d stat_interval=%d stutter=%d use_cpus_read_lock=%d, weight_resched=%d, weight_single=%d, weight_single_wait=%d, weight_many=%d, weight_many_wait=%d, weight_all=%d, weight_all_wait=%d\n" , tag, + verbose, holdoff, longwait, nthreads, onoff_holdoff, onoff_interval, shutdown, stat_interval, stutter, use_cpus_read_lock, weight_resched, weight_single, weight_single_wait, weight_many, weight_many_wait, weight_all, weight_all_wait); }static void scf_cleanup_handler (void *unused)
@@ -558,6 +559,11 @@ static int __init scf_torture_init(void)if (firsterr) goto unwind; } +if (stutter >0 ) { + firsterr =torture_stutter_init (stutter, stutter); +if (firsterr) + goto unwind; + }// Worker tasks invoking smp_call_function(). if (nthreads <0 )
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 23/28 locktorture: Invoke percpu_free_rwsem() to do percpu-rwsem cleanup
In reply to Paul E. McKenneyFrom: Hou Tao <[email protected]>
When executing the LOCK06 locktorture scenario featuring percpu-rwsem, the RCU callback rcu_sync_func() may still be pending after locktorture module is removed. This can in turn lead to the following Oops:
BUG: unable to handle page fault for address: ffffffffc00eb920 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 6500a067 P4D 6500a067 PUD 6500c067 PMD 13a36c067 PTE 800000013691c163 Oops: 0000 [#1] PREEMPT SMP CPU: 1 PID: 0 Comm: swapper/1 Not tainted 5.9.0-rc5+ #4 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) RIP: 0010:rcu_cblist_dequeue+0x12/0x30 Call Trace: <IRQ> rcu_core+0x1b1/0x860 __do_softirq+0xfe/0x326 asm_call_on_stack+0x12/0x20 </IRQ> do_softirq_own_stack+0x5f/0x80 irq_exit_rcu+0xaf/0xc0 sysvec_apic_timer_interrupt+0x2e/0xb0 asm_sysvec_apic_timer_interrupt+0x12/0x20
This commit avoids tis problem by adding an exit hook in lock_torture_ops and using it to call percpu_free_rwsem() for percpu rwsem torture during the module-cleanup function, thus ensuring that rcu_sync_func() completes before module exits.
It is also necessary to call the exit hook if lock_torture_init() fails half-way, so this commit also adds an ->init_called field in lock_torture_cxt to indicate that exit hook, if present, must be called.
--- kernel/locking/locktorture.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
kernel/locking/locktorture.c +21 -5
@@ -76,6 +76,7 @@ static void lock_torture_cleanup(void);*/ struct lock_torture_ops {void (*init)(void ); +void (*exit)(void );int (*writelock)(void );void (*write_delay)(struct torture_random_state *trsp);void (*task_boost)(struct torture_random_state *trsp);
@@ -92,12 +93,13 @@ struct lock_torture_cxt {int nrealwriters_stress;int nrealreaders_stress;bool debug_lock; +bool init_called;atomic_t n_lock_torture_errors;struct lock_torture_ops *cur_ops;struct lock_stress_stats *lwsa;/* writer statistics */ struct lock_stress_stats *lrsa;/* reader statistics */ }; -static struct lock_torture_cxt cxt = {0 ,0 , false, +static struct lock_torture_cxt cxt = {0 ,0 , false, false,ATOMIC_INIT (0 ),NULL ,NULL };/*
@@ -573,6 +575,11 @@ static void torture_percpu_rwsem_init(void)BUG_ON (percpu_init_rwsem (&pcpu_rwsem)); } +static void torture_percpu_rwsem_exit (void ) +{ +percpu_free_rwsem (&pcpu_rwsem); +} +static int torture_percpu_rwsem_down_write (void )__acquires (pcpu_rwsem) {percpu_down_write (&pcpu_rwsem);
@@ -597,6 +604,7 @@ static void torture_percpu_rwsem_up_read(void) __releases(pcpu_rwsem)static struct lock_torture_ops percpu_rwsem_lock_ops = { .init = torture_percpu_rwsem_init, + .exit = torture_percpu_rwsem_exit, .writelock = torture_percpu_rwsem_down_write, .write_delay = torture_rwsem_write_delay, .task_boost = torture_boost_dummy,
@@ -789,9 +797,10 @@ static void lock_torture_cleanup(void)/* * Indicates early cleanup, meaning that the test has not run, -* such as when passing bogus args when loading the module. As -* such, only perform the underlying torture-specific cleanups, -* and avoid anything related to locktorture. +* such as when passing bogus args when loading the module. +* However cxt->cur_ops.init() may have been invoked, so beside +* perform the underlying torture-specific cleanups, cur_ops.exit() +* will be invoked if needed. */ if (!cxt.lwsa && !cxt.lrsa) goto end;
@@ -831,6 +840,11 @@ static void lock_torture_cleanup(void) cxt.lrsa =NULL ; end: +if (cxt.init_called) { +if (cxt.cur_ops->exit) + cxt.cur_ops->exit (); + cxt.init_called = false; + }torture_cleanup_end (); }
@@ -878,8 +892,10 @@ static int __init lock_torture_init(void) goto unwind; } -if (cxt.cur_ops->init) +if (cxt.cur_ops->init) { cxt.cur_ops->init (); + cxt.init_called = true; + }if (nwriters_stress >=0 ) cxt.nrealwriters_stress = nwriters_stress;
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 24/28 rcutorture: Don't do need_resched() testing if ->sync is NULL
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
If cur_ops->sync is NULL, rcu_torture_fwd_prog_nr() will nevertheless attempt to call through it. This commit therefore flags cases where neither need_resched() nor call_rcu() forward-progress testing can be performed due to NULL function pointers, and also causes rcu_torture_fwd_prog_nr() to take an early exit if cur_ops->sync() is NULL.
--- kernel/rcu/rcutorture.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
kernel/rcu/rcutorture.c +5 -3
@@ -1923,7 +1923,9 @@ static void rcu_torture_fwd_prog_nr(struct rcu_fwd *rfp,unsigned long stopat;static DEFINE_TORTURE_RANDOM (trs); -if (cur_ops->call && cur_ops->sync && cur_ops->cb_barrier) { +if (!cur_ops->sync) +return ;// Cannot do need_resched() forward progress testing without ->sync. +if (cur_ops->call && cur_ops->cb_barrier) {init_rcu_head_on_stack (&fcs.rh); selfpropcb = true; }
@@ -2149,8 +2151,8 @@ static int __init rcu_torture_fwd_prog_init(void)if (!fwd_progress)return 0 ;/* Not requested, so don't do it. */ -if (!cur_ops->stall_dur || cur_ops->stall_dur () <=0 || - cur_ops == &rcu_busted_ops) { +if ((!cur_ops->sync && !cur_ops->call) || + !cur_ops->stall_dur || cur_ops->stall_dur () <=0 || cur_ops == &rcu_busted_ops) {VERBOSE_TOROUT_STRING ("rcu_torture_fwd_prog_init: Disabled, unsupported by RCU flavor under test" );return 0 ; }
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 25/28 rcutorture/nolibc: Fix a typo in header file
In reply to Paul E. McKenneyFrom: Samuel Hernandez <[email protected]>
This fixes a typo. Before this, the AT_FDCWD macro would be defined regardless of whether or not it's been defined before.
--- tools/include/nolibc/nolibc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/include/nolibc/nolibc.h +1 -1
@@ -231,7 +231,7 @@ struct rusage {#define DT_SOCK 12/* all the *at functions */ -#ifndef AT_FDWCD +#ifndef AT_FDCWD #define AT_FDCWD -100#endif
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 26/28 torture: Make kvm-check-branches.sh use --allcpus
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
Currently the kvm-check-branches.sh script calculates the number of CPUs and passes this to the kvm.sh --cpus command-line argument. This works, but this commit saves a line by instead using the new kvm.sh --allcpus command-line argument.
--- tools/testing/selftests/rcutorture/bin/kvm-check-branches.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-check-branches.sh +2 -3
@@ -52,8 +52,7 @@ echo Results directory: $resdir/$ds KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM PATH=${KVM}/bin:$PATH; export PATH . functions.sh -cpus="`identify_qemu_vcpus`" -echo Using up to $cpus CPUs. +echo Using all `identify_qemu_vcpus` CPUs. # Each pass through this loop does one command-line argument. for gitbr in $@
@@ -74,7 +73,7 @@ do # Test the specified commit. git checkout $i > $resdir/$ds/$idir/git-checkout.out 2>&1 echo git checkout return code: $? "(Commit $ntry: $i)" - kvm.sh --cpus $cpus --duration 3 --trust-make > $resdir/$ds/$idir/kvm.sh.out 2>&1 + kvm.sh --allcpus --duration 3 --trust-make > $resdir/$ds/$idir/kvm.sh.out 2>&1 ret=$? echo kvm.sh return code $ret for commit $i from branch $gitbr
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 27/28 tools/nolibc: Fix a spelling error in a comment
In reply to Paul E. McKenneyFrom: Bhaskar Chowdhury <[email protected]>
Fix a spelling in the comment line.
s/memry/memory/p
This is on linux-next.
--- tools/include/nolibc/nolibc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/include/nolibc/nolibc.h +1 -1
@@ -107,7 +107,7 @@ static int errno;#endif /* errno codes all ensure that they will not conflict with a valid pointer -* because they all correspond to the highest addressable memry page. +* because they all correspond to the highest addressable memory page. */ #define MAX_ERRNO 4095
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 28/28 tools/rcutorture: Fix BUG parsing of console.log
In reply to Paul E. McKenneyFrom: Anna-Maria Behnsen <[email protected]>
For the rcutorture test summary log file console.log of virtual machines is parsed. When a console.log contains "DEBUG", BUG counter is incremented because regular expression does not handle to ignore DEBUG.
--- tools/testing/selftests/rcutorture/bin/parse-console.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/parse-console.sh +1 -1
@@ -133,7 +133,7 @@ then then summary="$summary Warnings: $n_warn" fi - n_bugs=`egrep -c 'BUG|Oops:' $file` + n_bugs=`egrep -c '\bBUG|Oops:' $file` if test "$n_bugs" -ne 0 then summary="$summary Bugs: $n_bugs"
Signature · 1 line
2.9.5