linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH rcu 0/21] Torture-test scripting updates for v5.15
@ 2021-07-21 20:55 Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 01/21] torture: Add clocksource-watchdog testing to torture.sh Paul E. McKenney
                   ` (20 more replies)
  0 siblings, 21 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 20:55 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel

Hello!

This series contains torture-test scripting updates:

1.	Add clocksource-watchdog testing to torture.sh.

2.	Make torture.sh accept --do-all and --donone.

3.	Enable KCSAN summaries over groups of torture-test runs.

4.	Create KCSAN summaries for torture.sh runs.

5.	Make kvm-recheck-scf.sh tolerate qemu-cmd comments.

6.	Make kvm-recheck-lock.sh tolerate qemu-cmd comments.

7.	Log more kvm-remote.sh information.

8.	Protect kvm-remote.sh directory trees from /tmp reaping.

9.	Make kvm-recheck.sh skip kcsan.sum for build-only runs.

10.	Move parse-console.sh call to PATH-aware scripts.

11.	Put kvm.sh batch-creation awk script into a temp file.

12.	Make kvm.sh select per-scenario affinity masks.

13.	Don't redirect qemu-cmd comment lines.

14.	Make kvm-test-1-run-qemu.sh apply affinity.

15.	Upgrade two-CPU scenarios to four CPUs.

16.	Use numeric taskset argument in jitter.sh.

17.	Consistently name "qemu*" test output files.

18.	Make kvm-test-1-run-batch.sh select per-scenario affinity masks.

19.	Don't use "test" command's "-a" argument.

20.	Add timestamps to kvm-test-1-run-qemu.sh output.

21.	Make kvm-test-1-run-qemu.sh check for reboot loops.

						Thanx, Paul

------------------------------------------------------------------------

 b/tools/testing/selftests/rcutorture/bin/jitter.sh               |   10 
 b/tools/testing/selftests/rcutorture/bin/kcsan-collapse.sh       |    2 
 b/tools/testing/selftests/rcutorture/bin/kvm-again.sh            |    2 
 b/tools/testing/selftests/rcutorture/bin/kvm-assign-cpus.sh      |  105 ++++++++++
 b/tools/testing/selftests/rcutorture/bin/kvm-get-cpus-script.sh  |   87 ++++++++
 b/tools/testing/selftests/rcutorture/bin/kvm-recheck-lock.sh     |    2 
 b/tools/testing/selftests/rcutorture/bin/kvm-recheck-scf.sh      |    2 
 b/tools/testing/selftests/rcutorture/bin/kvm-recheck.sh          |    5 
 b/tools/testing/selftests/rcutorture/bin/kvm-remote-noreap.sh    |   30 ++
 b/tools/testing/selftests/rcutorture/bin/kvm-remote.sh           |   15 +
 b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-batch.sh |    1 
 b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh  |    2 
 b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh       |    1 
 b/tools/testing/selftests/rcutorture/bin/kvm.sh                  |   27 +-
 b/tools/testing/selftests/rcutorture/bin/torture.sh              |   29 ++
 b/tools/testing/selftests/rcutorture/configs/rcu/RUDE01          |    2 
 b/tools/testing/selftests/rcutorture/configs/rcu/TASKS01         |    2 
 b/tools/testing/selftests/rcutorture/configs/rcu/TASKS03         |    2 
 tools/testing/selftests/rcutorture/bin/kvm-again.sh              |    2 
 tools/testing/selftests/rcutorture/bin/kvm-remote.sh             |    7 
 tools/testing/selftests/rcutorture/bin/kvm-test-1-run-batch.sh   |   23 ++
 tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh    |   57 +++--
 tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh         |    1 
 tools/testing/selftests/rcutorture/bin/kvm.sh                    |   14 +
 tools/testing/selftests/rcutorture/bin/torture.sh                |    8 
 25 files changed, 373 insertions(+), 65 deletions(-)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH rcu 01/21] torture: Add clocksource-watchdog testing to torture.sh
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 02/21] torture: Make torture.sh accept --do-all and --donone Paul E. McKenney
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

This commit adds three short tests of the clocksource-watchdog capability
to the torture.sh script, all to avoid otherwise-inevitable bitrot.
While in the area, fix an obsolete comment.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 .../selftests/rcutorture/bin/torture.sh       | 29 +++++++++++++++++--
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/rcutorture/bin/torture.sh b/tools/testing/selftests/rcutorture/bin/torture.sh
index 53ec7c046262d..94802ddfb7a6a 100755
--- a/tools/testing/selftests/rcutorture/bin/torture.sh
+++ b/tools/testing/selftests/rcutorture/bin/torture.sh
@@ -53,6 +53,7 @@ do_refscale=yes
 do_kvfree=yes
 do_kasan=yes
 do_kcsan=no
+do_clocksourcewd=yes
 
 # doyesno - Helper function for yes/no arguments
 function doyesno () {
@@ -72,6 +73,7 @@ usage () {
 	echo "       --configs-scftorture \"config-file list w/ repeat factor (2*CFLIST)\""
 	echo "       --doall"
 	echo "       --doallmodconfig / --do-no-allmodconfig"
+	echo "       --do-clocksourcewd / --do-no-clocksourcewd"
 	echo "       --do-kasan / --do-no-kasan"
 	echo "       --do-kcsan / --do-no-kcsan"
 	echo "       --do-kvfree / --do-no-kvfree"
@@ -119,10 +121,14 @@ do
 		do_kvfree=yes
 		do_kasan=yes
 		do_kcsan=yes
+		do_clocksourcewd=yes
 		;;
 	--do-allmodconfig|--do-no-allmodconfig)
 		do_allmodconfig=`doyesno "$1" --do-allmodconfig`
 		;;
+	--do-clocksourcewd|--do-no-clocksourcewd)
+		do_clocksourcewd=`doyesno "$1" --do-clocksourcewd`
+		;;
 	--do-kasan|--do-no-kasan)
 		do_kasan=`doyesno "$1" --do-kasan`
 		;;
@@ -145,6 +151,7 @@ do
 		do_kvfree=no
 		do_kasan=no
 		do_kcsan=no
+		do_clocksourcewd=no
 		;;
 	--do-rcuscale|--do-no-rcuscale)
 		do_rcuscale=`doyesno "$1" --do-rcuscale`
@@ -279,9 +286,9 @@ function torture_one {
 #	torture_bootargs="[ kernel boot arguments ]"
 #	torture_set flavor [ kvm.sh arguments ]
 #
-# Note that "flavor" is an arbitrary string.  Supply --torture if needed.
-# Note that quoting is problematic.  So on the command line, pass multiple
-# values with multiple kvm.sh argument instances.
+# Note that "flavor" is an arbitrary string that does not affect kvm.sh
+# in any way.  So also supply --torture if you need something other than
+# the default.
 function torture_set {
 	local cur_kcsan_kmake_args=
 	local kcsan_kmake_tag=
@@ -377,6 +384,22 @@ then
 	torture_set "rcuscale-kvfree" tools/testing/selftests/rcutorture/bin/kvm.sh --torture rcuscale --allcpus --duration 10 --kconfig "CONFIG_NR_CPUS=$HALF_ALLOTED_CPUS" --memory 1G --trust-make
 fi
 
+if test "$do_clocksourcewd" = "yes"
+then
+	torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000"
+	torture_set "clocksourcewd-1" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 45s --configs TREE03 --kconfig "CONFIG_TEST_CLOCKSOURCE_WATCHDOG=y" --trust-make
+
+	torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 clocksource.max_cswd_read_retries=1"
+	torture_set "clocksourcewd-2" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 45s --configs TREE03 --kconfig "CONFIG_TEST_CLOCKSOURCE_WATCHDOG=y" --trust-make
+
+	# In case our work is already done...
+	if test "$do_rcutorture" != "yes"
+	then
+		torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000"
+		torture_set "clocksourcewd-3" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 45s --configs TREE03 --trust-make
+	fi
+fi
+
 echo " --- " $scriptname $args
 echo " --- " Done `date` | tee -a $T/log
 ret=0
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH rcu 02/21] torture: Make torture.sh accept --do-all and --donone
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 01/21] torture: Add clocksource-watchdog testing to torture.sh Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 03/21] torture: Enable KCSAN summaries over groups of torture-test runs Paul E. McKenney
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

Currently, torture.sh accepts --doall on the one hand and --do-none
on the other, which is a bit inconsistent.  This commit therefore adds
--do-all and --donone so that a fully consistent test may be used.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 tools/testing/selftests/rcutorture/bin/torture.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/rcutorture/bin/torture.sh b/tools/testing/selftests/rcutorture/bin/torture.sh
index 94802ddfb7a6a..f1d1dff715905 100755
--- a/tools/testing/selftests/rcutorture/bin/torture.sh
+++ b/tools/testing/selftests/rcutorture/bin/torture.sh
@@ -111,7 +111,7 @@ do
 		configs_scftorture="$configs_scftorture $2"
 		shift
 		;;
-	--doall)
+	--do-all|--doall)
 		do_allmodconfig=yes
 		do_rcutorture=yes
 		do_locktorture=yes
@@ -141,7 +141,7 @@ do
 	--do-locktorture|--do-no-locktorture)
 		do_locktorture=`doyesno "$1" --do-locktorture`
 		;;
-	--do-none)
+	--do-none|--donone)
 		do_allmodconfig=no
 		do_rcutorture=no
 		do_locktorture=no
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH rcu 03/21] torture: Enable KCSAN summaries over groups of torture-test runs
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 01/21] torture: Add clocksource-watchdog testing to torture.sh Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 02/21] torture: Make torture.sh accept --do-all and --donone Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 04/21] torture: Create KCSAN summaries for torture.sh runs Paul E. McKenney
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

The kcsan-collapse.sh script assumes that it is being run over the output
of a single kvm.sh run, which is less than helpful for torture.sh runs.
This commit therefore changes the kcsan-collapse.sh script's "ls" pattern
with a "find" command to enable a KCSAN summary across all the -kcsan
runs in a full torture.sh run.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 tools/testing/selftests/rcutorture/bin/kcsan-collapse.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/rcutorture/bin/kcsan-collapse.sh b/tools/testing/selftests/rcutorture/bin/kcsan-collapse.sh
index e5cc6b2f195eb..1af5d6b86b392 100755
--- a/tools/testing/selftests/rcutorture/bin/kcsan-collapse.sh
+++ b/tools/testing/selftests/rcutorture/bin/kcsan-collapse.sh
@@ -14,7 +14,7 @@ if test -z "$TORTURE_KCONFIG_KCSAN_ARG"
 then
 	exit 0
 fi
-cat $1/*/console.log |
+find $1 -name console.log -exec cat {} \; |
 	grep "BUG: KCSAN: " |
 	sed -e 's/^\[[^]]*] //' |
 	sort |
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH rcu 04/21] torture: Create KCSAN summaries for torture.sh runs
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
                   ` (2 preceding siblings ...)
  2021-07-21 21:01 ` [PATCH rcu 03/21] torture: Enable KCSAN summaries over groups of torture-test runs Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 05/21] torture: Make kvm-recheck-scf.sh tolerate qemu-cmd comments Paul E. McKenney
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

Currently, each -kcsan run in a torture.sh group of runs has its own
kcsan.sum summary.  This works, but there is usually a lot of duplication
between the runs.  This commit therefore also creates an overall kcsan.sum
file for the entire torture.sh run, if there was at least one -kcsan run.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 tools/testing/selftests/rcutorture/bin/torture.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/rcutorture/bin/torture.sh b/tools/testing/selftests/rcutorture/bin/torture.sh
index f1d1dff715905..363f56081eff3 100755
--- a/tools/testing/selftests/rcutorture/bin/torture.sh
+++ b/tools/testing/selftests/rcutorture/bin/torture.sh
@@ -418,6 +418,10 @@ then
 	nfailures="`wc -l "$T/failures" | awk '{ print $1 }'`"
 	ret=2
 fi
+if test "$do_kcsan" = "yes"
+then
+	TORTURE_KCONFIG_KCSAN_ARG=1 tools/testing/selftests/rcutorture/bin/kcsan-collapse.sh tools/testing/selftests/rcutorture/res/$ds > tools/testing/selftests/rcutorture/res/$ds/kcsan.sum
+fi
 echo Started at $startdate, ended at `date`, duration `get_starttime_duration $starttime`. | tee -a $T/log
 echo Summary: Successes: $nsuccesses Failures: $nfailures. | tee -a $T/log
 tdir="`cat $T/successes $T/failures | head -1 | awk '{ print $NF }' | sed -e 's,/[^/]\+/*$,,'`"
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH rcu 05/21] torture: Make kvm-recheck-scf.sh tolerate qemu-cmd comments
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
                   ` (3 preceding siblings ...)
  2021-07-21 21:01 ` [PATCH rcu 04/21] torture: Create KCSAN summaries for torture.sh runs Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 06/21] torture: Make kvm-recheck-lock.sh " Paul E. McKenney
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

The qemu-cmd file can contain comments that are not relevant to the
operation of kvm-recheck-scf.sh.  This commit therefore strips these
comments before looking for timing information.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 tools/testing/selftests/rcutorture/bin/kvm-recheck-scf.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/rcutorture/bin/kvm-recheck-scf.sh b/tools/testing/selftests/rcutorture/bin/kvm-recheck-scf.sh
index 671bfee4fcef4..3afa5c6eda4f7 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-recheck-scf.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-recheck-scf.sh
@@ -25,7 +25,7 @@ if test -z "$nscfs"
 then
 	echo "$configfile ------- "
 else
-	dur="`sed -e 's/^.* scftorture.shutdown_secs=//' -e 's/ .*$//' < $i/qemu-cmd 2> /dev/null`"
+	dur="`grep -v '^#' $i/qemu-cmd | sed -e 's/^.* scftorture.shutdown_secs=//' -e 's/ .*$//' 2> /dev/null`"
 	if test -z "$dur"
 	then
 		rate=""
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH rcu 06/21] torture: Make kvm-recheck-lock.sh tolerate qemu-cmd comments
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
                   ` (4 preceding siblings ...)
  2021-07-21 21:01 ` [PATCH rcu 05/21] torture: Make kvm-recheck-scf.sh tolerate qemu-cmd comments Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 07/21] torture: Log more kvm-remote.sh information Paul E. McKenney
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

The qemu-cmd file can contain comments that are not relevant to the
operation of kvm-recheck-lock.sh.  This commit therefore strips these
comments before looking for timing information.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 tools/testing/selftests/rcutorture/bin/kvm-recheck-lock.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/rcutorture/bin/kvm-recheck-lock.sh b/tools/testing/selftests/rcutorture/bin/kvm-recheck-lock.sh
index f3a7a5e2b89d4..db2c0e2c8e1de 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-recheck-lock.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-recheck-lock.sh
@@ -25,7 +25,7 @@ then
 	echo "$configfile -------"
 else
 	title="$configfile ------- $ncs acquisitions/releases"
-	dur=`sed -e 's/^.* locktorture.shutdown_secs=//' -e 's/ .*$//' < $i/qemu-cmd 2> /dev/null`
+	dur=`grep -v '^#' $i/qemu-cmd | sed -e 's/^.* locktorture.shutdown_secs=//' -e 's/ .*$//' 2> /dev/null`
 	if test -z "$dur"
 	then
 		:
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH rcu 07/21] torture: Log more kvm-remote.sh information
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
                   ` (5 preceding siblings ...)
  2021-07-21 21:01 ` [PATCH rcu 06/21] torture: Make kvm-recheck-lock.sh " Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 08/21] torture: Protect kvm-remote.sh directory trees from /tmp reaping Paul E. McKenney
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

This commit logs additional information to help track down set up and
networking issues.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 .../selftests/rcutorture/bin/kvm-remote.sh        | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/rcutorture/bin/kvm-remote.sh b/tools/testing/selftests/rcutorture/bin/kvm-remote.sh
index 79e680e0e7bf3..8f26dbfc2edf2 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-remote.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-remote.sh
@@ -128,6 +128,7 @@ awk < "$rundir"/scenarios -v dest="$T/bin" -v rundir="$rundir" '
 	for (i = 2; i <= NF; i++)
 		scenarios = scenarios " " $i;
 	print "kvm-test-1-run-batch.sh" scenarios > fn;
+	print "sync" >> fn;
 	print "rm " rundir "/remote.run" >> fn;
 }'
 chmod +x $T/bin/kvm-remote-*.sh
@@ -172,11 +173,20 @@ checkremotefile () {
 	do
 		ssh $1 "test -f \"$2\""
 		ret=$?
-		if test "$ret" -ne 255
+		if test "$ret" -eq 255
 		then
+			echo " ---" ssh failure to $1 checking for file $2, retry after $sleeptime seconds. `date`
+		elif test "$ret" -eq 0
+		then
+			return 0
+		elif test "$ret" -eq 1
+		then
+			echo " ---" File \"$2\" not found: ssh $1 test -f \"$2\"
+			return 1
+		else
+			echo " ---" Exit code $ret: ssh $1 test -f \"$2\", retry after $sleeptime seconds. `date`
 			return $ret
 		fi
-		echo " ---" ssh failure to $1 checking for file $2, retry after $sleeptime seconds. `date`
 		sleep $sleeptime
 	done
 }
@@ -242,6 +252,7 @@ do
 	do
 		sleep 30
 	done
+	echo " ---" Collecting results from $i `date`
 	( cd "$oldrun"; ssh $i "cd $rundir; tar -czf - kvm-remote-*.sh.out */console.log */kvm-test-1-run*.sh.out */qemu_pid */qemu-retval; rm -rf $T > /dev/null 2>&1" | tar -xzf - )
 done
 
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH rcu 08/21] torture: Protect kvm-remote.sh directory trees from /tmp reaping
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
                   ` (6 preceding siblings ...)
  2021-07-21 21:01 ` [PATCH rcu 07/21] torture: Log more kvm-remote.sh information Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 09/21] torture: Make kvm-recheck.sh skip kcsan.sum for build-only runs Paul E. McKenney
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

The kvm-remote.sh script places the datestamped directory containing
all the build artifacts in the destination systems' /tmp directories,
where they accumulate runtime artifacts such as console.log.  This works,
but some systems have a habit of removing files in /tmp that have not
been recently accessed.  This commit therefore runs a simple script that
periodically accesses all files in the datestamped directory.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 .../rcutorture/bin/kvm-remote-noreap.sh       | 30 +++++++++++++++++++
 .../selftests/rcutorture/bin/kvm-remote.sh    |  3 +-
 2 files changed, 32 insertions(+), 1 deletion(-)
 create mode 100755 tools/testing/selftests/rcutorture/bin/kvm-remote-noreap.sh

diff --git a/tools/testing/selftests/rcutorture/bin/kvm-remote-noreap.sh b/tools/testing/selftests/rcutorture/bin/kvm-remote-noreap.sh
new file mode 100755
index 0000000000000..014ce68260d78
--- /dev/null
+++ b/tools/testing/selftests/rcutorture/bin/kvm-remote-noreap.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Periodically scan a directory tree to prevent files from being reaped
+# by systemd and friends on long runs.
+#
+# Usage: kvm-remote-noreap.sh pathname
+#
+# Copyright (C) 2021 Facebook, Inc.
+#
+# Authors: Paul E. McKenney <paulmck@kernel.org>
+
+pathname="$1"
+if test "$pathname" = ""
+then
+	echo Usage: kvm-remote-noreap.sh pathname
+	exit 1
+fi
+if ! test -d "$pathname"
+then
+	echo  Usage: kvm-remote-noreap.sh pathname
+	echo "       pathname must be a directory."
+	exit 2
+fi
+
+while test -d "$pathname"
+do
+	find "$pathname" -type f -exec touch -c {} \; > /dev/null 2>&1
+	sleep 30
+done
diff --git a/tools/testing/selftests/rcutorture/bin/kvm-remote.sh b/tools/testing/selftests/rcutorture/bin/kvm-remote.sh
index 8f26dbfc2edf2..f52641fdd1fe7 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-remote.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-remote.sh
@@ -124,10 +124,11 @@ awk < "$rundir"/scenarios -v dest="$T/bin" -v rundir="$rundir" '
 	n = $1;
 	sub(/\./, "", n);
 	fn = dest "/kvm-remote-" n ".sh"
+	print "kvm-remote-noreap.sh " rundir " &" > fn;
 	scenarios = "";
 	for (i = 2; i <= NF; i++)
 		scenarios = scenarios " " $i;
-	print "kvm-test-1-run-batch.sh" scenarios > fn;
+	print "kvm-test-1-run-batch.sh" scenarios >> fn;
 	print "sync" >> fn;
 	print "rm " rundir "/remote.run" >> fn;
 }'
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH rcu 09/21] torture: Make kvm-recheck.sh skip kcsan.sum for build-only runs
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
                   ` (7 preceding siblings ...)
  2021-07-21 21:01 ` [PATCH rcu 08/21] torture: Protect kvm-remote.sh directory trees from /tmp reaping Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 10/21] torture: Move parse-console.sh call to PATH-aware scripts Paul E. McKenney
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

Currently, kvm-recheck.sh attempts to create a kcsan.sum file even for
build-only runs.  This results in false-positive bash errors due to
there being no console.log files in that case.  This commit therefore
makes kvm-recheck.sh skip creating the kcsan.sum file for build-only runs.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 tools/testing/selftests/rcutorture/bin/kvm-recheck.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/rcutorture/bin/kvm-recheck.sh b/tools/testing/selftests/rcutorture/bin/kvm-recheck.sh
index e01b31b870441..0a5419982ab3e 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-recheck.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-recheck.sh
@@ -74,7 +74,10 @@ do
 	done
 	if test -f "$rd/kcsan.sum"
 	then
-		if grep -q CONFIG_KCSAN=y $T
+		if ! test -f $T
+		then
+			:
+		elif grep -q CONFIG_KCSAN=y $T
 		then
 			echo "Compiler or architecture does not support KCSAN!"
 			echo Did you forget to switch your compiler with '--kmake-arg CC=<cc-that-supports-kcsan>'?
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH rcu 10/21] torture: Move parse-console.sh call to PATH-aware scripts
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
                   ` (8 preceding siblings ...)
  2021-07-21 21:01 ` [PATCH rcu 09/21] torture: Make kvm-recheck.sh skip kcsan.sum for build-only runs Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 11/21] torture: Put kvm.sh batch-creation awk script into a temp file Paul E. McKenney
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

The last line of kvm-test-1-run-qemu.sh invokes parse-console.sh, but
kvm-test-1-run-qemu.sh is unaware of the PATH containing this script
and does not have the job title handy.  This commit therefore moves
the invocation of parse-console.sh to kvm-test-1-run.sh, which has
PATH and title at hand.  This commit does not add an invocation of
parse-console.sh to kvm-test-1-run-batch.sh because this latter script
is run in the background, and the information will be gathered at the
end of the full run.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh | 2 --
 tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh      | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
index 5b1aa2a4f3f69..7c6643d1f0370 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
@@ -172,5 +172,3 @@ fi
 
 # Tell the script that this run is done.
 rm -f $resdir/build.run
-
-parse-console.sh $resdir/console.log $title
diff --git a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
index 420ed5ce9d32f..f10f426f50893 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
@@ -214,3 +214,4 @@ then
 fi
 
 kvm-test-1-run-qemu.sh $resdir
+parse-console.sh $resdir/console.log $title
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH rcu 11/21] torture: Put kvm.sh batch-creation awk script into a temp file
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
                   ` (9 preceding siblings ...)
  2021-07-21 21:01 ` [PATCH rcu 10/21] torture: Move parse-console.sh call to PATH-aware scripts Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 12/21] torture: Make kvm.sh select per-scenario affinity masks Paul E. McKenney
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

This commit is a first step towards pinning guest-OS vCPUs so as
to force latency differences, especially on multi-socket systems.
The kvm.sh script puts its batch-creation awk script into a temporary
file so that later commits can add the awk code needed to dole out CPUs
so as to maximize latency differences.  This awk code will be used by
multiple scripts.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 tools/testing/selftests/rcutorture/bin/kvm.sh | 27 ++++++++++---------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/tools/testing/selftests/rcutorture/bin/kvm.sh b/tools/testing/selftests/rcutorture/bin/kvm.sh
index b4ac4ee332226..0f26a81599f5c 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm.sh
@@ -430,17 +430,8 @@ then
 	git diff HEAD >> $resdir/$ds/testid.txt
 fi
 ___EOF___
-awk < $T/cfgcpu.pack \
-	-v TORTURE_BUILDONLY="$TORTURE_BUILDONLY" \
-	-v CONFIGDIR="$CONFIGFRAG/" \
-	-v KVM="$KVM" \
-	-v ncpus=$cpus \
-	-v jitter="$jitter" \
-	-v rd=$resdir/$ds/ \
-	-v dur=$dur \
-	-v TORTURE_QEMU_ARG="$TORTURE_QEMU_ARG" \
-	-v TORTURE_BOOTARGS="$TORTURE_BOOTARGS" \
-'BEGIN {
+cat << '___EOF___' > $T/dumpbatches.awk
+BEGIN {
 	i = 0;
 }
 
@@ -560,7 +551,19 @@ END {
 	# Dump the last batch.
 	if (ncpus != 0)
 		dump(first, i, batchnum);
-}' >> $T/script
+}
+___EOF___
+awk < $T/cfgcpu.pack \
+	-v TORTURE_BUILDONLY="$TORTURE_BUILDONLY" \
+	-v CONFIGDIR="$CONFIGFRAG/" \
+	-v KVM="$KVM" \
+	-v ncpus=$cpus \
+	-v jitter="$jitter" \
+	-v rd=$resdir/$ds/ \
+	-v dur=$dur \
+	-v TORTURE_QEMU_ARG="$TORTURE_QEMU_ARG" \
+	-v TORTURE_BOOTARGS="$TORTURE_BOOTARGS" \
+	-f $T/dumpbatches.awk >> $T/script
 echo kvm-end-run-stats.sh "$resdir/$ds" "$starttime" >> $T/script
 
 # Extract the tests and their batches from the script.
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH rcu 12/21] torture: Make kvm.sh select per-scenario affinity masks
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
                   ` (10 preceding siblings ...)
  2021-07-21 21:01 ` [PATCH rcu 11/21] torture: Put kvm.sh batch-creation awk script into a temp file Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 13/21] torture: Don't redirect qemu-cmd comment lines Paul E. McKenney
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

This commit causes kvm.sh to use the new kvm-assign-cpus.sh and
kvm-get-cpus-script.sh scripts to create a TORTURE_AFFINITY environment
variable containing either an empty string (for no affinity) or a list
of CPUs to pin the scenario's vCPUs to.  A later commit will make
use of this information to actually pin the vCPUs.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 .../rcutorture/bin/kvm-assign-cpus.sh         | 105 ++++++++++++++++++
 .../rcutorture/bin/kvm-get-cpus-script.sh     |  87 +++++++++++++++
 .../rcutorture/bin/kvm-test-1-run-batch.sh    |   1 +
 tools/testing/selftests/rcutorture/bin/kvm.sh |  14 ++-
 4 files changed, 205 insertions(+), 2 deletions(-)
 create mode 100755 tools/testing/selftests/rcutorture/bin/kvm-assign-cpus.sh
 create mode 100755 tools/testing/selftests/rcutorture/bin/kvm-get-cpus-script.sh

diff --git a/tools/testing/selftests/rcutorture/bin/kvm-assign-cpus.sh b/tools/testing/selftests/rcutorture/bin/kvm-assign-cpus.sh
new file mode 100755
index 0000000000000..494ae91cc1f0e
--- /dev/null
+++ b/tools/testing/selftests/rcutorture/bin/kvm-assign-cpus.sh
@@ -0,0 +1,105 @@
+#!/bin/sh
+#
+# Produce awk statements roughly depicting the system's CPU and cache
+# layout.  If the required information is not available, produce
+# error messages as awk comments.  Successful exit regardless.
+#
+# Usage: kvm-assign-cpus.sh /path/to/sysfs
+
+T=/tmp/kvm-assign-cpus.sh.$$
+trap 'rm -rf $T' 0 2
+mkdir $T
+
+sysfsdir=${1-/sys/devices/system/node}
+if ! cd "$sysfsdir" > $T/msg 2>&1
+then
+	sed -e 's/^/# /' < $T/msg
+	exit 0
+fi
+nodelist="`ls -d node*`"
+for i in node*
+do
+	if ! test -d $i/
+	then
+		echo "# Not a directory: $sysfsdir/node*"
+		exit 0
+	fi
+	for j in $i/cpu*/cache/index*
+	do
+		if ! test -d $j/
+		then
+			echo "# Not a directory: $sysfsdir/$j"
+			exit 0
+		else
+			break
+		fi
+	done
+	indexlist="`ls -d $i/cpu* | grep 'cpu[0-9][0-9]*' | head -1 | sed -e 's,^.*$,ls -d &/cache/index*,' | sh | sed -e 's,^.*/,,'`"
+	break
+done
+for i in node*/cpu*/cache/index*/shared_cpu_list
+do
+	if ! test -f $i
+	then
+		echo "# Not a file: $sysfsdir/$i"
+		exit 0
+	else
+		break
+	fi
+done
+firstshared=
+for i in $indexlist
+do
+	rm -f $T/cpulist
+	for n in node*
+	do
+		f="$n/cpu*/cache/$i/shared_cpu_list"
+		if ! cat $f > $T/msg 2>&1
+		then
+			sed -e 's/^/# /' < $T/msg
+			exit 0
+		fi
+		cat $f >> $T/cpulist
+	done
+	if grep -q '[-,]' $T/cpulist
+	then
+		if test -z "$firstshared"
+		then
+			firstshared="$i"
+		fi
+	fi
+done
+if test -z "$firstshared"
+then
+	splitindex="`echo $indexlist | sed -e 's/ .*$//'`"
+else
+	splitindex="$firstshared"
+fi
+nodenum=0
+for n in node*
+do
+	cat $n/cpu*/cache/$splitindex/shared_cpu_list | sort -u -k1n |
+	awk -v nodenum="$nodenum" '
+	BEGIN {
+		idx = 0;
+	}
+
+	{
+		nlists = split($0, cpulists, ",");
+		for (i = 1; i <= nlists; i++) {
+			listsize = split(cpulists[i], cpus, "-");
+			if (listsize == 1)
+				cpus[2] = cpus[1];
+			for (j = cpus[1]; j <= cpus[2]; j++) {
+				print "cpu[" nodenum "][" idx "] = " j ";";
+				idx++;
+			}
+		}
+	}
+
+	END {
+		print "nodecpus[" nodenum "] = " idx ";";
+	}'
+	nodenum=`expr $nodenum + 1`
+done
+echo "numnodes = $nodenum;"
diff --git a/tools/testing/selftests/rcutorture/bin/kvm-get-cpus-script.sh b/tools/testing/selftests/rcutorture/bin/kvm-get-cpus-script.sh
new file mode 100755
index 0000000000000..0ab7fca5bec12
--- /dev/null
+++ b/tools/testing/selftests/rcutorture/bin/kvm-get-cpus-script.sh
@@ -0,0 +1,87 @@
+#!/bin/sh
+#
+# Create an awk script that takes as input numbers of CPUs and outputs
+# lists of CPUs, one per line in both cases.
+#
+# Usage: kvm-get-cpus-script.sh /path/to/cpu/arrays /path/to/put/script [ /path/to/state ]
+#
+# The CPU arrays are output by kvm-assign-cpus.sh, and are valid awk
+# statements initializing the variables describing the system's topology.
+#
+# The optional state is input by this script (if the file exists and is
+# non-empty), and can also be output by this script.
+
+cpuarrays="${1-/sys/devices/system/node}"
+scriptfile="${2}"
+statefile="${3}"
+
+if ! test -f "$cpuarrays"
+then
+	echo "File not found: $cpuarrays" 1>&2
+	exit 1
+fi
+scriptdir="`dirname "$scriptfile"`"
+if ! test -d "$scriptdir" || ! test -x "$scriptdir" || ! test -w "$scriptdir"
+then
+	echo "Directory not usable for script output: $scriptdir"
+	exit 1
+fi
+
+cat << '___EOF___' > "$scriptfile"
+BEGIN {
+___EOF___
+cat "$cpuarrays" >> "$scriptfile"
+if test -r "$statefile"
+then
+	cat "$statefile" >> "$scriptfile"
+fi
+cat << '___EOF___' >> "$scriptfile"
+}
+
+# Do we have the system architecture to guide CPU affinity?
+function gotcpus()
+{
+	return numnodes != "";
+}
+
+# Return a comma-separated list of the next n CPUs.
+function nextcpus(n,  i, s)
+{
+	for (i = 0; i < n; i++) {
+		if (nodecpus[curnode] == "")
+			curnode = 0;
+		if (cpu[curnode][curcpu[curnode]] == "")
+			curcpu[curnode] = 0;
+		if (s != "")
+			s = s ",";
+		s = s cpu[curnode][curcpu[curnode]];
+		curcpu[curnode]++;
+		curnode++
+	}
+	return s;
+}
+
+# Dump out the current node/CPU state so that a later invocation of this
+# script can continue where this one left off.  Of course, this only works
+# when a state file was specified and where there was valid sysfs state.
+# Returns 1 if the state was dumped, 0 otherwise.
+#
+# Dumping the state for one system configuration and loading it into
+# another isn't likely to do what you want, whatever that might be.
+function dumpcpustate(  i, fn)
+{
+___EOF___
+echo '	fn = "'"$statefile"'";' >> $scriptfile
+cat << '___EOF___' >> "$scriptfile"
+	if (fn != "" && gotcpus()) {
+		print "curnode = " curnode ";" > fn;
+		for (i = 0; i < numnodes; i++)
+			if (curcpu[i] != "")
+				print "curcpu[" i "] = " curcpu[i] ";" >> fn;
+		return 1;
+	}
+	if (fn != "")
+		print "# No CPU state to dump." > fn;
+	return 0;
+}
+___EOF___
diff --git a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-batch.sh b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-batch.sh
index 7ea0809e229e9..005a048c55aa0 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-batch.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-batch.sh
@@ -54,6 +54,7 @@ for i in "$@"
 do
 	echo ---- System running test: `uname -a` > $i/kvm-test-1-run-qemu.sh.out
 	echo > $i/kvm-test-1-run-qemu.sh.out
+	export TORTURE_AFFINITY=
 	kvm-test-1-run-qemu.sh $i >> $i/kvm-test-1-run-qemu.sh.out 2>&1 &
 done
 for i in $runfiles
diff --git a/tools/testing/selftests/rcutorture/bin/kvm.sh b/tools/testing/selftests/rcutorture/bin/kvm.sh
index 0f26a81599f5c..f442d84fb2a3e 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm.sh
@@ -430,7 +430,9 @@ then
 	git diff HEAD >> $resdir/$ds/testid.txt
 fi
 ___EOF___
-cat << '___EOF___' > $T/dumpbatches.awk
+kvm-assign-cpus.sh /sys/devices/system/node > $T/cpuarray.awk
+kvm-get-cpus-script.sh $T/cpuarray.awk $T/dumpbatches.awk
+cat << '___EOF___' >> $T/dumpbatches.awk
 BEGIN {
 	i = 0;
 }
@@ -442,7 +444,7 @@ BEGIN {
 }
 
 # Dump out the scripting required to run one test batch.
-function dump(first, pastlast, batchnum)
+function dump(first, pastlast, batchnum,  affinitylist)
 {
 	print "echo ----Start batch " batchnum ": `date` | tee -a " rd "log";
 	print "needqemurun="
@@ -474,6 +476,14 @@ function dump(first, pastlast, batchnum)
 		print "echo ", cfr[jn], cpusr[jn] ovf ": Starting build. `date` | tee -a " rd "log";
 		print "mkdir " rd cfr[jn] " || :";
 		print "touch " builddir ".wait";
+		affinitylist = "";
+		if (gotcpus()) {
+			affinitylist = nextcpus(cpusr[jn]);
+		}
+		if (affinitylist ~ /^[0-9,-][0-9,-]*$/)
+			print "export TORTURE_AFFINITY=" affinitylist;
+		else
+			print "export TORTURE_AFFINITY=";
 		print "kvm-test-1-run.sh " CONFIGDIR cf[j], rd cfr[jn], dur " \"" TORTURE_QEMU_ARG "\" \"" TORTURE_BOOTARGS "\" > " rd cfr[jn]  "/kvm-test-1-run.sh.out 2>&1 &"
 		print "echo ", cfr[jn], cpusr[jn] ovf ": Waiting for build to complete. `date` | tee -a " rd "log";
 		print "while test -f " builddir ".wait"
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH rcu 13/21] torture: Don't redirect qemu-cmd comment lines
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
                   ` (11 preceding siblings ...)
  2021-07-21 21:01 ` [PATCH rcu 12/21] torture: Make kvm.sh select per-scenario affinity masks Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 14/21] torture: Make kvm-test-1-run-qemu.sh apply affinity Paul E. McKenney
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

Currently, kvm-test-1-run-qemu.sh applies redirection to each and every
line of each qemu-cmd script.  Only the first line (the only one that
is not a bash comment) needs to be redirected.  Although redirecting
the comments is currently harmless, just adding to the comment, it is
an accident waiting to happen.  This commit therefore adjusts the "sed"
command to redirect only the qemu-system* command itself.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
index 7c6643d1f0370..2fd0868b357c4 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
@@ -40,7 +40,7 @@ grep '^#' $resdir/qemu-cmd | sed -e 's/^# //' > $T/qemu-cmd-settings
 . $T/qemu-cmd-settings
 
 # Decorate qemu-cmd with redirection, backgrounding, and PID capture
-sed -e 's/$/ 2>\&1 \&/' < $resdir/qemu-cmd > $T/qemu-cmd
+sed -e 's/^[^#].*$/& 2>\&1 \&/' < $resdir/qemu-cmd > $T/qemu-cmd
 echo 'echo $! > $resdir/qemu_pid' >> $T/qemu-cmd
 
 # In case qemu refuses to run...
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH rcu 14/21] torture: Make kvm-test-1-run-qemu.sh apply affinity
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
                   ` (12 preceding siblings ...)
  2021-07-21 21:01 ` [PATCH rcu 13/21] torture: Don't redirect qemu-cmd comment lines Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 15/21] rcutorture: Upgrade two-CPU scenarios to four CPUs Paul E. McKenney
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

This commit causes the kvm-test-1-run-qemu.sh script to check the
TORTURE_AFFINITY environment variable and to add "taskset" commands to
the qemu-cmd file.  The first "taskset" command is applied only if the
TORTURE_AFFINITY environment variable is a non-empty string, and this
command pins the current scenario's guest OS to the specified CPUs.
The second "taskset" command reports the guest OS's affinity in a new
"qemu-affinity" file.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 .../selftests/rcutorture/bin/kvm-test-1-run-qemu.sh | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
index 2fd0868b357c4..b9a0bb6f01154 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
@@ -39,9 +39,16 @@ echo ' ---' `date`: Starting kernel, PID $$
 grep '^#' $resdir/qemu-cmd | sed -e 's/^# //' > $T/qemu-cmd-settings
 . $T/qemu-cmd-settings
 
-# Decorate qemu-cmd with redirection, backgrounding, and PID capture
-sed -e 's/^[^#].*$/& 2>\&1 \&/' < $resdir/qemu-cmd > $T/qemu-cmd
-echo 'echo $! > $resdir/qemu_pid' >> $T/qemu-cmd
+# Decorate qemu-cmd with affinity, redirection, backgrounding, and PID capture
+taskset_command=
+if test -n "$TORTURE_AFFINITY"
+then
+	taskset_command="taskset -c $TORTURE_AFFINITY "
+fi
+sed -e 's/^[^#].*$/'"$taskset_command"'& 2>\&1 \&/' < $resdir/qemu-cmd > $T/qemu-cmd
+echo 'qemu_pid=$!' >> $T/qemu-cmd
+echo 'echo $qemu_pid > $resdir/qemu_pid' >> $T/qemu-cmd
+echo 'taskset -c -p $qemu_pid > $resdir/qemu-affinity' >> $T/qemu-cmd
 
 # In case qemu refuses to run...
 echo "NOTE: $QEMU either did not run or was interactive" > $resdir/console.log
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH rcu 15/21] rcutorture: Upgrade two-CPU scenarios to four CPUs
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
                   ` (13 preceding siblings ...)
  2021-07-21 21:01 ` [PATCH rcu 14/21] torture: Make kvm-test-1-run-qemu.sh apply affinity Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 16/21] torture: Use numeric taskset argument in jitter.sh Paul E. McKenney
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

There is no way to place the vCPUs in a two-CPU rcutorture scenario to
get variable memory latency.  This commit therefore upgrades the current
two-CPU rcutorture scenarios to four CPUs.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 tools/testing/selftests/rcutorture/configs/rcu/RUDE01  | 2 +-
 tools/testing/selftests/rcutorture/configs/rcu/TASKS01 | 2 +-
 tools/testing/selftests/rcutorture/configs/rcu/TASKS03 | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/rcutorture/configs/rcu/RUDE01 b/tools/testing/selftests/rcutorture/configs/rcu/RUDE01
index bafe94cbd7390..3ca112444ce77 100644
--- a/tools/testing/selftests/rcutorture/configs/rcu/RUDE01
+++ b/tools/testing/selftests/rcutorture/configs/rcu/RUDE01
@@ -1,5 +1,5 @@
 CONFIG_SMP=y
-CONFIG_NR_CPUS=2
+CONFIG_NR_CPUS=4
 CONFIG_HOTPLUG_CPU=y
 CONFIG_PREEMPT_NONE=n
 CONFIG_PREEMPT_VOLUNTARY=n
diff --git a/tools/testing/selftests/rcutorture/configs/rcu/TASKS01 b/tools/testing/selftests/rcutorture/configs/rcu/TASKS01
index bafe94cbd7390..3ca112444ce77 100644
--- a/tools/testing/selftests/rcutorture/configs/rcu/TASKS01
+++ b/tools/testing/selftests/rcutorture/configs/rcu/TASKS01
@@ -1,5 +1,5 @@
 CONFIG_SMP=y
-CONFIG_NR_CPUS=2
+CONFIG_NR_CPUS=4
 CONFIG_HOTPLUG_CPU=y
 CONFIG_PREEMPT_NONE=n
 CONFIG_PREEMPT_VOLUNTARY=n
diff --git a/tools/testing/selftests/rcutorture/configs/rcu/TASKS03 b/tools/testing/selftests/rcutorture/configs/rcu/TASKS03
index ea4399020c6c1..dc02083803ce5 100644
--- a/tools/testing/selftests/rcutorture/configs/rcu/TASKS03
+++ b/tools/testing/selftests/rcutorture/configs/rcu/TASKS03
@@ -1,5 +1,5 @@
 CONFIG_SMP=y
-CONFIG_NR_CPUS=2
+CONFIG_NR_CPUS=4
 CONFIG_PREEMPT_NONE=n
 CONFIG_PREEMPT_VOLUNTARY=n
 CONFIG_PREEMPT=y
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH rcu 16/21] torture: Use numeric taskset argument in jitter.sh
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
                   ` (14 preceding siblings ...)
  2021-07-21 21:01 ` [PATCH rcu 15/21] rcutorture: Upgrade two-CPU scenarios to four CPUs Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 17/21] torture: Consistently name "qemu*" test output files Paul E. McKenney
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

The jitter.sh script has some entertaining awk code to generate a
hex mask from a randomly selected CPU number, which is handed to the
"taskset" command.  Except that this command has a "-c" parameter to
take a comma/dash-separated list of CPU numbers.  This commit therefore
saves a few lines of awk by switching to a single-number CPU list.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 tools/testing/selftests/rcutorture/bin/jitter.sh | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/tools/testing/selftests/rcutorture/bin/jitter.sh b/tools/testing/selftests/rcutorture/bin/jitter.sh
index 15d937ba96cad..fd1ffaa5a1358 100755
--- a/tools/testing/selftests/rcutorture/bin/jitter.sh
+++ b/tools/testing/selftests/rcutorture/bin/jitter.sh
@@ -68,16 +68,12 @@ do
 	cpumask=`awk -v cpus="$cpus" -v me=$me -v n=$n 'BEGIN {
 		srand(n + me + systime());
 		ncpus = split(cpus, ca);
