Torture-test updates for v5.10
Subsystems (5)
Paul E. McKenney
maintainercover Torture-test updates for v5.10
Hello!
This series provides torture-test updates for v5.10:
1. Remove KCSAN stubs from rcutorture.c.
2. Output number of elapsed grace periods.
3. document --allcpus argument added to the kvm.sh script.
4. Make function torture_percpu_rwsem_init() static.
5. Replace HTTP links with HTTPS ones.
6. Update initrd documentation.
7. Add CONFIG_PROVE_RCU_LIST to TREE05.
8. Add kvm.sh --help and update help message.
9. Properly set rcu_fwds for OOM handling.
10. Properly synchronize with OOM notifier.
11. Avoid null pointer dereference when buf fails to allocate.
12. Hoist OOM registry up one level.
13. Allow pointer leaks to test diagnostic code.
14. Add gdb support.
Thanx, Paul
------------------------------------------------------------------------
Documentation/admin-guide/kernel-parameters.txt | 12 ++ kernel/locking/locktorture.c | 2 kernel/rcu/rcutorture.c | 61 +++++++++----- kernel/rcu/refscale.c | 8 + tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 33 +++++-- tools/testing/selftests/rcutorture/bin/kvm.sh | 30 ++++++ tools/testing/selftests/rcutorture/configs/rcu/TREE05 | 1 tools/testing/selftests/rcutorture/doc/initrd.txt | 36 +------- tools/testing/selftests/rcutorture/doc/rcu-test-image.txt | 41 +++++++-- 9 files changed, 154 insertions(+), 70 deletions(-)
[email protected]
maintainerPATCH 1/14 rcutorture: Remove KCSAN stubs
From: "Paul E. McKenney" <[email protected]>
KCSAN is now in mainline, so this commit removes the stubs for the data_race(), ASSERT_EXCLUSIVE_WRITER(), and ASSERT_EXCLUSIVE_ACCESS() macros.
--- kernel/rcu/rcutorture.c | 13 ------------- 1 file changed, 13 deletions(-)
kernel/rcu/rcutorture.c +0 -13
@@ -52,19 +52,6 @@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. */ #define RCUTORTURE_RDR_MASK ((1 << RCUTORTURE_RDR_SHIFT) - 1)
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 2/14 rcutorture: Output number of elapsed grace periods
In reply to Paul E. McKenneyFrom: "Joel Fernandes (Google)" <[email protected]>
This commit adds code to print the grace-period number at the start of the test along with both the grace-period number and the number of elapsed grace periods at the end of the test. Note that variants of RCU)without the notion of a grace-period number (for example, Tiny RCU) just print zeroes.
--- kernel/rcu/rcutorture.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
kernel/rcu/rcutorture.c +11 -2
@@ -172,6 +172,7 @@ static long n_barrier_successes; /* did rcu_barrier test succeed? */static unsigned long n_read_exits;static struct list_head rcu_torture_removed;static unsigned long shutdown_jiffies; +static unsigned long start_gp_seq;static int rcu_torture_writer_state;#define RTWS_FIXED_DELAY 0
@@ -2469,8 +2470,9 @@ rcu_torture_cleanup(void)rcutorture_get_gp_data (cur_ops->ttype, &flags, &gp_seq);srcutorture_get_gp_data (cur_ops->ttype, srcu_ctlp, &flags, &gp_seq); -pr_alert ("%s: End-test grace-period state: g%lu f%#x\n" , - cur_ops->name, gp_seq, flags); +pr_alert ("%s: End-test grace-period state: g%ld f%#x total-gps=%ld\n" , + cur_ops->name, (long )gp_seq, flags, +rcutorture_seq_diff (gp_seq, start_gp_seq));torture_stop_kthread (rcu_torture_stats, stats_task);torture_stop_kthread (rcu_torture_fqs, fqs_task);if (rcu_torture_can_boost ())
@@ -2594,6 +2596,8 @@ rcu_torture_init(void)long i;int cpu;int firsterr =0 ; +int flags =0 ; +unsigned long gp_seq =0 ;static struct rcu_torture_ops *torture_ops[] = { &rcu_ops, &rcu_busted_ops, &srcu_ops, &srcud_ops, &busted_srcud_ops, &tasks_ops, &tasks_rude_ops,
@@ -2636,6 +2640,11 @@ rcu_torture_init(void) nrealreaders =1 ; }rcu_torture_print_module_parms (cur_ops,"Start of test" ); +rcutorture_get_gp_data (cur_ops->ttype, &flags, &gp_seq); +srcutorture_get_gp_data (cur_ops->ttype, srcu_ctlp, &flags, &gp_seq); + start_gp_seq = gp_seq; +pr_alert ("%s: Start-test grace-period state: g%ld f%#x\n" , + cur_ops->name, (long )gp_seq, flags);/* Set up the freelist. */
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 3/14 torture: document --allcpus argument added to the kvm.sh script
In reply to Paul E. McKenneyFrom: Paul Gortmaker <[email protected]>
--- tools/testing/selftests/rcutorture/bin/kvm.sh | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/rcutorture/bin/kvm.sh +1 -0
@@ -46,6 +46,7 @@ jitter="-1" usage () { echo "Usage: $scriptname optional arguments:" + echo " --allcpus" echo " --bootargs kernel-boot-arguments" echo " --bootimage relative-path-to-kernel-boot-image" echo " --buildonly"
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 4/14 locktorture: Make function torture_percpu_rwsem_init() static
In reply to Paul E. McKenneyFrom: Wei Yongjun <[email protected]>
The sparse tool complains as follows:
kernel/locking/locktorture.c:569:6: warning:
symbol 'torture_percpu_rwsem_init' was not declared. Should it be static?
And this function is not used outside of locktorture.c, so this commit marks it static.
--- kernel/locking/locktorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/locking/locktorture.c +1 -1
@@ -566,7 +566,7 @@ static struct lock_torture_ops rwsem_lock_ops = {#include <linux/percpu-rwsem.h> static struct percpu_rw_semaphore pcpu_rwsem; -void torture_percpu_rwsem_init (void ) +static void torture_percpu_rwsem_init (void ) {BUG_ON (percpu_init_rwsem (&pcpu_rwsem)); }
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 5/14 rcutorture: Replace HTTP links with HTTPS ones
In reply to Paul E. McKenneyFrom: "Alexander A. Klimov" <[email protected]>
Rationale:
Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate.
Deterministic algorithm:
For each file:
If not .svg:
For each line:
If doesn't contain \bxmlns\b:
For each link, \bhttp://[^# \t\r\n]*(?:\w|/):
If neither \bgnu\.org/license, nor \bmozilla\.org/MPL\b:
If both the HTTP and HTTPS versions
return 200 OK and serve the same content:
Replace HTTP with HTTPS.
--- tools/testing/selftests/rcutorture/doc/rcu-test-image.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/rcutorture/doc/rcu-test-image.txt +3 -3
@@ -36,7 +36,7 @@ References: https://help.ubuntu.com/community/JeOSVMBuilder http://wiki.libvirt.org/page/UbuntuKVMWalkthrough http://www.moe.co.uk/2011/01/07/pci_add_option_rom-failed-to-find-romfile-pxe-rtl8139-bin/ -- "apt-get install kvm-pxe" - http://www.landley.net/writing/rootfs-howto.html - http://en.wikipedia.org/wiki/Initrd - http://en.wikipedia.org/wiki/Cpio + https://www.landley.net/writing/rootfs-howto.html + https://en.wikipedia.org/wiki/Initrd + https://en.wikipedia.org/wiki/Cpio http://wiki.libvirt.org/page/UbuntuKVMWalkthrough
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 6/14 torture: Update initrd documentation
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The rcu-test-image.txt documentation covers a very uncommon case where a real userspace environment is required. However, someone reading this document might reasonably conclude that this is in fact a prerequisite. In addition, the initrd.txt file mentions dracut, which is no longer used. This commit therefore provides the needed updates.
--- tools/testing/selftests/rcutorture/doc/initrd.txt | 36 +++++----------------- .../selftests/rcutorture/doc/rcu-test-image.txt | 35 ++++++++++++++++++--- 2 files changed, 37 insertions(+), 34 deletions(-)
tools/testing/selftests/rcutorture/doc/initrd.txt +7 -29
@@ -1,12 +1,11 @@ -The rcutorture scripting tools automatically create the needed initrd -directory using dracut. Failing that, this tool will create an initrd -containing a single statically linked binary named "init" that loops -over a very long sleep() call. In both cases, this creation is done -by tools/testing/selftests/rcutorture/bin/mkinitrd.sh. +The rcutorture scripting tools automatically create an initrd containing +a single statically linked binary named "init" that loops over a +very long sleep() call. In both cases, this creation is done by +tools/testing/selftests/rcutorture/bin/mkinitrd.sh. -However, if you are attempting to run rcutorture on a system that does -not have dracut installed, and if you don't like the notion of static -linking, you might wish to press an existing initrd into service: +However, if you don't like the notion of statically linked bare-bones +userspace environments, you might wish to press an existing initrd +into service: ------------------------------------------------------------------------ cd tools/testing/selftests/rcutorture
@@ -15,24 +14,3 @@ mkdir initrd cd initrd cpio -id < /tmp/initrd.img.zcat # Manually verify that initrd contains needed binaries and libraries. ------------------------------------------------------------------------- - -Interestingly enough, if you are running rcutorture, you don't really -need userspace in many cases. Running without userspace has the -advantage of allowing you to test your kernel independently of the -distro in place, the root-filesystem layout, and so on. To make this -happen, put the following script in the initrd's tree's "/init" file, -with 0755 mode. - ------------------------------------------------------------------------- -#!/bin/sh - -while : -do - sleep 10 -done ------------------------------------------------------------------------- - -This approach also allows most of the binaries and libraries in the -initrd filesystem to be dispensed with, which can save significant -space in rcutorture's "res" directory.
tools/testing/selftests/rcutorture/doc/rcu-test-image.txt +30 -5
@@ -1,8 +1,33 @@ -This document describes one way to create the rcu-test-image file -that contains the filesystem used by the guest-OS kernel. There are -probably much better ways of doing this, and this filesystem could no -doubt be smaller. It is probably also possible to simply download -an appropriate image from any number of places. +Normally, a minimal initrd is created automatically by the rcutorture +scripting. But minimal really does mean "minimal", namely just a single +root directory with a single statically linked executable named "init": + +$ size tools/testing/selftests/rcutorture/initrd/init + text data bss dec hex filename + 328 0 8 336 150 tools/testing/selftests/rcutorture/initrd/init + +Suppose you need to run some scripts, perhaps to monitor or control +some aspect of the rcutorture testing. This will require a more fully +filled-out userspace, perhaps containing libraries, executables for +the shell and other utilities, and soforth. In that case, place your +desired filesystem here: + + tools/testing/selftests/rcutorture/initrd + +For example, your tools/testing/selftests/rcutorture/initrd/init might +be a script that does any needed mount operations and starts whatever +scripts need starting to properly monitor or control your testing. +The next rcutorture build will then incorporate this filesystem into +the kernel image that is passed to qemu. + +Or maybe you need a real root filesystem for some reason, in which case +please read on! + +The remainder of this document describes one way to create the +rcu-test-image file that contains the filesystem used by the guest-OS +kernel. There are probably much better ways of doing this, and this +filesystem could no doubt be smaller. It is probably also possible to +simply download an appropriate image from any number of places. That said, here are the commands:
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 7/14 rcutorture: Add CONFIG_PROVE_RCU_LIST to TREE05
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
Currently, the CONFIG_PROVE_RCU_LIST=y case is untested. This commit therefore adds CONFIG_PROVE_RCU_LIST=y to rcutorture's TREE05 scenario.
--- tools/testing/selftests/rcutorture/configs/rcu/TREE05 | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/rcutorture/configs/rcu/TREE05 +1 -0
@@ -16,5 +16,6 @@ CONFIG_RCU_NOCB_CPU=y CONFIG_DEBUG_LOCK_ALLOC=y CONFIG_PROVE_LOCKING=y #CHECK#CONFIG_PROVE_RCU=y +CONFIG_PROVE_RCU_LIST=y CONFIG_DEBUG_OBJECTS_RCU_HEAD=n CONFIG_RCU_EXPERT=y
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 8/14 torture: Add kvm.sh --help and update help message
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit adds a --help argument (along with its synonym -h) to display the help text. While in the area, this commit also updates the help text.
--- tools/testing/selftests/rcutorture/bin/kvm.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm.sh +6 -2
@@ -56,17 +56,18 @@ usage () { echo " --defconfig string" echo " --dryrun sched|script" echo " --duration minutes" + echo " --help" echo " --interactive" echo " --jitter N [ maxsleep (us) [ maxspin (us) ] ]" echo " --kconfig Kconfig-options" echo " --kmake-arg kernel-make-arguments" echo " --mac nn:nn:nn:nn:nn:nn" - echo " --memory megabytes | nnnG" + echo " --memory megabytes|nnnG" echo " --no-initrd" echo " --qemu-args qemu-arguments" echo " --qemu-cmd qemu-system-..." echo " --results absolute-pathname" - echo " --torture rcu" + echo " --torture lock|rcu|rcuperf|refscale|scf" echo " --trust-make" exit 1 }
@@ -127,6 +128,9 @@ do dur=$(($2*60)) shift ;; + --help|-h) + usage + ;; --interactive) TORTURE_QEMU_INTERACTIVE=1; export TORTURE_QEMU_INTERACTIVE ;;
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 9/14 rcutorture: Properly set rcu_fwds for OOM handling
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The conversion of rcu_fwds to dynamic allocation failed to actually allocate the required structure. This commit therefore allocates it, frees it, and updates rcu_fwds accordingly. While in the area, it abstracts the cleanup actions into rcu_torture_fwd_prog_cleanup().
--- kernel/rcu/rcutorture.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
kernel/rcu/rcutorture.c +12 -1
@@ -2148,9 +2148,20 @@ static int __init rcu_torture_fwd_prog_init(void)return -ENOMEM ;spin_lock_init (&rfp->rcu_fwd_lock); rfp->rcu_fwd_cb_tail = &rfp->rcu_fwd_cb_head; + rcu_fwds = rfp;return torture_create_kthread (rcu_torture_fwd_prog, rfp, fwd_prog_task); } +static void rcu_torture_fwd_prog_cleanup (void ) +{ +struct rcu_fwd *rfp; + +torture_stop_kthread (rcu_torture_fwd_prog, fwd_prog_task); + rfp = rcu_fwds; + rcu_fwds =NULL ; +kfree (rfp); +} +/* Callback function for RCU barrier testing. */ static void rcu_torture_barrier_cbf (struct rcu_head *rcu) {
@@ -2448,7 +2459,7 @@ rcu_torture_cleanup(void)show_rcu_gp_kthreads ();rcu_torture_read_exit_cleanup ();rcu_torture_barrier_cleanup (); -torture_stop_kthread (rcu_torture_fwd_prog, fwd_prog_task); +rcu_torture_fwd_prog_cleanup ();torture_stop_kthread (rcu_torture_stall, stall_task);torture_stop_kthread (rcu_torture_writer, writer_task);
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 10/14 rcutorture: Properly synchronize with OOM notifier
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The current rcutorture forward-progress code assumes that it is the only cause of out-of-memory (OOM) events. For script-based rcutorture testing, this assumption is in fact correct. However, testing based on modprobe/rmmod might well encounter external OOM events, which could happen at any time.
This commit therefore properly synchronizes the interaction between rcutorture's forward-progress testing and its OOM notifier by adding a global mutex.
--- kernel/rcu/rcutorture.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
kernel/rcu/rcutorture.c +13 -1
@@ -1796,6 +1796,7 @@ struct rcu_fwd {unsigned long rcu_launder_gp_seq_start; }; +static DEFINE_MUTEX (rcu_fwd_mutex);static struct rcu_fwd *rcu_fwds;static bool rcu_fwd_emergency_stop;
@@ -2062,8 +2063,14 @@ static void rcu_torture_fwd_prog_cr(struct rcu_fwd *rfp)static int rcutorture_oom_notify (struct notifier_block *self,unsigned long notused,void *nfreed) { -struct rcu_fwd *rfp = rcu_fwds; +struct rcu_fwd *rfp; +mutex_lock (&rcu_fwd_mutex); + rfp = rcu_fwds; +if (!rfp) { +mutex_unlock (&rcu_fwd_mutex); +return NOTIFY_OK ; + }WARN (1 ,"%s invoked upon OOM during forward-progress testing.\n" , __func__);rcu_torture_fwd_cb_hist (rfp);
@@ -2081,6 +2088,7 @@ static int rcutorture_oom_notify(struct notifier_block *self,smp_mb ();/* Frees before return to avoid redoing OOM. */ (*(unsigned long *)nfreed)++;/* Forward progress CBs freed! */ pr_info ("%s returning after OOM processing.\n" , __func__); +mutex_unlock (&rcu_fwd_mutex);return NOTIFY_OK ; }
@@ -2148,7 +2156,9 @@ static int __init rcu_torture_fwd_prog_init(void)return -ENOMEM ;spin_lock_init (&rfp->rcu_fwd_lock); rfp->rcu_fwd_cb_tail = &rfp->rcu_fwd_cb_head; +mutex_lock (&rcu_fwd_mutex); rcu_fwds = rfp; +mutex_unlock (&rcu_fwd_mutex);return torture_create_kthread (rcu_torture_fwd_prog, rfp, fwd_prog_task); }
@@ -2158,7 +2168,9 @@ static void rcu_torture_fwd_prog_cleanup(void)torture_stop_kthread (rcu_torture_fwd_prog, fwd_prog_task); rfp = rcu_fwds; +mutex_lock (&rcu_fwd_mutex); rcu_fwds =NULL ; +mutex_unlock (&rcu_fwd_mutex);kfree (rfp); }
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 11/14 refperf: Avoid null pointer dereference when buf fails to allocate
In reply to Paul E. McKenneyFrom: Colin Ian King <[email protected]>
Currently in the unlikely event that buf fails to be allocated it is dereferenced a few times. Use the errexit flag to determine if buf should be written to to avoid the null pointer dereferences.
Addresses-Coverity: ("Dereference after null check")
--- kernel/rcu/refscale.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
kernel/rcu/refscale.c +5 -3
@@ -546,9 +546,11 @@ static int main_func(void *arg)// Print the average of all experiments SCALEOUT ("END OF TEST. Calculating average duration per loop (nanoseconds)...\n" ); - buf[0 ] =0 ; -strcat (buf,"\n" ); -strcat (buf,"Runs\tTime(ns)\n" ); +if (!errexit) { + buf[0 ] =0 ; +strcat (buf,"\n" ); +strcat (buf,"Runs\tTime(ns)\n" ); + }for (exp =0 ; exp < nruns; exp++) {u64 avg;
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 12/14 rcutorture: Hoist OOM registry up one level
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
Currently, registering and unregistering the OOM notifier is done right before and after the test, respectively. This will not work well for multi-threaded tests, so this commit hoists this registering and unregistering up into the rcu_torture_fwd_prog_init() and rcu_torture_fwd_prog_cleanup() functions.
--- kernel/rcu/rcutorture.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/rcutorture.c +2 -2
@@ -2110,13 +2110,11 @@ static int rcu_torture_fwd_prog(void *args) do { schedule_timeout_interruptible(fwd_progress_holdoff * HZ); WRITE_ONCE(rcu_fwd_emergency_stop, false); - register_oom_notifier(&rcutorture_oom_nb); 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. */ stutter_wait("rcu_torture_fwd_prog");
@@ -2159,6 +2157,7 @@ static int __init rcu_torture_fwd_prog_init(void)mutex_lock (&rcu_fwd_mutex); rcu_fwds = rfp;mutex_unlock (&rcu_fwd_mutex); +register_oom_notifier (&rcutorture_oom_nb);return torture_create_kthread (rcu_torture_fwd_prog, rfp, fwd_prog_task); }
@@ -2171,6 +2170,7 @@ static void rcu_torture_fwd_prog_cleanup(void)mutex_lock (&rcu_fwd_mutex); rcu_fwds =NULL ;mutex_unlock (&rcu_fwd_mutex); +unregister_oom_notifier (&rcutorture_oom_nb);kfree (rfp); }
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 13/14 rcutorture: Allow pointer leaks to test diagnostic code
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit adds an rcutorture.leakpointer module parameter that intentionally leaks an RCU-protected pointer out of the RCU read-side critical section and checks to see if the corresponding grace period has elapsed, emitting a WARN_ON_ONCE() if so. This module parameter can be used to test facilities like CONFIG_RCU_STRICT_GRACE_PERIOD that end grace periods quickly.
While in the area, also document rcutorture.irqreader, which was previously left out.
Reported-by Jann Horn <[email protected]>
--- Documentation/admin-guide/kernel-parameters.txt | 12 ++++++++++++ kernel/rcu/rcutorture.c | 4 ++++ 2 files changed, 16 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +12 -0
@@ -4269,6 +4269,18 @@ are zero, rcutorture acts as if is interpreted they are all non-zero. + rcutorture.irqreader= [KNL] + Run RCU readers from irq handlers, or, more + accurately, from a timer handler. Not all RCU + flavors take kindly to this sort of thing. + + rcutorture.leakpointer= [KNL] + Leak an RCU-protected pointer out of the reader. + This can of course result in splats, and is + intended to test the ability of things like + CONFIG_RCU_STRICT_GRACE_PERIOD=y to detect + such leaks. + rcutorture.n_barrier_cbs= [KNL] Set callbacks/threads for rcu_barrier() testing.
kernel/rcu/rcutorture.c +4 -0
@@ -87,6 +87,7 @@ torture_param(bool, gp_normal, false, "Use normal (non-expedited) GP wait primitives");torture_param (bool, gp_sync, false,"Use synchronous GP wait primitives" );torture_param (int, irqreader,1 ,"Allow RCU readers from irq handlers" ); +torture_param (int, leakpointer,0 ,"Leak pointer dereferences from readers" );torture_param (int, n_barrier_cbs,0 ,"# of callbacks/kthreads for barrier testing" );torture_param (int, nfakewriters,4 ,"Number of RCU fake writer threads" );
@@ -1401,6 +1402,9 @@ static bool rcu_torture_one_read(struct torture_random_state *trsp)preempt_enable ();rcutorture_one_extend (&readstate,0 , trsp, rtrsp);WARN_ON_ONCE (readstate &RCUTORTURE_RDR_MASK ); +// This next splat is expected behavior if leakpointer, especially +// for CONFIG_RCU_STRICT_GRACE_PERIOD=y kernels. +WARN_ON_ONCE (leakpointer &&READ_ONCE (p->rtort_pipe_count) >1 );/* If error or close call, record the sequence of reader protections. */ if ((pipe_count >1 || completed >1 ) && !xchg (&err_segs_recorded,1 )) {
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 14/14 torture: Add gdb support
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit adds a "--gdb" parameter to kvm.sh, which causes "CONFIG_DEBUG_INFO=y" to be added to the Kconfig options, "nokaslr" to be added to the boot parameters, and "-s -S" to be added to the qemu arguments. Furthermore, the scripting prints messages telling the user how to start up gdb for the run in question.
Because of the interactive nature of gdb sessions, only one "--configs" scenario is permitted when "--gdb" is specified. For most torture types, this means that a "--configs" argument is required, and that argument must specify the single scenario of interest.
The usual cautions about breakpoints and timing apply, for example, staring at your gdb prompt for too long will likely get you many complaints, including RCU CPU stall warnings. Omar Sandoval further suggests using gdb's "hbreak" command instead of the "break" command on systems supporting hardware breakpoints, and further using the "commands" option because the resulting non-interactive breakpoints are less likely to get you RCU CPU stall warnings.
--- .../selftests/rcutorture/bin/kvm-test-1-run.sh | 33 ++++++++++++++++------ tools/testing/selftests/rcutorture/bin/kvm.sh | 21 ++++++++++++++ 2 files changed, 46 insertions(+), 8 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +25 -8
@@ -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 "--gdb options" KcList "$TORTURE_KCONFIG_GDB_ARG" 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"
@@ -152,7 +153,11 @@ qemu_append="`identify_qemu_append "$QEMU"`" boot_args="`configfrag_boot_params "$boot_args" "$config_template"`" # Generate kernel-version-specific boot parameters boot_args="`per_version_boot_params "$boot_args" $resdir/.config $seconds`" -echo $QEMU $qemu_args -m $TORTURE_QEMU_MEM -kernel $KERNEL -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd +if test -n "$TORTURE_BOOT_GDB_ARG" +then + boot_args="$boot_args $TORTURE_BOOT_GDB_ARG" +fi +echo $QEMU $qemu_args -m $TORTURE_QEMU_MEM -kernel $KERNEL -append \"$qemu_append $boot_args\" $TORTURE_QEMU_GDB_ARG > $resdir/qemu-cmd if test -n "$TORTURE_BUILDONLY" then
@@ -171,14 +176,26 @@ echo "NOTE: $QEMU either did not run or was interactive" > $resdir/console.log # Attempt to run qemu ( . $T/qemu-cmd; wait `cat $resdir/qemu_pid`; echo $? > $resdir/qemu-retval ) & commandcompleted=0 -sleep 10 # Give qemu's pid a chance to reach the file -if test -s "$resdir/qemu_pid" +if test -z "$TORTURE_KCONFIG_GDB_ARG" then - qemu_pid=`cat "$resdir/qemu_pid"` - echo Monitoring qemu job at pid $qemu_pid -else - qemu_pid="" - echo Monitoring qemu job at yet-as-unknown pid + sleep 10 # Give qemu's pid a chance to reach the file + if test -s "$resdir/qemu_pid" + then + qemu_pid=`cat "$resdir/qemu_pid"` + echo Monitoring qemu job at pid $qemu_pid + else + qemu_pid="" + echo Monitoring qemu job at yet-as-unknown pid + fi +fi +if test -n "$TORTURE_KCONFIG_GDB_ARG" +then + echo Waiting for you to attach a debug session, for example: > /dev/tty + echo " gdb $base_resdir/vmlinux" > /dev/tty + echo 'After symbols load and the "(gdb)" prompt appears:' > /dev/tty + echo " target remote :1234" > /dev/tty + echo " continue" > /dev/tty + kstarttime=`gawk 'BEGIN { print systime() }' < /dev/null` fi while : do
tools/testing/selftests/rcutorture/bin/kvm.sh +21 -0
@@ -31,6 +31,9 @@ TORTURE_DEFCONFIG=defconfig TORTURE_BOOT_IMAGE="" TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD TORTURE_KCONFIG_ARG="" +TORTURE_KCONFIG_GDB_ARG="" +TORTURE_BOOT_GDB_ARG="" +TORTURE_QEMU_GDB_ARG="" TORTURE_KCONFIG_KASAN_ARG="" TORTURE_KCONFIG_KCSAN_ARG="" TORTURE_KMAKE_ARG=""
@@ -56,6 +59,7 @@ usage () { echo " --defconfig string" echo " --dryrun sched|script" echo " --duration minutes" + echo " --gdb" echo " --help" echo " --interactive" echo " --jitter N [ maxsleep (us) [ maxspin (us) ] ]"
@@ -128,6 +132,11 @@ do dur=$(($2*60)) shift ;; + --gdb) + TORTURE_KCONFIG_GDB_ARG="CONFIG_DEBUG_INFO=y"; export TORTURE_KCONFIG_GDB_ARG + TORTURE_BOOT_GDB_ARG="nokaslr"; export TORTURE_BOOT_GDB_ARG + TORTURE_QEMU_GDB_ARG="-s -S"; export TORTURE_QEMU_GDB_ARG + ;; --help|-h) usage ;;
@@ -253,6 +262,15 @@ do done touch $T/cfgcpu configs_derep="`echo $configs_derep | sed -e "s/\<CFLIST\>/$defaultconfigs/g"`" +if test -n "$TORTURE_KCONFIG_GDB_ARG" +then + if test "`echo $configs_derep | wc -w`" -gt 1 + then + echo "The --config list is: $configs_derep." + echo "Only one --config permitted with --gdb, terminating." + exit 1 + fi +fi for CF1 in $configs_derep do if test -f "$CONFIGFRAG/$CF1"
@@ -328,6 +346,9 @@ 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_GDB_ARG="$TORTURE_KCONFIG_GDB_ARG"; export TORTURE_KCONFIG_GDB_ARG +TORTURE_BOOT_GDB_ARG="$TORTURE_BOOT_GDB_ARG"; export TORTURE_BOOT_GDB_ARG +TORTURE_QEMU_GDB_ARG="$TORTURE_QEMU_GDB_ARG"; export TORTURE_QEMU_GDB_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
Signature · 1 line
2.9.5