Torture-test updates for v5.8
Subsystems (5)
Paul E. McKenney
maintainercover Torture-test updates for v5.8
Hello!
This series contains a variety of torture-test updates:
1. Add KCSAN stubs.
2. Make kvm-recheck-rcu.sh handle truncated lines.
3. Mark data-race potential for rcu_barrier() test statistics.
4. locktorture.c: Fix if-statement empty body warnings, courtesy
of Randy Dunlap.
5. Default enable RCU list lockdep debugging with PROVE_RCU,
courtesy of Madhuparna Bhowmik.
6. Add flag to produce non-busy-wait task stalls.
7. Right-size TREE10 CPU consumption.
8. Allow rcutorture to starve grace-period kthread.
9. Add --kcsan argument to top-level kvm.sh script.
10. Make --kcsan argument also create a summary.
11. Make rcu_fwds and rcu_fwd_emergency_stop static, courtesy of
Jason Yan.
12. Eliminate duplicate #CHECK# from ConfigFragment.
13. Abstract application of additional Kconfig options.
14. Allow --kconfig options to override --kcsan defaults.
15. Allow scenario-specific Kconfig options to override CFcommon.
16. Save a few lines by using config_override_param initially.
17. Add a --kasan argument.
18. Convert ULONG_CMP_LT() to time_before().
Thanx, Paul
------------------------------------------------------------------------
Documentation/admin-guide/kernel-parameters.txt | 12 + include/linux/torture.h | 2 kernel/rcu/Kconfig.debug | 11 - kernel/rcu/rcu.h | 2 kernel/rcu/rcutorture.c | 63 +++++++-- kernel/rcu/tree.c | 27 ++++ tools/testing/selftests/rcutorture/bin/kcsan-collapse.sh | 22 +++ tools/testing/selftests/rcutorture/bin/kvm-recheck-rcu.sh | 16 ++ tools/testing/selftests/rcutorture/bin/kvm-recheck.sh | 9 + tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 90 +++++++------- tools/testing/selftests/rcutorture/bin/kvm.sh | 17 ++ tools/testing/selftests/rcutorture/configs/rcu/TREE10 | 2 12 files changed, 198 insertions(+), 75 deletions(-)
[email protected]
maintainerPATCH 1/18 rcutorture: Add KCSAN stubs
From: "Paul E. McKenney" <[email protected]>
This commit adds stubs for KCSAN's data_race(), ASSERT_EXCLUSIVE_WRITER(), and ASSERT_EXCLUSIVE_ACCESS() macros to allow code using these macros to move ahead.
--- kernel/rcu/rcutorture.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
kernel/rcu/rcutorture.c +12 -0
@@ -51,6 +51,18 @@MODULE_LICENSE ("GPL" );MODULE_AUTHOR ("Paul E. McKenney <[email protected]> and Josh Triplett <[email protected]>" ); +#ifndef data_race +#define data_race (expr) \ + ({ \ + expr; \ + }) +#endif +#ifndef ASSERT_EXCLUSIVE_WRITER +#define ASSERT_EXCLUSIVE_WRITER (var) do { } while (0) +#endif +#ifndef ASSERT_EXCLUSIVE_ACCESS +#define ASSERT_EXCLUSIVE_ACCESS (var) do { } while (0) +#endif /* Bits for ->extendables field, extendables param, and related definitions. */ #define RCUTORTURE_RDR_SHIFT 8/* Put SRCU index in upper bits. */
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 2/18 rcutorture: Make kvm-recheck-rcu.sh handle truncated lines
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
System hangs or killed rcutorture guest OSes can result in truncated "Reader Pipe:" lines, which can in turn result in false-positive reader-batch near-miss warnings. This commit therefore adjusts the reader-batch checks to account for possible line truncation.
--- .../testing/selftests/rcutorture/bin/kvm-recheck-rcu.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/kvm-recheck-rcu.sh +15 -1
@@ -41,7 +41,21 @@ else title="$title ($ngpsps/s)" fi echo $title $stopstate $fwdprog - nclosecalls=`grep --binary-files=text 'torture: Reader Batch' $i/console.log | tail -1 | awk '{for (i=NF-8;i<=NF;i++) sum+=$i; } END {print sum}'` + nclosecalls=`grep --binary-files=text 'torture: Reader Batch' $i/console.log | tail -1 | \ + awk -v sum=0 ' + { + for (i = 0; i <= NF; i++) { + sum += $i; + if ($i ~ /Batch:/) { + sum = 0; + i = i + 2; + } + } + } + + END { + print sum + }'` if test -z "$nclosecalls" then exit 0
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 3/18 rcutorture: Mark data-race potential for rcu_barrier() test statistics
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The n_barrier_successes, n_barrier_attempts, and n_rcu_torture_barrier_error variables are updated (without access markings) by the main rcu_barrier() test kthread, and accessed (also without access markings) by the rcu_torture_stats() kthread. This of course can result in KCSAN complaints.
Because the accesses are in diagnostic prints, this commit uses data_race() to excuse the diagnostic prints from the data race. If this were to ever cause bogus statistics prints (for example, due to store tearing), any misleading information would be disambiguated by the presence or absence of an rcutorture splat.
This data race was reported by KCSAN. Not appropriate for backporting due to failure being unlikely and due to the mild consequences of the failure, namely a confusing rcutorture console message.
--- kernel/rcu/rcutorture.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/rcu/rcutorture.c +3 -3
@@ -1456,9 +1456,9 @@ rcu_torture_stats_print(void) atomic_long_read(&n_rcu_torture_timers));torture_onoff_stats ();pr_cont ("barrier: %ld/%ld:%ld\n" , - n_barrier_successes, - n_barrier_attempts, - n_rcu_torture_barrier_error); +data_race (n_barrier_successes), +data_race (n_barrier_attempts), +data_race (n_rcu_torture_barrier_error));pr_alert ("%s%s " , torture_type,TORTURE_FLAG ); if (atomic_read(&n_rcu_torture_mberror) ||
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 4/18 locktorture.c: Fix if-statement empty body warnings
In reply to Paul E. McKenneyFrom: Randy Dunlap <[email protected]>
When using -Wextra, gcc complains about torture_preempt_schedule() when its definition is empty (i.e., when CONFIG_PREEMPTION is not set/enabled). Fix these warnings by adding an empty do-while block for that macro when CONFIG_PREEMPTION is not set.
Fixes these build warnings:
../kernel/locking/locktorture.c:119:29: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] ../kernel/locking/locktorture.c:166:29: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] ../kernel/locking/locktorture.c:337:29: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] ../kernel/locking/locktorture.c:490:29: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] ../kernel/locking/locktorture.c:528:29: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] ../kernel/locking/locktorture.c:553:29: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
I have verified that there is no object code change (with gcc 7.5.0).
--- include/linux/torture.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/torture.h +1 -1
@@ -89,7 +89,7 @@ void _torture_stop_kthread(char *m, struct task_struct **tp);#ifdef CONFIG_PREEMPTION #define torture_preempt_schedule () preempt_schedule()#else -#define torture_preempt_schedule () +#define torture_preempt_schedule () do { } while (0)#endif #endif /* __LINUX_TORTURE_H */
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 5/18 Default enable RCU list lockdep debugging with PROVE_RCU
In reply to Paul E. McKenneyFrom: Madhuparna Bhowmik <[email protected]>
This patch default enables CONFIG_PROVE_RCU_LIST option with CONFIG_PROVE_RCU for RCU list lockdep debugging.
With this change, RCU list lockdep debugging will be default enabled in CONFIG_PROVE_RCU=y kernels.
Most of the RCU users (in core kernel/, drivers/, and net/ subsystem) have already been modified to include lockdep expressions hence RCU list debugging can be enabled by default.
However, there are still chances of enountering false-positive lockdep splats because not everything is converted, in case RCU list primitives are used in non-RCU read-side critical section but under the protection of a lock. It would be okay to have a few false-positives, as long as bugs are identified, since this patch only affects debugging kernels.
--- kernel/rcu/Kconfig.debug | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
kernel/rcu/Kconfig.debug +3 -8
@@ -9,15 +9,10 @@ config PROVE_RCU def_bool PROVE_LOCKING config PROVE_RCU_LIST - bool "RCU list lockdep debugging" - depends on PROVE_RCU && RCU_EXPERT - default n + def_bool PROVE_RCU help - Enable RCU lockdep checking for list usages. By default it is - turned off since there are several list RCU users that still - need to be converted to pass a lockdep expression. To prevent - false-positive splats, we keep it default disabled but once all - users are converted, we can remove this config option. + Enable RCU lockdep checking for list usages. It is default + enabled with CONFIG_PROVE_RCU. config TORTURE_TEST tristate
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 6/18 rcutorture: Add flag to produce non-busy-wait task stalls
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit aids testing of RCU task stall warning messages by adding an rcutorture.stall_cpu_block module parameter that results in the induced stall sleeping within the RCU read-side critical section. Spinning with interrupts disabled is still available via the rcutorture.stall_cpu_irqsoff module parameter, and specifying neither of these two module parameters will spin with preemption disabled.
Note that sleeping (as opposed to preemption) results in additional complaints from RCU at context-switch time, so yet more testing.
--- Documentation/admin-guide/kernel-parameters.txt | 5 +++++ kernel/rcu/rcutorture.c | 17 +++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +5 -0
@@ -4210,6 +4210,11 @@ Duration of CPU stall (s) to test RCU CPU stall warnings, zero to disable. + rcutorture.stall_cpu_block= [KNL] + Sleep while stalling if set. This will result + in warnings from preemptible RCU in addition + to any other stall-related activity. + rcutorture.stall_cpu_holdoff= [KNL] Time to wait (s) after boot before inducing stall.
kernel/rcu/rcutorture.c +11 -6
@@ -114,6 +114,7 @@ torture_param(int, stall_cpu, 0, "Stall duration (s), zero to disable.");torture_param (int, stall_cpu_holdoff,10 ,"Time to wait before starting stall (s)." );torture_param (int, stall_cpu_irqsoff,0 ,"Disable interrupts while stalling." ); +torture_param (int, stall_cpu_block,0 ,"Sleep while stalling." );torture_param (int, stat_interval,60 ,"Number of seconds between stats printk()s" );torture_param (int, stutter,5 ,"Number of seconds to run/halt test" );
@@ -1548,6 +1549,7 @@ rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, const char *tag)"test_boost=%d/%d test_boost_interval=%d " "test_boost_duration=%d shutdown_secs=%d " "stall_cpu=%d stall_cpu_holdoff=%d stall_cpu_irqsoff=%d " +"stall_cpu_block=%d " "n_barrier_cbs=%d " "onoff_interval=%d onoff_holdoff=%d\n" , torture_type, tag, nrealreaders, nfakewriters,
@@ -1556,6 +1558,7 @@ rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, const char *tag) test_boost, cur_ops->can_boost, test_boost_interval, test_boost_duration, shutdown_secs, stall_cpu, stall_cpu_holdoff, stall_cpu_irqsoff, + stall_cpu_block, n_barrier_cbs, onoff_interval, onoff_holdoff); }
@@ -1611,6 +1614,7 @@ static int rcutorture_booster_init(unsigned int cpu)*/ static int rcu_torture_stall (void *args) { +int idx;unsigned long stop_at;VERBOSE_TOROUT_STRING ("rcu_torture_stall task started" );
@@ -1622,21 +1626,22 @@ static int rcu_torture_stall(void *args)if (!kthread_should_stop ()) { stop_at =ktime_get_seconds () + stall_cpu;/* RCU CPU stall is expected behavior in following code. */ -rcu_read_lock (); + idx = cur_ops->readlock ();if (stall_cpu_irqsoff)local_irq_disable (); -else +else if (!stall_cpu_block)preempt_disable ();pr_alert ("rcu_torture_stall start on CPU %d.\n" , -smp_processor_id ()); +raw_smp_processor_id ());while (ULONG_CMP_LT ((unsigned long )ktime_get_seconds (), stop_at)) -continue ;/* Induce RCU CPU stall warning. */ +if (stall_cpu_block) +schedule_timeout_uninterruptible (HZ );if (stall_cpu_irqsoff)local_irq_enable (); -else +else if (!stall_cpu_block)preempt_enable (); -rcu_read_unlock (); + cur_ops->readunlock (idx);pr_alert ("rcu_torture_stall end.\n" ); }torture_shutdown_absorb ("rcu_torture_stall" );
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 7/18 rcutorture: Right-size TREE10 CPU consumption
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The number of CPUs is tuned to allow "4*CFLIST TREE10" on a large system, up from "3*CFLIST TREE10" previously.
--- tools/testing/selftests/rcutorture/configs/rcu/TREE10 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/rcutorture/configs/rcu/TREE10 +1 -1
@@ -1,5 +1,5 @@ CONFIG_SMP=y -CONFIG_NR_CPUS=100 +CONFIG_NR_CPUS=56 CONFIG_PREEMPT_NONE=y CONFIG_PREEMPT_VOLUNTARY=n CONFIG_PREEMPT=n
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 8/18 rcu: Allow rcutorture to starve grace-period kthread
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit provides an rcutorture.stall_gp_kthread module parameter to allow rcutorture to starve the grace-period kthread. This allows testing the code that detects such starvation.
--- Documentation/admin-guide/kernel-parameters.txt | 7 +++++++ kernel/rcu/rcu.h | 2 ++ kernel/rcu/rcutorture.c | 18 ++++++++++++++--- kernel/rcu/tree.c | 27 +++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 3 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +7 -0
@@ -4221,6 +4221,13 @@ rcutorture.stall_cpu_irqsoff= [KNL] Disable interrupts while stalling if set. + rcutorture.stall_gp_kthread= [KNL] + Duration (s) of forced sleep within RCU + grace-period kthread to test RCU CPU stall + warnings, zero to disable. If both stall_cpu + and stall_gp_kthread are specified, the + kthread is starved first, then the CPU. + rcutorture.stat_interval= [KNL] Time (s) between statistics printk()s.
kernel/rcu/rcu.h +2 -0
@@ -454,6 +454,7 @@ void do_trace_rcu_torture_read(const char *rcutorturename,unsigned long secs, unsigned long c_old, unsigned long c); +void rcu_gp_set_torture_wait (int duration);#else static inline void rcutorture_get_gp_data (enum rcutorture_type test_type,int *flags,unsigned long *gp_seq)
@@ -471,6 +472,7 @@ void do_trace_rcu_torture_read(const char *rcutorturename,#define do_trace_rcu_torture_read (rcutorturename, rhp, secs, c_old, c) \ do { } while (0)#endif +static inline void rcu_gp_set_torture_wait (int duration) { }#endif #if IS_ENABLED (CONFIG_RCU_TORTURE_TEST ) ||IS_MODULE (CONFIG_RCU_TORTURE_TEST )
kernel/rcu/rcutorture.c +15 -3
@@ -115,6 +115,8 @@ torture_param(int, stall_cpu_holdoff, 10, "Time to wait before starting stall (s).");torture_param (int, stall_cpu_irqsoff,0 ,"Disable interrupts while stalling." );torture_param (int, stall_cpu_block,0 ,"Sleep while stalling." ); +torture_param (int, stall_gp_kthread,0 , +"Grace-period kthread stall duration (s)." );torture_param (int, stat_interval,60 ,"Number of seconds between stats printk()s" );torture_param (int, stutter,5 ,"Number of seconds to run/halt test" );
@@ -1623,7 +1625,17 @@ static int rcu_torture_stall(void *args)schedule_timeout_interruptible (stall_cpu_holdoff *HZ );VERBOSE_TOROUT_STRING ("rcu_torture_stall end holdoff" ); } -if (!kthread_should_stop ()) { +if (!kthread_should_stop () && stall_gp_kthread >0 ) { +VERBOSE_TOROUT_STRING ("rcu_torture_stall begin GP stall" ); +rcu_gp_set_torture_wait (stall_gp_kthread *HZ ); +for (idx =0 ; idx < stall_gp_kthread +2 ; idx++) { +if (kthread_should_stop ()) +break ; +schedule_timeout_uninterruptible (HZ ); + } + } +if (!kthread_should_stop () && stall_cpu >0 ) { +VERBOSE_TOROUT_STRING ("rcu_torture_stall begin CPU stall" ); stop_at =ktime_get_seconds () + stall_cpu;/* RCU CPU stall is expected behavior in following code. */ idx = cur_ops->readlock ();
@@ -1642,8 +1654,8 @@ static int rcu_torture_stall(void *args)else if (!stall_cpu_block)preempt_enable (); cur_ops->readunlock (idx); -pr_alert ("rcu_torture_stall end.\n" ); } +pr_alert ("rcu_torture_stall end.\n" );torture_shutdown_absorb ("rcu_torture_stall" );while (!kthread_should_stop ())schedule_timeout_interruptible (10 *HZ );
@@ -1653,7 +1665,7 @@ static int rcu_torture_stall(void *args)/* Spawn CPU-stall kthread, if stall_cpu specified. */ static int __init rcu_torture_stall_init (void ) { -if (stall_cpu <=0 ) +if (stall_cpu <=0 && stall_gp_kthread <=0 )return 0 ;return torture_create_kthread (rcu_torture_stall,NULL , stall_task); }
kernel/rcu/tree.c +27 -0
@@ -1486,6 +1486,31 @@ static void rcu_gp_slow(int delay)schedule_timeout_uninterruptible (delay); } +static unsigned long sleep_duration; + +/* Allow rcutorture to stall the grace-period kthread. */ +void rcu_gp_set_torture_wait (int duration) +{ +if (IS_ENABLED (CONFIG_RCU_TORTURE_TEST ) && duration >0 ) +WRITE_ONCE (sleep_duration, duration); +} +EXPORT_SYMBOL_GPL (rcu_gp_set_torture_wait); + +/* Actually implement the aforementioned wait. */ +static void rcu_gp_torture_wait (void ) +{ +unsigned long duration; + +if (!IS_ENABLED (CONFIG_RCU_TORTURE_TEST )) +return ; + duration =xchg (&sleep_duration,0UL ); +if (duration >0 ) { +pr_alert ("%s: Waiting %lu jiffies\n" , __func__, duration); +schedule_timeout_uninterruptible (duration); +pr_alert ("%s: Wait complete\n" , __func__); + } +} +/* * Initialize a new grace period. Return false if no grace period required. */
@@ -1686,6 +1711,7 @@ static void rcu_gp_fqs_loop(void) rcu_state.gp_state =RCU_GP_WAIT_FQS ; ret =swait_event_idle_timeout_exclusive ( rcu_state.gp_wq,rcu_gp_fqs_check_wake (&gf), j); +rcu_gp_torture_wait (); rcu_state.gp_state =RCU_GP_DOING_FQS ;/* Locking provides needed memory barriers. */ /* If grace period done, leave loop. */
@@ -1834,6 +1860,7 @@ static int __noreturn rcu_gp_kthread(void *unused)swait_event_idle_exclusive (rcu_state.gp_wq,READ_ONCE (rcu_state.gp_flags) &RCU_GP_FLAG_INIT ); +rcu_gp_torture_wait (); rcu_state.gp_state =RCU_GP_DONE_GPS ;/* Locking provides needed memory barrier. */ if (rcu_gp_init ())
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 9/18 torture: Add --kcsan argument to top-level kvm.sh script
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
Although the existing --kconfig argument can be used to run KCSAN for an rcutorture test, it is not as straightforward as one might like:
--kconfig "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"
This commit therefore adds a "--kcsan" argument that emulates the above --kconfig command. Note that if you specify a Kconfig option using -kconfig that conflicts with one that --kcsan adds, you get whatever the script and the build system decide to give you.
--- tools/testing/selftests/rcutorture/bin/kvm.sh | 8 ++++++++ 1 file changed, 8 insertions(+)
tools/testing/selftests/rcutorture/bin/kvm.sh +8 -0
@@ -31,6 +31,7 @@ TORTURE_DEFCONFIG=defconfig TORTURE_BOOT_IMAGE="" TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD TORTURE_KCONFIG_ARG="" +TORTURE_KCONFIG_KCSAN_ARG="" TORTURE_KMAKE_ARG="" TORTURE_QEMU_MEM=512 TORTURE_SHUTDOWN_GRACE=180
@@ -133,6 +134,9 @@ do TORTURE_KCONFIG_ARG="$2" shift ;; + --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) checkarg --kmake-arg "(kernel make arguments)" $# "$2" '.*' '^error$' TORTURE_KMAKE_ARG="$2"
@@ -201,6 +205,9 @@ else exit 1 fi +TORTURE_KCONFIG_ARG="${TORTURE_KCONFIG_ARG} ${TORTURE_KCONFIG_KCSAN_ARG}" +TORTURE_KCONFIG_ARG="`echo ${TORTURE_KCONFIG_ARG} | sed -e 's/^ *//' -e 's/ *$//'`" + CONFIGFRAG=${KVM}/configs/${TORTURE_SUITE}; export CONFIGFRAG defaultconfigs="`tr '\012' ' ' < $CONFIGFRAG/CFLIST`"
@@ -310,6 +317,7 @@ TORTURE_BUILDONLY="$TORTURE_BUILDONLY"; export TORTURE_BUILDONLY TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG TORTURE_INITRD="$TORTURE_INITRD"; export TORTURE_INITRD TORTURE_KCONFIG_ARG="$TORTURE_KCONFIG_ARG"; export TORTURE_KCONFIG_ARG +TORTURE_KCONFIG_KCSAN_ARG="$TORTURE_KCONFIG_KCSAN_ARG"; export TORTURE_KCONFIG_KCSAN_ARG TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG"; export TORTURE_KMAKE_ARG TORTURE_QEMU_CMD="$TORTURE_QEMU_CMD"; export TORTURE_QEMU_CMD TORTURE_QEMU_INTERACTIVE="$TORTURE_QEMU_INTERACTIVE"; export TORTURE_QEMU_INTERACTIVE
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 10/18 torture: Make --kcsan argument also create a summary
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The KCSAN tool emits a great many warnings for current kernels, for example, a one-hour run of the full set of rcutorture scenarios results in no fewer than 3252 such warnings, many of which are duplicates or are otherwise closely related. This commit therefore introduces a kcsan-collapse.sh script that maps these warnings down to a set of function pairs (22 of them given the 3252 individual warnings), placing the resulting list in decreasing order of frequency of occurrence into a kcsan.sum file. If any KCSAN warnings were produced, the pathname of this file is emitted at the end of the summary of the rcutorture runs.
--- .../selftests/rcutorture/bin/kcsan-collapse.sh | 22 ++++++++++++++++++++++ .../selftests/rcutorture/bin/kvm-recheck.sh | 9 +++++++++ tools/testing/selftests/rcutorture/bin/kvm.sh | 1 + 3 files changed, 32 insertions(+) create mode 100755 tools/testing/selftests/rcutorture/bin/kcsan-collapse.sh
tools/testing/selftests/rcutorture/bin/kcsan-collapse.sh new file +22 -0
@@ -0,0 +1,22 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0+ +# +# If this was a KCSAN run, collapse the reports in the various console.log +# files onto pairs of functions. +# +# Usage: kcsan-collapse.sh resultsdir +# +# Copyright (C) 2020 Facebook, Inc. +# +# Authors: Paul E. McKenney <[email protected]> + +if test -z "$TORTURE_KCONFIG_KCSAN_ARG" +then + exit 0 +fi +cat $1/*/console.log | + grep "BUG: KCSAN: " | + sed -e 's/^\[[^]]*] //' | + sort | + uniq -c | + sort -k1nr > $1/kcsan.sum
tools/testing/selftests/rcutorture/bin/kvm-recheck.sh +9 -0
@@ -70,6 +70,15 @@ do fi fi done + if test -f "$rd/kcsan.sum" + then + if test -s "$rd/kcsan.sum" + then + echo KCSAN summary in $rd/kcsan.sum + else + echo Clean KCSAN run in $rd + fi + fi done EDITOR=echo kvm-find-errors.sh "${@: -1}" > $T 2>&1 ret=$?
tools/testing/selftests/rcutorture/bin/kvm.sh +1 -0
@@ -472,6 +472,7 @@ echo echo echo " --- `date` Test summary:" echo Results directory: $resdir/$ds +kcsan-collapse.sh $resdir/$ds kvm-recheck.sh $resdir/$ds ___EOF___
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 11/18 rcutorture: Make rcu_fwds and rcu_fwd_emergency_stop static
In reply to Paul E. McKenneyFrom: Jason Yan <[email protected]>
This commit fixes the following sparse warning:
kernel/rcu/rcutorture.c:1695:16: warning: symbol 'rcu_fwds' was not declared. Should it be static? kernel/rcu/rcutorture.c:1696:6: warning: symbol 'rcu_fwd_emergency_stop' was not declared. Should it be static?
--- kernel/rcu/rcutorture.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/rcutorture.c +2 -2
@@ -1721,8 +1721,8 @@ struct rcu_fwd {unsigned long rcu_launder_gp_seq_start; }; -struct rcu_fwd *rcu_fwds; -bool rcu_fwd_emergency_stop; +static struct rcu_fwd *rcu_fwds; +static bool rcu_fwd_emergency_stop;static void rcu_torture_fwd_cb_hist (struct rcu_fwd *rfp) {
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 12/18 torture: Eliminate duplicate #CHECK# from ConfigFragment
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The #CHECK# directives that can be present in CFcommon and in the rcutorture scenario Kconfig files are both copied to ConfigFragment and grepped out of the two directive files and added to ConfigFragment. This commit therefore removes the redundant "grep" commands and takes advantage of the consequent opportunity to simplify redirection.
--- tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +2 -4
@@ -44,19 +44,17 @@ then fi echo ' ---' `date`: Starting build echo ' ---' Kconfig fragment at: $config_template >> $resdir/log -touch $resdir/ConfigFragment.input $resdir/ConfigFragment +touch $resdir/ConfigFragment.input if test -r "$config_dir/CFcommon" then echo " --- $config_dir/CFcommon" >> $resdir/ConfigFragment.input cat < $config_dir/CFcommon >> $resdir/ConfigFragment.input config_override.sh $config_dir/CFcommon $config_template > $T/Kc1 - grep '#CHECK#' $config_dir/CFcommon >> $resdir/ConfigFragment else cp $config_template $T/Kc1 fi echo " --- $config_template" >> $resdir/ConfigFragment.input cat $config_template >> $resdir/ConfigFragment.input -grep '#CHECK#' $config_template >> $resdir/ConfigFragment if test -n "$TORTURE_KCONFIG_ARG" then echo $TORTURE_KCONFIG_ARG | tr -s " " "\012" > $T/cmdline
@@ -67,7 +65,7 @@ then else cp $T/Kc1 $T/Kc2 fi -cat $T/Kc2 >> $resdir/ConfigFragment +cat $T/Kc2 > $resdir/ConfigFragment base_resdir=`echo $resdir | sed -e 's/\.[0-9]\+$//'` if test "$base_resdir" != "$resdir" -a -f $base_resdir/bzImage -a -f $base_resdir/vmlinux
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 13/18 torture: Abstract application of additional Kconfig options
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit introduces a config_override_param() bash function that folds in an additional set of Kconfig options. This is initially applied to fold in the --kconfig kvm.sh parameter, but later commits will also apply it to the Kconfig options added by the --kcsan kvm.sh parameter.
--- .../selftests/rcutorture/bin/kvm-test-1-run.sh | 31 ++++++++++++++-------- 1 file changed, 20 insertions(+), 11 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +20 -11
@@ -45,6 +45,24 @@ fi echo ' ---' `date`: Starting build echo ' ---' Kconfig fragment at: $config_template >> $resdir/log touch $resdir/ConfigFragment.input + +# Combine additional Kconfig options into an existing set such that newer +# options win. The first argument is the Kconfig source ID, the second +# the source file within $T, the third the destination file within $T, +# and the fourth and final the list of additional Kconfig options. +config_override_param () { + if test -n "$4" + then + echo $4 | sed -e 's/^ *//' -e 's/ *$//' | tr -s " " "\012" > $T/Kconfig_args + echo " --- $1" >> $resdir/ConfigFragment.input + cat $T/Kconfig_args >> $resdir/ConfigFragment.input + config_override.sh $T/$2 $T/Kconfig_args > $T/$3 + # Note that "#CHECK#" is not permitted on commandline. + else + cp $T/$2 $T/$3 + fi +} + if test -r "$config_dir/CFcommon" then echo " --- $config_dir/CFcommon" >> $resdir/ConfigFragment.input
@@ -55,17 +73,8 @@ else fi echo " --- $config_template" >> $resdir/ConfigFragment.input cat $config_template >> $resdir/ConfigFragment.input -if test -n "$TORTURE_KCONFIG_ARG" -then - echo $TORTURE_KCONFIG_ARG | tr -s " " "\012" > $T/cmdline - echo " --- --kconfig argument" >> $resdir/ConfigFragment.input - cat $T/cmdline >> $resdir/ConfigFragment.input - config_override.sh $T/Kc1 $T/cmdline > $T/Kc2 - # Note that "#CHECK#" is not permitted on commandline. -else - cp $T/Kc1 $T/Kc2 -fi -cat $T/Kc2 > $resdir/ConfigFragment +config_override_param "--kconfig argument" Kc1 Kc2 "$TORTURE_KCONFIG_ARG" +cp $T/Kc2 $resdir/ConfigFragment base_resdir=`echo $resdir | sed -e 's/\.[0-9]\+$//'` if test "$base_resdir" != "$resdir" -a -f $base_resdir/bzImage -a -f $base_resdir/vmlinux
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 14/18 torture: Allow --kconfig options to override --kcsan defaults
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
Currently, attempting to override a --kcsan default with a --kconfig option might or might not work. However, it would be good to allow the user to adjust the --kcsan defaults, for example, to specify a different time for CONFIG_KCSAN_REPORT_ONCE_IN_MS. This commit therefore uses the new config_override_param() bash function to apply the --kcsan defaults and then apply the --kconfig options, which allows this overriding to occur.
--- tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 7 ++++--- tools/testing/selftests/rcutorture/bin/kvm.sh | 3 --- 2 files changed, 4 insertions(+), 6 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +4 -3
@@ -73,8 +73,9 @@ else fi echo " --- $config_template" >> $resdir/ConfigFragment.input cat $config_template >> $resdir/ConfigFragment.input -config_override_param "--kconfig argument" Kc1 Kc2 "$TORTURE_KCONFIG_ARG" -cp $T/Kc2 $resdir/ConfigFragment +config_override_param "--kcsan options" Kc1 Kc2 "$TORTURE_KCONFIG_KCSAN_ARG" +config_override_param "--kconfig argument" Kc2 Kc3 "$TORTURE_KCONFIG_ARG" +cp $T/Kc3 $resdir/ConfigFragment base_resdir=`echo $resdir | sed -e 's/\.[0-9]\+$//'` if test "$base_resdir" != "$resdir" -a -f $base_resdir/bzImage -a -f $base_resdir/vmlinux
@@ -87,7 +88,7 @@ then ln -s $base_resdir/.config $resdir # for kvm-recheck.sh # Arch-independent indicator touch $resdir/builtkernel -elif kvm-build.sh $T/Kc2 $resdir +elif kvm-build.sh $T/Kc3 $resdir then # Had to build a kernel for this test. QEMU="`identify_qemu vmlinux`"
tools/testing/selftests/rcutorture/bin/kvm.sh +0 -3
@@ -205,9 +205,6 @@ else exit 1 fi -TORTURE_KCONFIG_ARG="${TORTURE_KCONFIG_ARG} ${TORTURE_KCONFIG_KCSAN_ARG}" -TORTURE_KCONFIG_ARG="`echo ${TORTURE_KCONFIG_ARG} | sed -e 's/^ *//' -e 's/ *$//'`" - CONFIGFRAG=${KVM}/configs/${TORTURE_SUITE}; export CONFIGFRAG defaultconfigs="`tr '\012' ' ' < $CONFIGFRAG/CFLIST`"
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 15/18 torture: Allow scenario-specific Kconfig options to override CFcommon
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit applies config_override_param() to allow scenario-specific Kconfig options to override those in CFcommon. This in turn will allow additional Kconfig options to be placed in CFcommon, for example, an option common to all but a few scenario can be placed in CFcommon and then overridden in those few scenarios. Plus this change saves one whole line of code.
--- tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +3 -4
@@ -67,12 +67,11 @@ if test -r "$config_dir/CFcommon" then echo " --- $config_dir/CFcommon" >> $resdir/ConfigFragment.input cat < $config_dir/CFcommon >> $resdir/ConfigFragment.input - config_override.sh $config_dir/CFcommon $config_template > $T/Kc1 + cp $config_dir/CFcommon $T/Kc0 else - cp $config_template $T/Kc1 + echo > $T/Kc0 fi -echo " --- $config_template" >> $resdir/ConfigFragment.input -cat $config_template >> $resdir/ConfigFragment.input +config_override_param "$config_template" Kc0 Kc1 "`cat $config_template 2> /dev/null`" config_override_param "--kcsan options" Kc1 Kc2 "$TORTURE_KCONFIG_KCSAN_ARG" config_override_param "--kconfig argument" Kc2 Kc3 "$TORTURE_KCONFIG_ARG" cp $T/Kc3 $resdir/ConfigFragment
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 16/18 torture: Save a few lines by using config_override_param initially
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit saves a few lines of code by also using the bash config_override_param() to set the initial list of Kconfig options from the CFcommon file. While in the area, it makes this function capable of update-in-place on the file containing the cumulative Kconfig options, thus avoiding annoying changes when adding another source of options.
--- .../selftests/rcutorture/bin/kvm-test-1-run.sh | 38 +++++++++------------- 1 file changed, 16 insertions(+), 22 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +16 -22
@@ -46,35 +46,29 @@ echo ' ---' `date`: Starting build echo ' ---' Kconfig fragment at: $config_template >> $resdir/log touch $resdir/ConfigFragment.input -# Combine additional Kconfig options into an existing set such that newer -# options win. The first argument is the Kconfig source ID, the second -# the source file within $T, the third the destination file within $T, -# and the fourth and final the list of additional Kconfig options. +# Combine additional Kconfig options into an existing set such that +# newer options win. The first argument is the Kconfig source ID, the +# second the to-be-updated file within $T, and the third and final the +# list of additional Kconfig options. Note that a $2.tmp file is +# created when doing the update. config_override_param () { - if test -n "$4" + if test -n "$3" then - echo $4 | sed -e 's/^ *//' -e 's/ *$//' | tr -s " " "\012" > $T/Kconfig_args + echo $3 | sed -e 's/^ *//' -e 's/ *$//' | tr -s " " "\012" > $T/Kconfig_args echo " --- $1" >> $resdir/ConfigFragment.input cat $T/Kconfig_args >> $resdir/ConfigFragment.input - config_override.sh $T/$2 $T/Kconfig_args > $T/$3 + config_override.sh $T/$2 $T/Kconfig_args > $T/$2.tmp + mv $T/$2.tmp $T/$2 # Note that "#CHECK#" is not permitted on commandline. - else - cp $T/$2 $T/$3 fi } -if test -r "$config_dir/CFcommon" -then - echo " --- $config_dir/CFcommon" >> $resdir/ConfigFragment.input - cat < $config_dir/CFcommon >> $resdir/ConfigFragment.input - cp $config_dir/CFcommon $T/Kc0 -else - echo > $T/Kc0 -fi -config_override_param "$config_template" Kc0 Kc1 "`cat $config_template 2> /dev/null`" -config_override_param "--kcsan options" Kc1 Kc2 "$TORTURE_KCONFIG_KCSAN_ARG" -config_override_param "--kconfig argument" Kc2 Kc3 "$TORTURE_KCONFIG_ARG" -cp $T/Kc3 $resdir/ConfigFragment +echo > $T/KcList +config_override_param "$config_dir/CFcommon" KcList "`cat $config_dir/CFcommon 2> /dev/null`" +config_override_param "$config_template" KcList "`cat $config_template 2> /dev/null`" +config_override_param "--kcsan options" KcList "$TORTURE_KCONFIG_KCSAN_ARG" +config_override_param "--kconfig argument" KcList "$TORTURE_KCONFIG_ARG" +cp $T/KcList $resdir/ConfigFragment base_resdir=`echo $resdir | sed -e 's/\.[0-9]\+$//'` if test "$base_resdir" != "$resdir" -a -f $base_resdir/bzImage -a -f $base_resdir/vmlinux
@@ -87,7 +81,7 @@ then ln -s $base_resdir/.config $resdir # for kvm-recheck.sh # Arch-independent indicator touch $resdir/builtkernel -elif kvm-build.sh $T/Kc3 $resdir +elif kvm-build.sh $T/KcList $resdir then # Had to build a kernel for this test. QEMU="`identify_qemu vmlinux`"
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 17/18 torture: Add a --kasan argument
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
Make it a bit easier to apply KASAN to rcutorture runs with a new --kasan argument, again leveraging the config_override_param() bash function.
--- tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 1 + tools/testing/selftests/rcutorture/bin/kvm.sh | 5 +++++ 2 files changed, 6 insertions(+)
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +1 -0
@@ -66,6 +66,7 @@ config_override_param () { echo > $T/KcList config_override_param "$config_dir/CFcommon" KcList "`cat $config_dir/CFcommon 2> /dev/null`" config_override_param "$config_template" KcList "`cat $config_template 2> /dev/null`" +config_override_param "--kasan options" KcList "$TORTURE_KCONFIG_KASAN_ARG" config_override_param "--kcsan options" KcList "$TORTURE_KCONFIG_KCSAN_ARG" config_override_param "--kconfig argument" KcList "$TORTURE_KCONFIG_ARG" cp $T/KcList $resdir/ConfigFragment
tools/testing/selftests/rcutorture/bin/kvm.sh +5 -0
@@ -31,6 +31,7 @@ TORTURE_DEFCONFIG=defconfig TORTURE_BOOT_IMAGE="" TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD TORTURE_KCONFIG_ARG="" +TORTURE_KCONFIG_KASAN_ARG="" TORTURE_KCONFIG_KCSAN_ARG="" TORTURE_KMAKE_ARG="" TORTURE_QEMU_MEM=512
@@ -134,6 +135,9 @@ do TORTURE_KCONFIG_ARG="$2" shift ;; + --kasan) + TORTURE_KCONFIG_KASAN_ARG="CONFIG_DEBUG_INFO=y CONFIG_KASAN=y"; export TORTURE_KCONFIG_KASAN_ARG + ;; --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 ;;
@@ -314,6 +318,7 @@ TORTURE_BUILDONLY="$TORTURE_BUILDONLY"; export TORTURE_BUILDONLY TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG TORTURE_INITRD="$TORTURE_INITRD"; export TORTURE_INITRD TORTURE_KCONFIG_ARG="$TORTURE_KCONFIG_ARG"; export TORTURE_KCONFIG_ARG +TORTURE_KCONFIG_KASAN_ARG="$TORTURE_KCONFIG_KASAN_ARG"; export TORTURE_KCONFIG_KASAN_ARG TORTURE_KCONFIG_KCSAN_ARG="$TORTURE_KCONFIG_KCSAN_ARG"; export TORTURE_KCONFIG_KCSAN_ARG TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG"; export TORTURE_KMAKE_ARG TORTURE_QEMU_CMD="$TORTURE_QEMU_CMD"; export TORTURE_QEMU_CMD
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 18/18 rcutorture: Convert ULONG_CMP_LT() to time_before()
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit converts three ULONG_CMP_LT() invocations in rcutorture to time_before() to reflect the fact that they are comparing timestamps to the jiffies counter.
--- kernel/rcu/rcutorture.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/rcu/rcutorture.c +3 -3
@@ -848,7 +848,7 @@ static int rcu_torture_boost(void *arg)/* Wait for the next test interval. */ oldstarttime = boost_starttime; -while (ULONG_CMP_LT (jiffies, oldstarttime)) { +while (time_before (jiffies, oldstarttime)) {schedule_timeout_interruptible (oldstarttime - jiffies);stutter_wait ("rcu_torture_boost" );if (torture_must_stop ())
@@ -858,7 +858,7 @@ static int rcu_torture_boost(void *arg)/* Do one boost-test interval. */ endtime = oldstarttime + test_boost_duration *HZ ; call_rcu_time = jiffies; -while (ULONG_CMP_LT (jiffies, endtime)) { +while (time_before (jiffies, endtime)) {/* If we don't have a callback in flight, post one. */ if (!smp_load_acquire (&rbi.inflight)) {/* RCU core before ->inflight = 1. */
@@ -929,7 +929,7 @@ rcu_torture_fqs(void *arg)VERBOSE_TOROUT_STRING ("rcu_torture_fqs task started" ); do { fqs_resume_time = jiffies + fqs_stutter * HZ; - while (ULONG_CMP_LT(jiffies, fqs_resume_time) && + while (time_before(jiffies, fqs_resume_time) && !kthread_should_stop()) { schedule_timeout_interruptible(1); }
Signature · 1 line
2.9.5