-		curcpu = ca[int(rand() * ncpus + 1)];
-		z = "";
-		for (i = 1; 4 * i <= curcpu; i++)
-			z = z "0";
-		print "0x" 2 ^ (curcpu % 4) z;
+		print ca[int(rand() * ncpus + 1)];
 	}' < /dev/null`
 	n=$(($n+1))
-	if ! taskset -p $cpumask $$ > /dev/null 2>&1
+	if ! taskset -c -p $cpumask $$ > /dev/null 2>&1
 	then
-		echo taskset failure: '"taskset -p ' $cpumask $$ '"'
+		echo taskset failure: '"taskset -c -p ' $cpumask $$ '"'
 		exit 1
 	fi
 
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH rcu 17/21] torture: Consistently name "qemu*" test output files
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
                   ` (15 preceding siblings ...)
  2021-07-21 21:01 ` [PATCH rcu 16/21] torture: Use numeric taskset argument in jitter.sh Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 18/21] torture: Make kvm-test-1-run-batch.sh select per-scenario affinity masks Paul E. McKenney
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

There is "qemu-affinity", "qemu-cmd", "qemu-retval", but also "qemu_pid".
This is hard to remember, not so good for bash tab completion, and just
plain inconsistent.  This commit therefore renames the "qemu_pid" file to
"qemu-pid".  A couple of the scripts must deal with old runs, and thus
must handle both "qemu_pid" and "qemu-pid", but new runs will produce
"qemu-pid".

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 .../selftests/rcutorture/bin/kvm-again.sh        |  2 +-
 .../selftests/rcutorture/bin/kvm-remote.sh       |  2 +-
 .../rcutorture/bin/kvm-test-1-run-qemu.sh        | 16 ++++++++--------
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/rcutorture/bin/kvm-again.sh b/tools/testing/selftests/rcutorture/bin/kvm-again.sh
index d8c8483c46f13..b7b8d6856d7ec 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-again.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-again.sh
@@ -142,7 +142,7 @@ then
 	echo "Cannot copy from $oldrun to $rundir."
 	usage
 fi
