Torture-test updates for v5.7
Subsystems (5)
Paul E. McKenney
maintainercover Torture-test updates for v5.7
Hello!
This series contains torture-test updates.
1. Suppress forward-progress complaints during early boot.
2. Make results-directory date format completion-friendly.
3. Refrain from callback flooding during boot.
4. Forgive -EBUSY from boottime CPU-hotplug operations.
5. Allow boottime stall warnings to be suppressed.
6. Suppress boottime bad-sequence warnings.
7. Allow disabling of boottime CPU-hotplug torture operations.
8. Add 100-CPU configuration.
9. Summarize summary of build and run results.
10. Make kvm-find-errors.sh abort on bad directory.
11. Fix rcu_torture_one_read()/rcu_torture_writer() data race.
12. Fix stray access to rcu_fwd_cb_nodelay.
13. Add READ_ONCE() to rcu_torture_count and rcu_torture_batch.
14. Annotation lockless accesses to rcu_torture_current.
15. Measure memory footprint during kfree_rcu() test.
16. Make rcu_torture_barrier_cbs() post from corresponding CPU.
17. Manually clean up after rcu_barrier() failure.
18. Set KCSAN Kconfig options to detect more data races.
Thanx, Paul
------------------------------------------------------------------------
Documentation/admin-guide/kernel-parameters.txt | 10 + include/linux/rcutiny.h | 1 include/linux/rcutree.h | 1 kernel/rcu/rcu.h | 17 +++ kernel/rcu/rcuperf.c | 14 ++ kernel/rcu/rcutorture.c | 73 ++++++++++---- kernel/rcu/tree_exp.h | 9 + kernel/rcu/tree_stall.h | 6 - kernel/rcu/update.c | 20 +++ kernel/torture.c | 29 ++++- tools/testing/selftests/rcutorture/bin/kvm-find-errors.sh | 2 tools/testing/selftests/rcutorture/bin/kvm-recheck.sh | 17 +++ tools/testing/selftests/rcutorture/bin/kvm.sh | 2 tools/testing/selftests/rcutorture/configs/rcu/CFcommon | 2 tools/testing/selftests/rcutorture/configs/rcu/TREE10 | 18 +++ 15 files changed, 187 insertions(+), 34 deletions(-)
[email protected]
maintainerPATCH 1/18 rcutorture: Suppress forward-progress complaints during early boot
From: "Paul E. McKenney" <[email protected]>
Some larger systems can take in excess of 50 seconds to complete their early boot initcalls prior to spawing init. This does not in any way help the forward-progress judgments of built-in rcutorture (when rcutorture is built as a module, the insmod or modprobe command normally cannot happen until some time after boot completes). This commit therefore suppresses such complaints until about the time that init is spawned.
This also includes a fix to a stupid error located by kbuild test robot.
--- include/linux/rcutiny.h | 1 + include/linux/rcutree.h | 1 + kernel/rcu/rcutorture.c | 3 ++- kernel/rcu/tree_exp.h | 7 ++++++- kernel/rcu/update.c | 12 ++++++++++++ 5 files changed, 22 insertions(+), 2 deletions(-)
include/linux/rcutiny.h +1 -0
@@ -83,6 +83,7 @@ void rcu_scheduler_starting(void);static inline void rcu_scheduler_starting (void ) { }#endif /* #else #ifndef CONFIG_SRCU */ static inline void rcu_end_inkernel_boot (void ) { } +static inline bool rcu_inkernel_boot_has_ended (void ) {return true; }static inline bool rcu_is_watching (void ) {return true; }static inline void rcu_momentary_dyntick_idle (void ) { }static inline void kfree_rcu_scheduler_running (void ) { }
include/linux/rcutree.h +1 -0
@@ -54,6 +54,7 @@ void exit_rcu(void);void rcu_scheduler_starting (void );extern int rcu_scheduler_active__read_mostly ;void rcu_end_inkernel_boot (void ); +bool rcu_inkernel_boot_has_ended (void );bool rcu_is_watching (void );#ifndef CONFIG_PREEMPTION void rcu_all_qs (void );
kernel/rcu/rcutorture.c +2 -1
@@ -1067,7 +1067,8 @@ rcu_torture_writer(void *arg)if (stutter_wait ("rcu_torture_writer" ) && !READ_ONCE (rcu_fwd_cb_nodelay) && !cur_ops->slow_gps && - !torture_must_stop ()) + !torture_must_stop () && +rcu_inkernel_boot_has_ended ())for (i =0 ; i <ARRAY_SIZE (rcu_tortures); i++)if (list_empty (&rcu_tortures[i].rtort_free) && rcu_access_pointer(rcu_torture_current) !=
kernel/rcu/tree_exp.h +6 -1
@@ -485,6 +485,7 @@ static bool synchronize_rcu_expedited_wait_once(long tlimit)static void synchronize_rcu_expedited_wait (void ) {int cpu; +unsigned long j;unsigned long jiffies_stall;unsigned long jiffies_start;unsigned long mask;
@@ -496,7 +497,7 @@ static void synchronize_rcu_expedited_wait(void)trace_rcu_exp_grace_period (rcu_state.name,rcu_exp_gp_seq_endval (),TPS ("startwait" )); jiffies_stall =rcu_jiffies_till_stall_check (); jiffies_start = jiffies; -if (IS_ENABLED (CONFIG_NO_HZ_FULL )) { +if (tick_nohz_full_enabled () &&rcu_inkernel_boot_has_ended ()) {if (synchronize_rcu_expedited_wait_once (1 ))return ;rcu_for_each_leaf_node (rnp) {
@@ -508,6 +509,10 @@ static void synchronize_rcu_expedited_wait(void)tick_dep_set_cpu (cpu,TICK_DEP_BIT_RCU_EXP ); } } + j =READ_ONCE (jiffies_till_first_fqs); +if (synchronize_rcu_expedited_wait_once (j +HZ )) +return ; +WARN_ON_ONCE (IS_ENABLED (CONFIG_PREEMPT_RT )); }for (;;) {
kernel/rcu/update.c +12 -0
@@ -183,6 +183,8 @@ void rcu_unexpedite_gp(void) }EXPORT_SYMBOL_GPL (rcu_unexpedite_gp); +static bool rcu_boot_ended__read_mostly ; +/* * Inform RCU of the end of the in-kernel boot sequence. */
@@ -191,7 +193,17 @@ void rcu_end_inkernel_boot(void)rcu_unexpedite_gp ();if (rcu_normal_after_boot)WRITE_ONCE (rcu_normal,1 ); + rcu_boot_ended = 1; +} + +/* +* Let rcutorture know when it is OK to turn it up to eleven. +*/ +bool rcu_inkernel_boot_has_ended (void ) +{ +return rcu_boot_ended; } +EXPORT_SYMBOL_GPL (rcu_inkernel_boot_has_ended);#endif /* #ifndef CONFIG_TINY_RCU */
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 2/18 torture: Make results-directory date format completion-friendly
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The names of the per-test results directories are of the form 2019.11.29-20:42:19. This works, but the ":" characters make tab-based shell name completion a bit onerous because the user must remember to include a quote character somewhere before the first ":". This commit therefore changes the ":" characters to periods, as in 2019.12.01-20.48.01", which allows tab-based completion to work more naturally.
--- tools/testing/selftests/rcutorture/bin/kvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/kvm.sh +1 -1
@@ -39,7 +39,7 @@ TORTURE_TRUST_MAKE="" resdir="" configs="" cpus=0 -ds=`date +%Y.%m.%d-%H:%M:%S` +ds=`date +%Y.%m.%d-%H.%M.%S` jitter="-1" usage () {
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 3/18 rcutorture: Refrain from callback flooding during boot
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
Additional rcutorture aggression can result in, believe it or not, boot times in excess of three minutes on large hyperthreaded systems. This is long enough for rcutorture to decide to do some callback flooding, which seems a bit excessive given that userspace cannot have started until long after boot, and it is userspace that does the real-world callback flooding. Worse yet, because Tiny RCU lacks forward-progress functionality, the looping-in-the-kernel tests can also be problematic during early boot.
This commit therefore causes rcutorture to hold off on callback flooding until about the time that init is spawned, and the same for looping-in-the-kernel tests for Tiny RCU.
--- kernel/rcu/rcutorture.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
kernel/rcu/rcutorture.c +5 -2
@@ -1994,8 +1994,11 @@ static int rcu_torture_fwd_prog(void *args)schedule_timeout_interruptible (fwd_progress_holdoff *HZ );WRITE_ONCE (rcu_fwd_emergency_stop, false);register_oom_notifier (&rcutorture_oom_nb); -rcu_torture_fwd_prog_nr (rfp, &tested, &tested_tries); -rcu_torture_fwd_prog_cr (rfp); +if (!IS_ENABLED (CONFIG_TINY_RCU ) || +rcu_inkernel_boot_has_ended ()) +rcu_torture_fwd_prog_nr (rfp, &tested, &tested_tries); +if (rcu_inkernel_boot_has_ended ()) +rcu_torture_fwd_prog_cr (rfp);unregister_oom_notifier (&rcutorture_oom_nb);/* Avoid slow periods, better to test when busy. */
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 4/18 torture: Forgive -EBUSY from boottime CPU-hotplug operations
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
During boot, CPU hotplug is often disabled, for example by PCI probing. On large systems that take substantial time to boot, this can result in spurious RCU_HOTPLUG errors. This commit therefore forgives any boottime -EBUSY CPU-hotplug failures by adjusting counters to pretend that the corresponding attempt never happened. A non-splat record of the failed attempt is emitted to the console with the added string "(-EBUSY forgiven during boot)".
--- kernel/torture.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
kernel/torture.c +18 -4
@@ -84,6 +84,7 @@ bool torture_offline(int cpu, long *n_offl_attempts, long *n_offl_successes, {unsigned long delta;int ret; +char *s;unsigned long starttime;if (!cpu_online (cpu) || !cpu_is_hotpluggable (cpu))
@@ -99,10 +100,16 @@ bool torture_offline(int cpu, long *n_offl_attempts, long *n_offl_successes, (*n_offl_attempts)++; ret =cpu_down (cpu);if (ret) { + s ="" ; +if (!rcu_inkernel_boot_has_ended () && ret == -EBUSY ) { +// PCI probe frequently disables hotplug during boot. + (*n_offl_attempts)--; + s =" (-EBUSY forgiven during boot)" ; + }if (verbose)pr_alert ("%s" TORTURE_FLAG -"torture_onoff task: offline %d failed: errno %d\n" , - torture_type, cpu, ret); +"torture_onoff task: offline %d failed%s: errno %d\n" , + torture_type, cpu, s, ret); }else {if (verbose >1 ) pr_alert("%s" TORTURE_FLAG
@@ -137,6 +144,7 @@ bool torture_online(int cpu, long *n_onl_attempts, long *n_onl_successes, {unsigned long delta;int ret; +char *s;unsigned long starttime;if (cpu_online (cpu) || !cpu_is_hotpluggable (cpu))
@@ -150,10 +158,16 @@ bool torture_online(int cpu, long *n_onl_attempts, long *n_onl_successes, (*n_onl_attempts)++; ret =cpu_up (cpu);if (ret) { + s ="" ; +if (!rcu_inkernel_boot_has_ended () && ret == -EBUSY ) { +// PCI probe frequently disables hotplug during boot. + (*n_onl_attempts)--; + s =" (-EBUSY forgiven during boot)" ; + }if (verbose)pr_alert ("%s" TORTURE_FLAG -"torture_onoff task: online %d failed: errno %d\n" , - torture_type, cpu, ret); +"torture_onoff task: online %d failed%s: errno %d\n" , + torture_type, cpu, s, ret); }else {if (verbose >1 ) pr_alert("%s" TORTURE_FLAG
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 5/18 rcutorture: Allow boottime stall warnings to be suppressed
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
In normal production, an RCU CPU stall warning at boottime is often just as bad as at any other time. In fact, given the desire for fast boot, any sort of long-term stall at boot is a bad idea. However, heavy rcutorture testing on large hyperthreaded systems can generate boottime RCU CPU stalls as a matter of course. This commit therefore provides a kernel boot parameter that suppresses reporting of boottime RCU CPU stall warnings and similarly of rcutorture writer stalls.
--- Documentation/admin-guide/kernel-parameters.txt | 6 ++++++ kernel/rcu/rcu.h | 17 +++++++++++++++++ kernel/rcu/rcutorture.c | 2 +- kernel/rcu/tree_exp.h | 2 +- kernel/rcu/tree_stall.h | 6 +++--- kernel/rcu/update.c | 8 +++++++- 6 files changed, 35 insertions(+), 6 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +6 -0
@@ -4195,6 +4195,12 @@ rcupdate.rcu_cpu_stall_suppress= [KNL] Suppress RCU CPU stall warning messages. + rcupdate.rcu_cpu_stall_suppress_at_boot= [KNL] + Suppress RCU CPU stall warning messages and + rcutorture writer stall warnings that occur + during early boot, that is, during the time + before the init task is spawned. + rcupdate.rcu_cpu_stall_timeout= [KNL] Set timeout for RCU CPU stall warning messages.
kernel/rcu/rcu.h +17 -0
@@ -198,6 +198,13 @@ static inline void debug_rcu_head_unqueue(struct rcu_head *head) }#endif /* #else !CONFIG_DEBUG_OBJECTS_RCU_HEAD */ +extern int rcu_cpu_stall_suppress_at_boot; + +static inline bool rcu_stall_is_suppressed_at_boot (void ) +{ +return rcu_cpu_stall_suppress_at_boot && !rcu_inkernel_boot_has_ended (); +} +#ifdef CONFIG_RCU_STALL_COMMON extern int rcu_cpu_stall_ftrace_dump;
@@ -205,6 +212,11 @@ extern int rcu_cpu_stall_suppress;extern int rcu_cpu_stall_timeout;int rcu_jiffies_till_stall_check (void ); +static inline bool rcu_stall_is_suppressed (void ) +{ +return rcu_stall_is_suppressed_at_boot () || rcu_cpu_stall_suppress; +} +#define rcu_ftrace_dump_stall_suppress () \ do { \ if (!rcu_cpu_stall_suppress) \
@@ -218,6 +230,11 @@ do { \ } while (0)#else /* #endif #ifdef CONFIG_RCU_STALL_COMMON */ + +static inline bool rcu_stall_is_suppressed (void ) +{ +return rcu_stall_is_suppressed_at_boot (); +}#define rcu_ftrace_dump_stall_suppress ()#define rcu_ftrace_dump_stall_unsuppress ()#endif /* #ifdef CONFIG_RCU_STALL_COMMON */
kernel/rcu/rcutorture.c +1 -1
@@ -1479,7 +1479,7 @@ rcu_torture_stats_print(void)if (cur_ops->stats) cur_ops->stats ();if (rtcv_snap == rcu_torture_current_version && - rcu_torture_current !=NULL ) { + rcu_torture_current !=NULL && !rcu_stall_is_suppressed ()) {int __maybe_unused flags =0 ;unsigned long __maybe_unused gp_seq =0 ;
kernel/rcu/tree_exp.h +1 -1
@@ -518,7 +518,7 @@ static void synchronize_rcu_expedited_wait(void)for (;;) {if (synchronize_rcu_expedited_wait_once (jiffies_stall))return ; -if (rcu_cpu_stall_suppress) +if (rcu_stall_is_suppressed ())continue ;panic_on_rcu_stall (); pr_err("INFO: %s detected expedited stalls on CPUs/tasks: {",
kernel/rcu/tree_stall.h +3 -3
@@ -383,7 +383,7 @@ static void print_other_cpu_stall(unsigned long gp_seq)/* Kick and suppress, if so configured. */ rcu_stall_kick_kthreads (); -if (rcu_cpu_stall_suppress) +if (rcu_stall_is_suppressed ())return ;/*
@@ -452,7 +452,7 @@ static void print_cpu_stall(void)/* Kick and suppress, if so configured. */ rcu_stall_kick_kthreads (); -if (rcu_cpu_stall_suppress) +if (rcu_stall_is_suppressed ())return ;/*
@@ -504,7 +504,7 @@ static void check_cpu_stall(struct rcu_data *rdp)unsigned long js;struct rcu_node *rnp; -if ((rcu_cpu_stall_suppress && !rcu_kick_kthreads) || +if ((rcu_stall_is_suppressed () && !rcu_kick_kthreads) || !rcu_gp_in_progress ())return ;rcu_stall_kick_kthreads ();
kernel/rcu/update.c +7 -1
@@ -476,13 +476,19 @@ EXPORT_SYMBOL_GPL(rcutorture_sched_setaffinity);#ifdef CONFIG_RCU_STALL_COMMON int rcu_cpu_stall_ftrace_dump__read_mostly ;module_param (rcu_cpu_stall_ftrace_dump, int,0644 ); -int rcu_cpu_stall_suppress__read_mostly ;/* 1 = suppress stall warnings. */ +int rcu_cpu_stall_suppress__read_mostly ;// !0 = suppress stall warnings. EXPORT_SYMBOL_GPL (rcu_cpu_stall_suppress);module_param (rcu_cpu_stall_suppress, int,0644 );int rcu_cpu_stall_timeout__read_mostly =CONFIG_RCU_CPU_STALL_TIMEOUT ;module_param (rcu_cpu_stall_timeout, int,0644 );#endif /* #ifdef CONFIG_RCU_STALL_COMMON */ +// Suppress boot-time RCU CPU stall warnings and rcutorture writer stall +// warnings. Also used by rcutorture even if stall warnings are excluded. +int rcu_cpu_stall_suppress_at_boot__read_mostly ;// !0 = suppress boot stalls. +EXPORT_SYMBOL_GPL (rcu_cpu_stall_suppress_at_boot); +module_param (rcu_cpu_stall_suppress_at_boot, int,0444 ); +#ifdef CONFIG_TASKS_RCU /*
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 6/18 rcutorture: Suppress boottime bad-sequence warnings
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
In normal production, an excessively long wait on a grace period (synchronize_rcu(), for example) at boottime is often just as bad as at any other time. In fact, given the desire for fast boot, any sort of long wait at boot is a bad idea. However, heavy rcutorture testing on large hyperthreaded systems can generate such long waits during boot as a matter of course. This commit therefore causes the rcupdate.rcu_cpu_stall_suppress_at_boot kernel boot parameter to suppress reporting of bootime bad-sequence warning due to excessively long grace-period waits.
--- kernel/rcu/rcutorture.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcu/rcutorture.c +2 -1
@@ -1423,7 +1423,8 @@ rcu_torture_stats_print(void)pr_alert ("%s%s " , torture_type,TORTURE_FLAG ); pr_cont("rtc: %p %s: %lu tfle: %d rta: %d rtaf: %d rtf: %d ", rcu_torture_current, - rcu_torture_current ? "ver" : "VER", + rcu_torture_current && !rcu_stall_is_suppressed_at_boot() + ? "ver" : "VER", rcu_torture_current_version, list_empty(&rcu_torture_freelist), atomic_read(&n_rcu_torture_alloc),
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 7/18 torture: Allow disabling of boottime CPU-hotplug torture operations
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
In theory, RCU-hotplug operations are supposed to work as soon as there is more than one CPU online. However, in practice, in normal production there is no way to make them happen until userspace is up and running. Besides which, on smaller systems, rcutorture doesn't start doing hotplug operations until 30 seconds after the start of boot, which on most systems also means the better part of 30 seconds after the end of boot. This commit therefore provides a new torture.disable_onoff_at_boot kernel boot parameter that suppresses CPU-hotplug torture operations until about the time that init is spawned.
Of course, if you know of a need for boottime CPU-hotplug operations, then you should avoid passing this argument to any of the torture tests. You might also want to look at the splats linked to below.
--- Documentation/admin-guide/kernel-parameters.txt | 4 ++++ kernel/torture.c | 7 +++++++ 2 files changed, 11 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +4 -0
@@ -4873,6 +4873,10 @@ topology updates sent by the hypervisor to this LPAR. + torture.disable_onoff_at_boot= [KNL] + Prevent the CPU-hotplug component of torturing + until after init has spawned. + tp720= [HW,PS2] tpm_suspend_pcr=[HW,TPM]
kernel/torture.c +7 -0
@@ -42,6 +42,9 @@MODULE_LICENSE ("GPL" );MODULE_AUTHOR ("Paul E. McKenney <[email protected]>" ); +static bool disable_onoff_at_boot; +module_param (disable_onoff_at_boot, bool,0444 ); +static char *torture_type;static int verbose;
@@ -229,6 +232,10 @@ torture_onoff(void *arg)VERBOSE_TOROUT_STRING ("torture_onoff end holdoff" ); } while (!torture_must_stop()) { + if (disable_onoff_at_boot && !rcu_inkernel_boot_has_ended()) { + schedule_timeout_interruptible(HZ / 10); + continue; + } cpu = (torture_random(&rand) >> 4) % (maxcpu + 1); if (!torture_offline(cpu, &n_offline_attempts, &n_offline_successes,
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 8/18 rcutorture: Add 100-CPU configuration
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The small-system rcutorture configurations have served us well for a great many years, but it is now time to add a larger one. This commit does just that, but does not add it to the defaults in CFLIST. This allows the kvm.sh argument '--configs "4*CFLIST TREE10" to run four instances of each of the default configurations concurrently with one instance of the large configuration.
--- tools/testing/selftests/rcutorture/configs/rcu/TREE10 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tools/testing/selftests/rcutorture/configs/rcu/TREE10
tools/testing/selftests/rcutorture/configs/rcu/TREE10 new file +18 -0
@@ -0,0 +1,18 @@ +CONFIG_SMP=y +CONFIG_NR_CPUS=100 +CONFIG_PREEMPT_NONE=y +CONFIG_PREEMPT_VOLUNTARY=n +CONFIG_PREEMPT=n +#CHECK#CONFIG_TREE_RCU=y +CONFIG_HZ_PERIODIC=n +CONFIG_NO_HZ_IDLE=y +CONFIG_NO_HZ_FULL=n +CONFIG_RCU_FAST_NO_HZ=n +CONFIG_RCU_TRACE=n +CONFIG_RCU_NOCB_CPU=n +CONFIG_DEBUG_LOCK_ALLOC=n +CONFIG_PROVE_LOCKING=n +#CHECK#CONFIG_PROVE_RCU=n +CONFIG_DEBUG_OBJECTS=n +CONFIG_DEBUG_OBJECTS_RCU_HEAD=n +CONFIG_RCU_EXPERT=n
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 9/18 rcutorture: Summarize summary of build and run results
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
When running the default list of tests, the run summary of a successful (that is, failed to find any errors) run fits easily on a 24-line screen. But a run with something like "--configs '5*CFLIST'" will be 80 lines long, and it is all too easy to miss a failure message when scrolling back. This commit therefore prints out the number of runs with failing builds or runtime failures, but only if there are any such failures.
For example, a run with a single build error and a single runtime error would print two lines like this:
1 runs with build errors.
1 runs with runtime errors.
--- tools/testing/selftests/rcutorture/bin/kvm-recheck.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/kvm-recheck.sh +16 -1
@@ -13,6 +13,9 @@ # # Authors: Paul E. McKenney <[email protected]> +T=/tmp/kvm-recheck.sh.$$ +trap 'rm -f $T' 0 2 + PATH=`pwd`/tools/testing/selftests/rcutorture/bin:$PATH; export PATH . functions.sh for rd in "$@"
@@ -68,4 +71,16 @@ do fi done done -EDITOR=echo kvm-find-errors.sh "${@: -1}" > /dev/null 2>&1 +EDITOR=echo kvm-find-errors.sh "${@: -1}" > $T 2>&1 +ret=$? +builderrors="`tr ' ' '\012' < $T | grep -c '/Make.out.diags'`" +if test "$builderrors" -gt 0 +then + echo $builderrors runs with build errors. +fi +runerrors="`tr ' ' '\012' < $T | grep -c '/console.log.diags'`" +if test "$runerrors" -gt 0 +then + echo $runerrors runs with runtime errors. +fi +exit $ret
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 10/18 rcutorture: Make kvm-find-errors.sh abort on bad directory
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
Currently, kvm-find-errors.sh gives a usage prompt when given a bad directory, but then soldiers on, giving a series of confusing error messages. This commit therefore prints an error message and exits when given a bad directory, hopefully reducing confusion.
--- tools/testing/selftests/rcutorture/bin/kvm-find-errors.sh | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/rcutorture/bin/kvm-find-errors.sh +2 -0
@@ -20,7 +20,9 @@ rundir="${1}" if test -z "$rundir" -o ! -d "$rundir" then + echo Directory "$rundir" not found. echo Usage: $0 directory + exit 1 fi editor=${EDITOR-vi}
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 11/18 rcutorture: Fix rcu_torture_one_read()/rcu_torture_writer() data race
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The ->rtort_pipe_count field in the rcu_torture structure checks for too-short grace periods, and is therefore read by rcutorture's readers while being updated by rcutorture's writers. This commit therefore adds the needed READ_ONCE() and WRITE_ONCE() invocations.
This data race was reported by KCSAN. Not appropriate for backporting due to failure being unlikely and due to this being rcutorture.
--- kernel/rcu/rcutorture.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
kernel/rcu/rcutorture.c +6 -4
@@ -375,11 +375,12 @@ rcu_torture_pipe_update_one(struct rcu_torture *rp) {int i; - i = rp->rtort_pipe_count; + i =READ_ONCE (rp->rtort_pipe_count);if (i >RCU_TORTURE_PIPE_LEN ) i =RCU_TORTURE_PIPE_LEN ;atomic_inc (&rcu_torture_wcount[i]); -if (++rp->rtort_pipe_count >=RCU_TORTURE_PIPE_LEN ) { +WRITE_ONCE (rp->rtort_pipe_count, i +1 ); +if (rp->rtort_pipe_count >=RCU_TORTURE_PIPE_LEN ) { rp->rtort_mbtest =0 ;return true; }
@@ -1015,7 +1016,8 @@ rcu_torture_writer(void *arg)if (i >RCU_TORTURE_PIPE_LEN ) i =RCU_TORTURE_PIPE_LEN ;atomic_inc (&rcu_torture_wcount[i]); - old_rp->rtort_pipe_count++; +WRITE_ONCE (old_rp->rtort_pipe_count, + old_rp->rtort_pipe_count +1 );switch (synctype[torture_random (&rand) % nsynctypes]) {case RTWS_DEF_FREE : rcu_torture_writer_state =RTWS_DEF_FREE ;
@@ -1291,7 +1293,7 @@ static bool rcu_torture_one_read(struct torture_random_state *trsp)atomic_inc (&n_rcu_torture_mberror); rtrsp =rcutorture_loop_extend (&readstate, trsp, rtrsp);preempt_disable (); - pipe_count = p->rtort_pipe_count; + pipe_count =READ_ONCE (p->rtort_pipe_count);if (pipe_count >RCU_TORTURE_PIPE_LEN ) {/* Should not happen, but... */ pipe_count =RCU_TORTURE_PIPE_LEN ;
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 12/18 rcutorture: Fix stray access to rcu_fwd_cb_nodelay
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The rcu_fwd_cb_nodelay variable suppresses excessively long read-side delays while carrying out an rcutorture forward-progress test. As such, it is accessed both by readers and updaters, and most of the accesses therefore use *_ONCE(). Except for one in rcu_read_delay(), which this commit fixes.
This data race was reported by KCSAN. Not appropriate for backporting due to this being rcutorture.
--- kernel/rcu/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/rcutorture.c +1 -1
@@ -339,7 +339,7 @@ rcu_read_delay(struct torture_random_state *rrsp, struct rt_read_seg *rtrsp)* period, and we want a long delay occasionally to trigger * force_quiescent_state. */ -if (!rcu_fwd_cb_nodelay && +if (!READ_ONCE (rcu_fwd_cb_nodelay) && !(torture_random (rrsp) % (nrealreaders *2000 * longdelay_ms))) { started = cur_ops->get_gp_seq (); ts =rcu_trace_clock_local ();
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 13/18 rcutorture: Add READ_ONCE() to rcu_torture_count and rcu_torture_batch
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The rcutorture rcu_torture_count and rcu_torture_batch per-CPU variables are read locklessly, so this commit adds the READ_ONCE() to a load in order to avoid various types of compiler vandalism^Woptimization.
This data race was reported by KCSAN. Not appropriate for backporting due to failure being unlikely and due to this being rcutorture.
--- kernel/rcu/rcutorture.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/rcutorture.c +2 -2
@@ -1413,8 +1413,8 @@ rcu_torture_stats_print(void)for_each_possible_cpu (cpu) {for (i =0 ; i <RCU_TORTURE_PIPE_LEN +1 ; i++) { - pipesummary[i] +=per_cpu (rcu_torture_count, cpu)[i]; - batchsummary[i] +=per_cpu (rcu_torture_batch, cpu)[i]; + pipesummary[i] +=READ_ONCE (per_cpu (rcu_torture_count, cpu)[i]); + batchsummary[i] +=READ_ONCE (per_cpu (rcu_torture_batch, cpu)[i]); } }for (i =RCU_TORTURE_PIPE_LEN -1 ; i >=0 ; i--) {
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 14/18 rcutorture: Annotation lockless accesses to rcu_torture_current
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The rcutorture global variable rcu_torture_current is accessed locklessly, so it must use the RCU pointer load/store primitives. This commit therefore adds several that were missed.
This data race was reported by KCSAN. Not appropriate for backporting due to failure being unlikely and due to this being used only by rcutorture.
--- kernel/rcu/rcutorture.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
kernel/rcu/rcutorture.c +6 -4
@@ -1407,6 +1407,7 @@ rcu_torture_stats_print(void)int i;long pipesummary[RCU_TORTURE_PIPE_LEN +1 ] = {0 };long batchsummary[RCU_TORTURE_PIPE_LEN +1 ] = {0 }; +struct rcu_torture *rtcp;static unsigned long rtcv_snap =ULONG_MAX ;static bool splatted;struct task_struct *wtp;
@@ -1423,10 +1424,10 @@ rcu_torture_stats_print(void) }pr_alert ("%s%s " , torture_type,TORTURE_FLAG ); + rtcp =rcu_access_pointer (rcu_torture_current); pr_cont("rtc: %p %s: %lu tfle: %d rta: %d rtaf: %d rtf: %d ", - rcu_torture_current, - rcu_torture_current && !rcu_stall_is_suppressed_at_boot() - ? "ver" : "VER", + rtcp, + rtcp && !rcu_stall_is_suppressed_at_boot() ? "ver" : "VER", rcu_torture_current_version, list_empty(&rcu_torture_freelist), atomic_read(&n_rcu_torture_alloc),
@@ -1482,7 +1483,8 @@ rcu_torture_stats_print(void)if (cur_ops->stats) cur_ops->stats ();if (rtcv_snap == rcu_torture_current_version && - rcu_torture_current !=NULL && !rcu_stall_is_suppressed ()) { +rcu_access_pointer (rcu_torture_current) && + !rcu_stall_is_suppressed ()) {int __maybe_unused flags =0 ;unsigned long __maybe_unused gp_seq =0 ;
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 15/18 rcuperf: Measure memory footprint during kfree_rcu() test
In reply to Paul E. McKenneyFrom: "Joel Fernandes (Google)" <[email protected]>
During changes to kfree_rcu() code, we often check the amount of free memory. As an alternative to checking this manually, this commit adds a measurement in the test itself. It measures four times during the test for available memory, digitally filters these measurements to produce a running average with a weight of 0.5, and compares this digitally filtered value with the amount of available memory at the beginning of the test.
Something like the following is printed at the end of the run:
Total time taken by all kfree'ers: 6369738407 ns, loops: 10000, batches: 764, memory footprint: 216MB
--- kernel/rcu/rcuperf.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
kernel/rcu/rcuperf.c +12 -2
@@ -12,6 +12,7 @@#include <linux/types.h> #include <linux/kernel.h> #include <linux/init.h> +#include <linux/mm.h> #include <linux/module.h> #include <linux/kthread.h> #include <linux/err.h>
@@ -611,6 +612,7 @@ kfree_perf_thread(void *arg)long me = (long )arg;struct kfree_obj *alloc_ptr;u64 start_time, end_time; +long long mem_begin, mem_during =0 ;VERBOSE_PERFOUT_STRING ("kfree_perf_thread task started" );set_cpus_allowed_ptr (current,cpumask_of (me % nr_cpu_ids));
@@ -626,6 +628,12 @@ kfree_perf_thread(void *arg) } do { + if (!mem_during) { + mem_during = mem_begin = si_mem_available(); + } else if (loop % (kfree_loops / 4) == 0) { + mem_during = (mem_during + si_mem_available()) / 2; + } + for (i = 0; i < kfree_alloc_num; i++) { alloc_ptr = kmalloc(sizeof(struct kfree_obj), GFP_KERNEL); if (!alloc_ptr)
@@ -645,9 +653,11 @@ kfree_perf_thread(void *arg)else b_rcu_gp_test_finished = cur_ops->get_gp_seq (); -pr_alert ("Total time taken by all kfree'ers: %llu ns, loops: %d, batches: %ld\n" , +pr_alert ("Total time taken by all kfree'ers: %llu ns, loops: %d, batches: %ld, memory footprint: %lldMB\n" , (unsigned long long )(end_time - start_time), kfree_loops, -rcuperf_seq_diff (b_rcu_gp_test_finished, b_rcu_gp_test_started)); +rcuperf_seq_diff (b_rcu_gp_test_finished, b_rcu_gp_test_started), + (mem_begin - mem_during) >> (20 -PAGE_SHIFT )); +if (shutdown) {smp_mb ();/* Assign before wake. */ wake_up (&shutdown_wq);
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 16/18 rcutorture: Make rcu_torture_barrier_cbs() post from corresponding CPU
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
Currently, rcu_torture_barrier_cbs() posts callbacks from whatever CPU it is running on, which means that all these kthreads might well be posting from the same CPU, which would drastically reduce the effectiveness of this test. This commit therefore uses IPIs to make the callbacks be posted from the corresponding CPU (given by local variable myid).
If the IPI fails (which can happen if the target CPU is offline or does not exist at all), the callback is posted on whatever CPU is currently running.
--- kernel/rcu/rcutorture.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
kernel/rcu/rcutorture.c +13 -3
@@ -2053,6 +2053,14 @@ static void rcu_torture_barrier_cbf(struct rcu_head *rcu)atomic_inc (&barrier_cbs_invoked); } +/* IPI handler to get callback posted on desired CPU, if online. */ +static void rcu_torture_barrier1cb (void *rcu_void) +{ +struct rcu_head *rhp = rcu_void; + + cur_ops->call (rhp, rcu_torture_barrier_cbf); +} +/* kthread function to register callbacks used to test RCU barriers. */ static int rcu_torture_barrier_cbs (void *arg) {
@@ -2076,9 +2084,11 @@ static int rcu_torture_barrier_cbs(void *arg)* The above smp_load_acquire() ensures barrier_phase load * is ordered before the following ->call(). */ -local_irq_disable ();/* Just to test no-irq call_rcu(). */ - cur_ops->call (&rcu, rcu_torture_barrier_cbf); -local_irq_enable (); +if (smp_call_function_single (myid, rcu_torture_barrier1cb, + &rcu,1 )) { +// IPI failed, so use direct call from current CPU. + cur_ops->call (&rcu, rcu_torture_barrier_cbf); + }if (atomic_dec_and_test (&barrier_cbs_count))wake_up (&barrier_wq); }while (!torture_must_stop ());
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 17/18 rcutorture: Manually clean up after rcu_barrier() failure
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
Currently, if rcu_barrier() returns too soon, the test waits 100ms and then does another instance of the test. However, if rcu_barrier() were to have waited for more than 100ms too short a time, this could cause the test's rcu_head structures to be reused while they were still on RCU's callback lists. This can result in knock-on errors that obscure the original rcu_barrier() test failure.
This commit therefore adds code that attempts to wait until all of the test's callbacks have been invoked. Of course, if RCU completely lost track of the corresponding rcu_head structures, this wait could be forever. This commit therefore also complains if this attempted recovery takes more than one second, and it also gives up when the test ends.
--- kernel/rcu/rcutorture.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
kernel/rcu/rcutorture.c +15 -1
@@ -2124,7 +2124,21 @@ static int rcu_torture_barrier(void *arg)pr_err ("barrier_cbs_invoked = %d, n_barrier_cbs = %d\n" ,atomic_read (&barrier_cbs_invoked), n_barrier_cbs); -WARN_ON_ONCE (1 ); +WARN_ON (1 ); +// Wait manually for the remaining callbacks + i =0 ; +do { +if (WARN_ON (i++ >HZ )) + i =INT_MIN ; +schedule_timeout_interruptible (1 ); + cur_ops->cb_barrier (); + }while (atomic_read (&barrier_cbs_invoked) != + n_barrier_cbs && + !torture_must_stop ()); +smp_mb ();// Can't trust ordering if broken. +if (!torture_must_stop ()) +pr_err ("Recovered: barrier_cbs_invoked = %d\n" , +atomic_read (&barrier_cbs_invoked)); }else { n_barrier_successes++; }
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 18/18 rcutorture: Set KCSAN Kconfig options to detect more data races
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit enables the KCSAN Kconfig options that (1) detect data races between reads and writes even when the writes do not change the variable's value and (2) detect data races involving plain C-language writes. These changes only affect scripted rcutorture runs and can be overridden using the kvm.sh --kconfig argument.
--- tools/testing/selftests/rcutorture/configs/rcu/CFcommon | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/rcutorture/configs/rcu/CFcommon +2 -0
@@ -3,3 +3,5 @@ CONFIG_PRINTK_TIME=y CONFIG_HYPERVISOR_GUEST=y CONFIG_PARAVIRT=y CONFIG_KVM_GUEST=y +CONFIG_KCSAN_ASSUME_PLAIN_WRITES_ATOMIC=n +CONFIG_KCSAN_REPORT_VALUE_CHANGE_ONLY=n
Signature · 1 line
2.9.5