From 8126c57f00cea3502a017b7c76df1fac58f89e88 Mon Sep 17 00:00:00 2001 From: "Paul E. McKenney" Date: Wed, 10 Feb 2021 13:25:58 -0800 Subject: torture: Make jitter.sh handle large systems The current jitter.sh script expects cpumask bits to fit into whatever the awk interpreter uses for an integer, which clearly does not hold for even medium-sized systems these days. This means that on a large system, only the first 32 or 64 CPUs (depending) are subjected to jitter.sh CPU-time perturbations. This commit therefore computes a given CPU's cpumask using text manipulation rather than arithmetic shifts. Reported-by: Sebastian Andrzej Siewior Signed-off-by: Paul E. McKenney --- tools/testing/selftests/rcutorture/bin/jitter.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tools/testing/selftests/rcutorture/bin/jitter.sh') diff --git a/tools/testing/selftests/rcutorture/bin/jitter.sh b/tools/testing/selftests/rcutorture/bin/jitter.sh index 188b864bc4bf..3a856ec2e92a 100755 --- a/tools/testing/selftests/rcutorture/bin/jitter.sh +++ b/tools/testing/selftests/rcutorture/bin/jitter.sh @@ -67,10 +67,10 @@ do srand(n + me + systime()); ncpus = split(cpus, ca); curcpu = ca[int(rand() * ncpus + 1)]; - mask = lshift(1, curcpu); - if (mask + 0 <= 0) - mask = 1; - printf("%#x\n", mask); + z = ""; + for (i = 1; 4 * i <= curcpu; i++) + z = z "0"; + print "0x" 2 ^ (curcpu % 4) z; }' < /dev/null` n=$(($n+1)) if ! taskset -p $cpumask $$ > /dev/null 2>&1 -- cgit v1.2.3-59-g8ed1b From 37812c9429722824859788cf754dd3e33f546908 Mon Sep 17 00:00:00 2001 From: "Paul E. McKenney" Date: Thu, 11 Feb 2021 10:39:28 -0800 Subject: torture: Use "jittering" file to control jitter.sh execution Currently, jitter.sh execution is controlled by a time limit and by the "kill" command. The former allowed jitter.sh to run uselessly past the end of a set of runs that panicked during boot, and the latter is vulnerable to PID reuse. This commit therefore introduces a "jittering" file in the date-stamp directory within "res" that must be present for the jitter.sh scripts to continue executing. The time limit is still in place in order to avoid disturbing runs featuring large trace dumps, but the removal of the "jittering" file handles the panic-during-boot scenario without relying on PIDs. Signed-off-by: Paul E. McKenney --- tools/testing/selftests/rcutorture/bin/jitter.sh | 10 ++++++---- tools/testing/selftests/rcutorture/bin/kvm.sh | 5 ++++- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'tools/testing/selftests/rcutorture/bin/jitter.sh') diff --git a/tools/testing/selftests/rcutorture/bin/jitter.sh b/tools/testing/selftests/rcutorture/bin/jitter.sh index 188b864bc4bf..ed0ea86ddf5d 100755 --- a/tools/testing/selftests/rcutorture/bin/jitter.sh +++ b/tools/testing/selftests/rcutorture/bin/jitter.sh @@ -5,10 +5,11 @@ # of this script is to inflict random OS jitter on a concurrently running # test. # -# Usage: jitter.sh me duration [ sleepmax [ spinmax ] ] +# Usage: jitter.sh me duration jittering-path [ sleepmax [ spinmax ] ] # # me: Random-number-generator seed salt. # duration: Time to run in seconds. +# jittering-path: Path to file whose removal will stop this script. # sleepmax: Maximum microseconds to sleep, defaults to one second. # spinmax: Maximum microseconds to spin, defaults to one millisecond. # @@ -18,8 +19,9 @@ me=$(($1 * 1000)) duration=$2 -sleepmax=${3-1000000} -spinmax=${4-1000} +jittering=$3 +sleepmax=${4-1000000} +spinmax=${5-1000} n=1 @@ -47,7 +49,7 @@ do fi # Check for stop request. - if test -f "$TORTURE_STOPFILE" + if ! test -f "$jittering" then exit 1; fi diff --git a/tools/testing/selftests/rcutorture/bin/kvm.sh b/tools/testing/selftests/rcutorture/bin/kvm.sh index 1f5f8720cacc..48da4cdb29d8 100755 --- a/tools/testing/selftests/rcutorture/bin/kvm.sh +++ b/tools/testing/selftests/rcutorture/bin/kvm.sh @@ -503,14 +503,17 @@ function dump(first, pastlast, batchnum) print "then" print "\techo ---- Starting kernels. `date` | tee -a " rd "log"; print "\techo > " rd "jitter_pids" + print "\ttouch " rd "jittering" for (j = 0; j < njitter; j++) { - print "\tjitter.sh " j " " dur " " ja[2] " " ja[3] "&" + print "\tjitter.sh " j " " dur " " rd "jittering " ja[2] " " ja[3] "&" print "\techo $! >> " rd "jitter_pids" } print "\twhile ls $runfiles > /dev/null 2>&1" print "\tdo" print "\t\t:" print "\tdone" + print "\trm -f " rd "jittering" + print "\twait" print "\techo ---- All kernel runs complete. `date` | tee -a " rd "log"; print "else" print "\twait" -- cgit v1.2.3-59-g8ed1b From 4cd54518c3d8afadd11ebd6ad4f03b00859f5e85 Mon Sep 17 00:00:00 2001 From: "Paul E. McKenney" Date: Thu, 11 Feb 2021 11:54:43 -0800 Subject: torture: Reverse jittering and duration parameters for jitter.sh Remote rcutorture testing requires that jitter.sh continue to be invoked from the generated script for local runs, but that it instead be invoked on the remote system for distributed runs. This argues for common jitterstart and jitterstop scripts. But it would be good for jitterstart and jitterstop to control the name and location of the "jittering" file, while continuing to have the duration controlled by the caller of these new scripts. This commit therefore reverses the order of the jittering and duration parameters for jitter.sh, so that the jittering parameter precedes the duration parameter. Signed-off-by: Paul E. McKenney --- tools/testing/selftests/rcutorture/bin/jitter.sh | 6 +++--- tools/testing/selftests/rcutorture/bin/kvm.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tools/testing/selftests/rcutorture/bin/jitter.sh') diff --git a/tools/testing/selftests/rcutorture/bin/jitter.sh b/tools/testing/selftests/rcutorture/bin/jitter.sh index ed0ea86ddf5d..ff1d3e468e53 100755 --- a/tools/testing/selftests/rcutorture/bin/jitter.sh +++ b/tools/testing/selftests/rcutorture/bin/jitter.sh @@ -5,7 +5,7 @@ # of this script is to inflict random OS jitter on a concurrently running # test. # -# Usage: jitter.sh me duration jittering-path [ sleepmax [ spinmax ] ] +# Usage: jitter.sh me jittering-path duration [ sleepmax [ spinmax ] ] # # me: Random-number-generator seed salt. # duration: Time to run in seconds. @@ -18,8 +18,8 @@ # Authors: Paul E. McKenney me=$(($1 * 1000)) -duration=$2 -jittering=$3 +jittering=$2 +duration=$3 sleepmax=${4-1000000} spinmax=${5-1000} diff --git a/tools/testing/selftests/rcutorture/bin/kvm.sh b/tools/testing/selftests/rcutorture/bin/kvm.sh index de93802c3d00..a2ee3f2fff3c 100755 --- a/tools/testing/selftests/rcutorture/bin/kvm.sh +++ b/tools/testing/selftests/rcutorture/bin/kvm.sh @@ -504,7 +504,7 @@ function dump(first, pastlast, batchnum) print "\techo ---- Starting kernels. `date` | tee -a " rd "log"; print "\ttouch " rd "jittering" for (j = 0; j < njitter; j++) - print "\tjitter.sh " j " " dur " " rd "jittering " ja[2] " " ja[3] "&" + print "\tjitter.sh " j " " rd "jittering " dur " " ja[2] " " ja[3] "&" print "\twhile ls $runfiles > /dev/null 2>&1" print "\tdo" print "\t\t:" -- cgit v1.2.3-59-g8ed1b