-rm -f "$rundir"/*/{console.log,console.log.diags,qemu_pid,qemu-retval,Warnings,kvm-test-1-run.sh.out,kvm-test-1-run-qemu.sh.out,vmlinux} "$rundir"/log
+rm -f "$rundir"/*/{console.log,console.log.diags,qemu_pid,qemu-pid,qemu-retval,Warnings,kvm-test-1-run.sh.out,kvm-test-1-run-qemu.sh.out,vmlinux} "$rundir"/log
 touch "$rundir/log"
 echo $scriptname $args | tee -a "$rundir/log"
 echo $oldrun > "$rundir/re-run"
diff --git a/tools/testing/selftests/rcutorture/bin/kvm-remote.sh b/tools/testing/selftests/rcutorture/bin/kvm-remote.sh
index f52641fdd1fe7..19cadb1b2f2d3 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-remote.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-remote.sh
@@ -254,7 +254,7 @@ do
 		sleep 30
 	done
 	echo " ---" Collecting results from $i `date`
-	( cd "$oldrun"; ssh $i "cd $rundir; tar -czf - kvm-remote-*.sh.out */console.log */kvm-test-1-run*.sh.out */qemu_pid */qemu-retval; rm -rf $T > /dev/null 2>&1" | tar -xzf - )
+	( cd "$oldrun"; ssh $i "cd $rundir; tar -czf - kvm-remote-*.sh.out */console.log */kvm-test-1-run*.sh.out */qemu[_-]pid */qemu-retval; rm -rf $T > /dev/null 2>&1" | tar -xzf - )
 done
 
 ( kvm-end-run-stats.sh "$oldrun" "$starttime"; echo $? > $T/exitcode ) | tee -a "$oldrun/remote-log"
diff --git a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
index b9a0bb6f01154..d828a34b5b89f 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
@@ -47,7 +47,7 @@ then
 fi
 sed -e 's/^[^#].*$/'"$taskset_command"'& 2>\&1 \&/' < $resdir/qemu-cmd > $T/qemu-cmd
 echo 'qemu_pid=$!' >> $T/qemu-cmd
-echo 'echo $qemu_pid > $resdir/qemu_pid' >> $T/qemu-cmd
+echo 'echo $qemu_pid > $resdir/qemu-pid' >> $T/qemu-cmd
 echo 'taskset -c -p $qemu_pid > $resdir/qemu-affinity' >> $T/qemu-cmd
 
 # In case qemu refuses to run...
@@ -55,14 +55,14 @@ echo "NOTE: $QEMU either did not run or was interactive" > $resdir/console.log
 
 # Attempt to run qemu
 kstarttime=`gawk 'BEGIN { print systime() }' < /dev/null`
-( . $T/qemu-cmd; wait `cat  $resdir/qemu_pid`; echo $? > $resdir/qemu-retval ) &
+( . $T/qemu-cmd; wait `cat  $resdir/qemu-pid`; echo $? > $resdir/qemu-retval ) &
 commandcompleted=0
 if test -z "$TORTURE_KCONFIG_GDB_ARG"
 then
 	sleep 10 # Give qemu's pid a chance to reach the file
-	if test -s "$resdir/qemu_pid"
+	if test -s "$resdir/qemu-pid"
 	then
-		qemu_pid=`cat "$resdir/qemu_pid"`
+		qemu_pid=`cat "$resdir/qemu-pid"`
 		echo Monitoring qemu job at pid $qemu_pid
 	else
 		qemu_pid=""
@@ -89,9 +89,9 @@ then
 fi
 while :
 do
-	if test -z "$qemu_pid" -a -s "$resdir/qemu_pid"
+	if test -z "$qemu_pid" -a -s "$resdir/qemu-pid"
 	then
-		qemu_pid=`cat "$resdir/qemu_pid"`
+		qemu_pid=`cat "$resdir/qemu-pid"`
 	fi
 	kruntime=`gawk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null`
 	if test -z "$qemu_pid" || kill -0 "$qemu_pid" > /dev/null 2>&1
@@ -122,9 +122,9 @@ do
 		break
 	fi
 done
-if test -z "$qemu_pid" -a -s "$resdir/qemu_pid"
+if test -z "$qemu_pid" -a -s "$resdir/qemu-pid"
 then
-	qemu_pid=`cat "$resdir/qemu_pid"`
+	qemu_pid=`cat "$resdir/qemu-pid"`
 fi
 if test $commandcompleted -eq 0 -a -n "$qemu_pid"
 then
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH rcu 18/21] torture: Make kvm-test-1-run-batch.sh select per-scenario affinity masks
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
                   ` (16 preceding siblings ...)
  2021-07-21 21:01 ` [PATCH rcu 17/21] torture: Consistently name "qemu*" test output files Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 19/21] torture: Don't use "test" command's "-a" argument Paul E. McKenney
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

This commit causes kvm-test-1-run-batch.sh to use the new
kvm-assign-cpus.sh and kvm-get-cpus-script.sh scripts to create a
TORTURE_AFFINITY environment variable containing either an empty string
(for no affinity) or a list of CPUs to pin the scenario's vCPUs to.
The additional change to kvm-test-1-run.sh places the per-scenario
number-of-CPUs information where it can easily be found.

If there is some reason why affinity cannot be supplied, this commit
prints and logs the reason via changes to kvm-again.sh.

Finally, this commit updates the kvm-remote.sh script to copy the
qemu-affinity output files back to the host system.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 .../selftests/rcutorture/bin/kvm-again.sh     |  2 +-
 .../selftests/rcutorture/bin/kvm-remote.sh    |  2 +-
 .../rcutorture/bin/kvm-test-1-run-batch.sh    | 23 +++++++++++++++++++
 .../rcutorture/bin/kvm-test-1-run.sh          |  1 +
 4 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/rcutorture/bin/kvm-again.sh b/tools/testing/selftests/rcutorture/bin/kvm-again.sh
index b7b8d6856d7ec..5a0023d183dac 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-again.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-again.sh
@@ -179,6 +179,6 @@ if test -n "$dryrun"
 then
 	echo ---- Dryrun complete, directory: $rundir | tee -a "$rundir/log"
 else
-	( cd "$rundir"; sh $T/runbatches.sh )
+	( cd "$rundir"; sh $T/runbatches.sh ) | tee -a "$rundir/log"
 	kvm-end-run-stats.sh "$rundir" "$starttime"
 fi
diff --git a/tools/testing/selftests/rcutorture/bin/kvm-remote.sh b/tools/testing/selftests/rcutorture/bin/kvm-remote.sh
index 19cadb1b2f2d3..03126eb6ec5ae 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-remote.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-remote.sh
@@ -254,7 +254,7 @@ do
 		sleep 30
 	done
 	echo " ---" Collecting results from $i `date`
-	( cd "$oldrun"; ssh $i "cd $rundir; tar -czf - kvm-remote-*.sh.out */console.log */kvm-test-1-run*.sh.out */qemu[_-]pid */qemu-retval; rm -rf $T > /dev/null 2>&1" | tar -xzf - )
+	( cd "$oldrun"; ssh $i "cd $rundir; tar -czf - kvm-remote-*.sh.out */console.log */kvm-test-1-run*.sh.out */qemu[_-]pid */qemu-retval */qemu-affinity; rm -rf $T > /dev/null 2>&1" | tar -xzf - )
 done
 
 ( kvm-end-run-stats.sh "$oldrun" "$starttime"; echo $? > $T/exitcode ) | tee -a "$oldrun/remote-log"
diff --git a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-batch.sh b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-batch.sh
index 005a048c55aa0..1e29d656501bc 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-batch.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-batch.sh
@@ -50,11 +50,34 @@ grep '^#' $1/qemu-cmd | sed -e 's/^# //' > $T/qemu-cmd-settings
 echo ---- System running test: `uname -a`
 echo ---- Starting kernels. `date` | tee -a log
 $TORTURE_JITTER_START
+kvm-assign-cpus.sh /sys/devices/system/node > $T/cpuarray.awk
 for i in "$@"
 do
 	echo ---- System running test: `uname -a` > $i/kvm-test-1-run-qemu.sh.out
 	echo > $i/kvm-test-1-run-qemu.sh.out
 	export TORTURE_AFFINITY=
+	kvm-get-cpus-script.sh $T/cpuarray.awk $T/cpubatches.awk $T/cpustate
+	cat << '	___EOF___' >> $T/cpubatches.awk
+	END {
+		affinitylist = "";
+		if (!gotcpus()) {
+			print "echo No CPU-affinity information, so no taskset command.";
+		} else if (cpu_count !~ /^[0-9][0-9]*$/) {
+			print "echo " scenario ": Bogus number of CPUs (old qemu-cmd?), so no taskset command.";
+		} else {
+			affinitylist = nextcpus(cpu_count);
+			if (!(affinitylist ~ /^[0-9,-][0-9,-]*$/))
+				print "echo " scenario ": Bogus CPU-affinity information, so no taskset command.";
+			else if (!dumpcpustate())
+				print "echo " scenario ": Could not dump state, so no taskset command.";
+			else
+				print "export TORTURE_AFFINITY=" affinitylist;
+		}
+	}
+	___EOF___
+	cpu_count="`grep '# TORTURE_CPU_COUNT=' $i/qemu-cmd | sed -e 's/^.*=//'`"
+	affinity_export="`awk -f $T/cpubatches.awk -v cpu_count="$cpu_count" -v scenario=$i < /dev/null`"
+	$affinity_export
 	kvm-test-1-run-qemu.sh $i >> $i/kvm-test-1-run-qemu.sh.out 2>&1 &
 done
 for i in $runfiles
diff --git a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
index f10f426f50893..f4c8055dbf7ad 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
@@ -205,6 +205,7 @@ echo "# TORTURE_KCONFIG_GDB_ARG=\"$TORTURE_KCONFIG_GDB_ARG\"" >> $resdir/qemu-cm
 echo "# TORTURE_JITTER_START=\"$TORTURE_JITTER_START\"" >> $resdir/qemu-cmd
 echo "# TORTURE_JITTER_STOP=\"$TORTURE_JITTER_STOP\"" >> $resdir/qemu-cmd
 echo "# TORTURE_TRUST_MAKE=\"$TORTURE_TRUST_MAKE\"; export TORTURE_TRUST_MAKE" >> $resdir/qemu-cmd
+echo "# TORTURE_CPU_COUNT=$cpu_count" >> $resdir/qemu-cmd
 
 if test -n "$TORTURE_BUILDONLY"
 then
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH rcu 19/21] torture: Don't use "test" command's "-a" argument
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
                   ` (17 preceding siblings ...)
  2021-07-21 21:01 ` [PATCH rcu 18/21] torture: Make kvm-test-1-run-batch.sh select per-scenario affinity masks Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 20/21] torture: Add timestamps to kvm-test-1-run-qemu.sh output Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 21/21] torture: Make kvm-test-1-run-qemu.sh check for reboot loops Paul E. McKenney
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

There was a time long ago when the "test" command's documentation
claimed that the "-a" and "-o" arguments did something useful.
But this documentation now suggests letting the shell execute
these boolean operators, so this commit applies that suggestion to
kvm-test-1-run-qemu.sh.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 .../selftests/rcutorture/bin/kvm-test-1-run-qemu.sh    | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
index d828a34b5b89f..ca1d49c1c2f45 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
@@ -89,7 +89,7 @@ then
 fi
 while :
 do
-	if test -z "$qemu_pid" -a -s "$resdir/qemu-pid"
+	if test -z "$qemu_pid" && test -s "$resdir/qemu-pid"
 	then
 		qemu_pid=`cat "$resdir/qemu-pid"`
 	fi
@@ -122,11 +122,11 @@ do
 		break
 	fi
 done
-if test -z "$qemu_pid" -a -s "$resdir/qemu-pid"
+if test -z "$qemu_pid" && test -s "$resdir/qemu-pid"
 then
 	qemu_pid=`cat "$resdir/qemu-pid"`
 fi
-if test $commandcompleted -eq 0 -a -n "$qemu_pid"
+if test $commandcompleted -eq 0 && test -n "$qemu_pid"
 then
 	if ! test -f "$resdir/../STOP.1"
 	then
@@ -159,11 +159,11 @@ then
 		then
 			last_ts=0
 		fi
-		if test "$newline" != "$oldline" -a "$last_ts" -lt $((seconds + $TORTURE_SHUTDOWN_GRACE))
+		if test "$newline" != "$oldline" && test "$last_ts" -lt $((seconds + $TORTURE_SHUTDOWN_GRACE))
 		then
 			must_continue=yes
 		fi
-		if test $must_continue = no -a $kruntime -ge $((seconds + $TORTURE_SHUTDOWN_GRACE))
+		if test $must_continue = no && test $kruntime -ge $((seconds + $TORTURE_SHUTDOWN_GRACE))
 		then
 			echo "!!! PID $qemu_pid hung at $kruntime vs. $seconds seconds" >> $resdir/Warnings 2>&1
 			kill -KILL $qemu_pid
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH rcu 20/21] torture: Add timestamps to kvm-test-1-run-qemu.sh output
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
                   ` (18 preceding siblings ...)
  2021-07-21 21:01 ` [PATCH rcu 19/21] torture: Don't use "test" command's "-a" argument Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  2021-07-21 21:01 ` [PATCH rcu 21/21] torture: Make kvm-test-1-run-qemu.sh check for reboot loops Paul E. McKenney
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

The kvm-test-1-run-qemu.sh script logs the torture-test start time and
also when it starts getting impatient for the test to finish.  However, it
does not timestamp these log messages, which can make debugging needlessly
challenging.  This commit therefore adds timestamps to these messages.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 .../selftests/rcutorture/bin/kvm-test-1-run-qemu.sh    | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
index ca1d49c1c2f45..b41252033fac0 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
@@ -63,10 +63,10 @@ then
 	if test -s "$resdir/qemu-pid"
 	then
 		qemu_pid=`cat "$resdir/qemu-pid"`
-		echo Monitoring qemu job at pid $qemu_pid
+		echo Monitoring qemu job at pid $qemu_pid `date`
 	else
 		qemu_pid=""
-		echo Monitoring qemu job at yet-as-unknown pid
+		echo Monitoring qemu job at yet-as-unknown pid `date`
 	fi
 fi
 if test -n "$TORTURE_KCONFIG_GDB_ARG"
@@ -130,14 +130,14 @@ if test $commandcompleted -eq 0 && test -n "$qemu_pid"
 then
 	if ! test -f "$resdir/../STOP.1"
 	then
-		echo Grace period for qemu job at pid $qemu_pid
+		echo Grace period for qemu job at pid $qemu_pid `date`
 	fi
 	oldline="`tail $resdir/console.log`"
 	while :
 	do
 		if test -f "$resdir/../STOP.1"
 		then
-			echo "PID $qemu_pid killed due to run STOP.1 request" >> $resdir/Warnings 2>&1
+			echo "PID $qemu_pid killed due to run STOP.1 request `date`" >> $resdir/Warnings 2>&1
 			kill -KILL $qemu_pid
 			break
 		fi
@@ -165,7 +165,7 @@ then
 		fi
 		if test $must_continue = no && test $kruntime -ge $((seconds + $TORTURE_SHUTDOWN_GRACE))
 		then
-			echo "!!! PID $qemu_pid hung at $kruntime vs. $seconds seconds" >> $resdir/Warnings 2>&1
+			echo "!!! PID $qemu_pid hung at $kruntime vs. $seconds seconds `date`" >> $resdir/Warnings 2>&1
 			kill -KILL $qemu_pid
 			break
 		fi
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH rcu 21/21] torture: Make kvm-test-1-run-qemu.sh check for reboot loops
  2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
                   ` (19 preceding siblings ...)
  2021-07-21 21:01 ` [PATCH rcu 20/21] torture: Add timestamps to kvm-test-1-run-qemu.sh output Paul E. McKenney
@ 2021-07-21 21:01 ` Paul E. McKenney
  20 siblings, 0 replies; 22+ messages in thread
From: Paul E. McKenney @ 2021-07-21 21:01 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

It turns out that certain types of early boot bugs can result in reboot
loops, even within a guest OS running under qemu/KVM.  This commit
therefore upgrades the kvm-test-1-run-qemu.sh script's hang-detection
heuristics to detect such situations and to terminate the run when
they occur.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 .../testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
index b41252033fac0..44280582c594e 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run-qemu.sh
@@ -159,9 +159,13 @@ then
 		then
 			last_ts=0
 		fi
-		if test "$newline" != "$oldline" && test "$last_ts" -lt $((seconds + $TORTURE_SHUTDOWN_GRACE))
+		if test "$newline" != "$oldline" && test "$last_ts" -lt $((seconds + $TORTURE_SHUTDOWN_GRACE)) && test "$last_ts" -gt "$TORTURE_SHUTDOWN_GRACE"
 		then
 			must_continue=yes
+			if test $kruntime -ge $((seconds + $TORTURE_SHUTDOWN_GRACE))
+			then
+				echo Continuing at console.log time $last_ts \"`tail -n 1 $resdir/console.log`\" `date`
+			fi
 		fi
 		if test $must_continue = no && test $kruntime -ge $((seconds + $TORTURE_SHUTDOWN_GRACE))
 		then
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2021-07-21 21:02 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-21 20:55 [PATCH rcu 0/21] Torture-test scripting updates for v5.15 Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 01/21] torture: Add clocksource-watchdog testing to torture.sh Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 02/21] torture: Make torture.sh accept --do-all and --donone Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 03/21] torture: Enable KCSAN summaries over groups of torture-test runs Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 04/21] torture: Create KCSAN summaries for torture.sh runs Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 05/21] torture: Make kvm-recheck-scf.sh tolerate qemu-cmd comments Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 06/21] torture: Make kvm-recheck-lock.sh " Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 07/21] torture: Log more kvm-remote.sh information Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 08/21] torture: Protect kvm-remote.sh directory trees from /tmp reaping Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 09/21] torture: Make kvm-recheck.sh skip kcsan.sum for build-only runs Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 10/21] torture: Move parse-console.sh call to PATH-aware scripts Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 11/21] torture: Put kvm.sh batch-creation awk script into a temp file Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 12/21] torture: Make kvm.sh select per-scenario affinity masks Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 13/21] torture: Don't redirect qemu-cmd comment lines Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 14/21] torture: Make kvm-test-1-run-qemu.sh apply affinity Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 15/21] rcutorture: Upgrade two-CPU scenarios to four CPUs Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 16/21] torture: Use numeric taskset argument in jitter.sh Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 17/21] torture: Consistently name "qemu*" test output files Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 18/21] torture: Make kvm-test-1-run-batch.sh select per-scenario affinity masks Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 19/21] torture: Don't use "test" command's "-a" argument Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 20/21] torture: Add timestamps to kvm-test-1-run-qemu.sh output Paul E. McKenney
2021-07-21 21:01 ` [PATCH rcu 21/21] torture: Make kvm-test-1-run-qemu.sh check for reboot loops Paul E. McKenney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).