All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] torture: Update bare metal config generation
@ 2021-05-06 13:15 Frederic Weisbecker
  2021-05-06 13:15 ` [PATCH 1/3] torture: Add --cmdline-to-config parameter to kvm.sh Frederic Weisbecker
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Frederic Weisbecker @ 2021-05-06 13:15 UTC (permalink / raw)
  To: Paul E . McKenney; +Cc: LKML, Frederic Weisbecker

Hi,

I've been using these changes for my bare-metal testings for a few weeks
now and I figured I should share even though I bet I'm the only one who
runs rcutorture on bare-metal, but who knows?

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git
	rcu/dev

HEAD: 2ffb53f35976a1e12c481fd059701e66a6cd28ae

Thanks,
	Frederic
---

Frederic Weisbecker (3):
      torture: Add --cmdline-to-config parameter to kvm.sh
      torture: Add --configonly parameter for kvm.sh
      torture: Update bare metal advices to latest kvm.sh options


 .../testing/selftests/rcutorture/bin/configinit.sh | 13 +++++
 .../testing/selftests/rcutorture/bin/kvm-build.sh  |  9 ++-
 .../selftests/rcutorture/bin/kvm-recheck.sh        |  6 +-
 .../selftests/rcutorture/bin/kvm-test-1-run.sh     | 67 +++++++++++++---------
 tools/testing/selftests/rcutorture/bin/kvm.sh      | 32 ++++++++---
 5 files changed, 91 insertions(+), 36 deletions(-)

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

* [PATCH 1/3] torture: Add --cmdline-to-config parameter to kvm.sh
  2021-05-06 13:15 [PATCH 0/3] torture: Update bare metal config generation Frederic Weisbecker
@ 2021-05-06 13:15 ` Frederic Weisbecker
  2021-05-07 19:20   ` Paul E. McKenney
  2021-05-06 13:15 ` [PATCH 2/3] torture: Add --configonly parameter for kvm.sh Frederic Weisbecker
  2021-05-06 13:15 ` [PATCH 3/3] torture: Update bare metal advices to latest kvm.sh options Frederic Weisbecker
  2 siblings, 1 reply; 10+ messages in thread
From: Frederic Weisbecker @ 2021-05-06 13:15 UTC (permalink / raw)
  To: Paul E . McKenney; +Cc: LKML, Frederic Weisbecker

While running rcutorture on bare metal, an easy way to test is to build
a kernel with the torture scenario parameters built-in using
CONFIG_CMDLINE="". This way the remote box can simply download the image
and the boot loader doesn't need to be updated with the new kernel
parameters.

Provide kvm.sh with --cmdline-to-config to perform that.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
---
 .../selftests/rcutorture/bin/configinit.sh    | 13 +++++++
 .../selftests/rcutorture/bin/kvm-build.sh     |  4 ++-
 .../rcutorture/bin/kvm-test-1-run.sh          | 34 +++++++++++--------
 tools/testing/selftests/rcutorture/bin/kvm.sh |  6 ++++
 4 files changed, 41 insertions(+), 16 deletions(-)

diff --git a/tools/testing/selftests/rcutorture/bin/configinit.sh b/tools/testing/selftests/rcutorture/bin/configinit.sh
index d6e5ce084b1c..d2b8a68114e4 100755
--- a/tools/testing/selftests/rcutorture/bin/configinit.sh
+++ b/tools/testing/selftests/rcutorture/bin/configinit.sh
@@ -23,6 +23,8 @@ mkdir $T
 
 c=$1
 resdir=$2
+kboot_args=$3
+modprobe_args=$4
 
 sed -e 's/^\(CONFIG[0-9A-Z_]*\)=.*$/grep -v "^# \1" |/' < $c > $T/u.sh
 sed -e 's/^\(CONFIG[0-9A-Z_]*=\).*$/grep -v \1 |/' < $c >> $T/u.sh
@@ -35,6 +37,17 @@ fi
 make $TORTURE_KMAKE_ARG $TORTURE_DEFCONFIG > $resdir/Make.defconfig.out 2>&1
 mv .config .config.sav
 sh $T/upd.sh < .config.sav > .config
+
+if test -n "$TORTURE_CMDLINE2CONFIG"
+then
+	cmdline=$(grep "CONFIG_CMDLINE=" .config | sed -E 's/CONFIG_CMDLINE="(.*)"/\1/')
+	prefixed_modprobe_args=$(echo $modprobe_args | sed -E -e "s/([^ ]+?)(=[^ ]*)?/rcutorture.\1\2/g")
+	cmdline="$kboot_args $prefixed_modprobe_args $cmdline"
+	grep -Ev "CONFIG_CMDLINE[= ]" .config > .config.sav
+	mv .config.sav .config
+	echo "CONFIG_CMDLINE=\""$cmdline"\"" >> .config
+fi
+
 cp .config .config.new
 yes '' | make $TORTURE_KMAKE_ARG oldconfig > $resdir/Make.oldconfig.out 2> $resdir/Make.oldconfig.err
 
diff --git a/tools/testing/selftests/rcutorture/bin/kvm-build.sh b/tools/testing/selftests/rcutorture/bin/kvm-build.sh
index 5ad973dca820..9eb4324d42e1 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-build.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-build.sh
@@ -22,6 +22,8 @@ then
 	exit 1
 fi
 resdir=${2}
+kboot_args=${3}
+modprobe_args=${4}
 
 T=${TMPDIR-/tmp}/test-linux.sh.$$
 trap 'rm -rf $T' 0
@@ -34,7 +36,7 @@ CONFIG_VIRTIO_PCI=y
 CONFIG_VIRTIO_CONSOLE=y
 ___EOF___
 
-configinit.sh $T/config $resdir
+configinit.sh $T/config $resdir "$kboot_args" "$modprobe_args"
 retval=$?
 if test $retval -gt 1
 then
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 420ed5ce9d32..e6aece69d81b 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
@@ -71,6 +71,24 @@ config_override_param "--kcsan options" KcList "$TORTURE_KCONFIG_KCSAN_ARG"
 config_override_param "--kconfig argument" KcList "$TORTURE_KCONFIG_ARG"
 cp $T/KcList $resdir/ConfigFragment
 
+seconds=$3
+qemu_args=$4
+boot_args_in=$5
+
+# Pull in Kconfig-fragment boot parameters
+boot_args="`configfrag_boot_params "$boot_args_in" "$config_template"`"
+# Generate kernel-version-specific boot parameters
+boot_args="`per_version_boot_params "$boot_args" $resdir/.config $seconds`"
+
+if test -n "$TORTURE_BOOT_GDB_ARG"
+then
+	boot_args="$boot_args $TORTURE_BOOT_GDB_ARG"
+fi
+
+modprobe_args="`echo $boot_args | tr -s ' ' '\012' | grep "^$TORTURE_MOD\." | sed -e "s/$TORTURE_MOD\.//g"`"
+kboot_args="`echo $boot_args | tr -s ' ' '\012' | grep -v "^$TORTURE_MOD\."`"
+
+
 base_resdir=`echo $resdir | sed -e 's/\.[0-9]\+$//'`
 if test "$base_resdir" != "$resdir" && test -f $base_resdir/bzImage && test -f $base_resdir/vmlinux
 then
@@ -93,7 +111,7 @@ then
 		mv $resdir/build.wait $resdir/build.ready
 	fi
 	exit 1
-elif kvm-build.sh $T/KcList $resdir
+elif kvm-build.sh $T/KcList $resdir "$kboot_args" "$modprobe_args"
 then
 	# Had to build a kernel for this test.
 	QEMU="`identify_qemu vmlinux`"
@@ -131,9 +149,6 @@ while test -f $resdir/build.ready
 do
 	sleep 1
 done
-seconds=$3
-qemu_args=$4
-boot_args_in=$5
 
 if test -z "$TORTURE_BUILDONLY"
 then
@@ -158,18 +173,7 @@ qemu_args="$qemu_args `identify_qemu_args "$QEMU" "$resdir/console.log"`"
 # Generate qemu -append arguments
 qemu_append="`identify_qemu_append "$QEMU"`"
 
-# Pull in Kconfig-fragment boot parameters
-boot_args="`configfrag_boot_params "$boot_args_in" "$config_template"`"
-# Generate kernel-version-specific boot parameters
-boot_args="`per_version_boot_params "$boot_args" $resdir/.config $seconds`"
-if test -n "$TORTURE_BOOT_GDB_ARG"
-then
-	boot_args="$boot_args $TORTURE_BOOT_GDB_ARG"
-fi
-
 # Give bare-metal advice
-modprobe_args="`echo $boot_args | tr -s ' ' '\012' | grep "^$TORTURE_MOD\." | sed -e "s/$TORTURE_MOD\.//g"`"
-kboot_args="`echo $boot_args | tr -s ' ' '\012' | grep -v "^$TORTURE_MOD\."`"
 testid_txt="`dirname $resdir`/testid.txt"
 touch $resdir/bare-metal
 echo To run this scenario on bare metal: >> $resdir/bare-metal
diff --git a/tools/testing/selftests/rcutorture/bin/kvm.sh b/tools/testing/selftests/rcutorture/bin/kvm.sh
index b4ac4ee33222..a05a20135de1 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm.sh
@@ -33,6 +33,7 @@ TORTURE_ALLOTED_CPUS="`identify_qemu_vcpus`"
 TORTURE_DEFCONFIG=defconfig
 TORTURE_BOOT_IMAGE=""
 TORTURE_BUILDONLY=
+TORTURE_CMDLINE2CONFIG=
 TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
 TORTURE_KCONFIG_ARG=""
 TORTURE_KCONFIG_GDB_ARG=""
@@ -64,6 +65,7 @@ usage () {
 	echo "       --bootargs kernel-boot-arguments"
 	echo "       --bootimage relative-path-to-kernel-boot-image"
 	echo "       --buildonly"
+	echo "       --cmdline-to-config"
 	echo "       --configs \"config-file list w/ repeat factor (3*TINY01)\""
 	echo "       --cpus N"
 	echo "       --datestamp string"
@@ -108,6 +110,9 @@ do
 	--buildonly|--build-only)
 		TORTURE_BUILDONLY=1
 		;;
+	--cmdline-to-config)
+		TORTURE_CMDLINE2CONFIG=1
+		;;
 	--configs|--config)
 		checkarg --configs "(list of config files)" "$#" "$2" '^[^/.a-z]\+$' '^--'
 		configs="$configs $2"
@@ -388,6 +393,7 @@ PATH="$PATH"; export PATH
 TORTURE_ALLOTED_CPUS="$TORTURE_ALLOTED_CPUS"; export TORTURE_ALLOTED_CPUS
 TORTURE_BOOT_IMAGE="$TORTURE_BOOT_IMAGE"; export TORTURE_BOOT_IMAGE
 TORTURE_BUILDONLY="$TORTURE_BUILDONLY"; export TORTURE_BUILDONLY
+TORTURE_CMDLINE2CONFIG="$TORTURE_CMDLINE2CONFIG"; export TORTURE_CMDLINE2CONFIG
 TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG
 TORTURE_INITRD="$TORTURE_INITRD"; export TORTURE_INITRD
 TORTURE_KCONFIG_ARG="$TORTURE_KCONFIG_ARG"; export TORTURE_KCONFIG_ARG
-- 
2.25.1


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

* [PATCH 2/3] torture: Add --configonly parameter for kvm.sh
  2021-05-06 13:15 [PATCH 0/3] torture: Update bare metal config generation Frederic Weisbecker
  2021-05-06 13:15 ` [PATCH 1/3] torture: Add --cmdline-to-config parameter to kvm.sh Frederic Weisbecker
@ 2021-05-06 13:15 ` Frederic Weisbecker
  2021-05-07 20:29   ` Paul E. McKenney
  2021-05-06 13:15 ` [PATCH 3/3] torture: Update bare metal advices to latest kvm.sh options Frederic Weisbecker
  2 siblings, 1 reply; 10+ messages in thread
From: Frederic Weisbecker @ 2021-05-06 13:15 UTC (permalink / raw)
  To: Paul E . McKenney; +Cc: LKML, Frederic Weisbecker

Those who just want the resulting config file to generate for bare metal
don't need to wait for the build. Provide an option to only produce
the .config file.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
---
 .../selftests/rcutorture/bin/kvm-build.sh     |  5 ++++
 .../selftests/rcutorture/bin/kvm-recheck.sh   |  6 ++++-
 .../rcutorture/bin/kvm-test-1-run.sh          | 12 ++++++++-
 tools/testing/selftests/rcutorture/bin/kvm.sh | 26 +++++++++++++------
 4 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/rcutorture/bin/kvm-build.sh b/tools/testing/selftests/rcutorture/bin/kvm-build.sh
index 9eb4324d42e1..463db5590220 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-build.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-build.sh
@@ -43,6 +43,11 @@ then
 	exit 2
 fi
 
+if test -n "$TORTURE_CONFIGONLY"
+then
+    exit 0
+fi
+
 # Tell "make" to use double the number of real CPUs on the build system.
 ncpus="`getconf _NPROCESSORS_ONLN`"
 make -j$((2 * ncpus)) $TORTURE_KMAKE_ARG > $resdir/Make.out 2>&1
diff --git a/tools/testing/selftests/rcutorture/bin/kvm-recheck.sh b/tools/testing/selftests/rcutorture/bin/kvm-recheck.sh
index e01b31b87044..68b521b5961e 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-recheck.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-recheck.sh
@@ -57,7 +57,11 @@ do
 				cat $i/Warnings
 			fi
 		else
-			if test -f "$i/buildonly"
+			if test -f "$i/configonly"
+			then
+				echo Config-only run, no build/boot/test
+				configcheck.sh $i/.config $i/ConfigFragment
+			elif test -f "$i/buildonly"
 			then
 				echo Build-only run, no boot/test
 				configcheck.sh $i/.config $i/ConfigFragment
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 e6aece69d81b..6df9efc77469 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
@@ -113,11 +113,21 @@ then
 	exit 1
 elif kvm-build.sh $T/KcList $resdir "$kboot_args" "$modprobe_args"
 then
+	cp .config $resdir
+	if test -n "$TORTURE_CONFIGONLY"
+	then
+		if test -f $resdir/build.wait
+		then
+			rm $resdir/build.wait
+		fi
+		echo Config-only run specified, build/boot/test omitted.
+		touch $resdir/configonly
+		exit 0
+	fi
 	# Had to build a kernel for this test.
 	QEMU="`identify_qemu vmlinux`"
 	BOOT_IMAGE="`identify_boot_image $QEMU`"
 	cp vmlinux $resdir
-	cp .config $resdir
 	cp Module.symvers $resdir > /dev/null || :
 	cp System.map $resdir > /dev/null || :
 	if test -n "$BOOT_IMAGE"
diff --git a/tools/testing/selftests/rcutorture/bin/kvm.sh b/tools/testing/selftests/rcutorture/bin/kvm.sh
index a05a20135de1..283f5d896234 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm.sh
@@ -34,6 +34,7 @@ TORTURE_DEFCONFIG=defconfig
 TORTURE_BOOT_IMAGE=""
 TORTURE_BUILDONLY=
 TORTURE_CMDLINE2CONFIG=
+TORTURE_CONFIGONLY=
 TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
 TORTURE_KCONFIG_ARG=""
 TORTURE_KCONFIG_GDB_ARG=""
@@ -66,6 +67,7 @@ usage () {
 	echo "       --bootimage relative-path-to-kernel-boot-image"
 	echo "       --buildonly"
 	echo "       --cmdline-to-config"
+	echo "       --configonly"
 	echo "       --configs \"config-file list w/ repeat factor (3*TINY01)\""
 	echo "       --cpus N"
 	echo "       --datestamp string"
@@ -113,6 +115,9 @@ do
 	--cmdline-to-config)
 		TORTURE_CMDLINE2CONFIG=1
 		;;
+	--configonly|--config-only)
+		TORTURE_CONFIGONLY=1
+		;;
 	--configs|--config)
 		checkarg --configs "(list of config files)" "$#" "$2" '^[^/.a-z]\+$' '^--'
 		configs="$configs $2"
@@ -394,6 +399,7 @@ TORTURE_ALLOTED_CPUS="$TORTURE_ALLOTED_CPUS"; export TORTURE_ALLOTED_CPUS
 TORTURE_BOOT_IMAGE="$TORTURE_BOOT_IMAGE"; export TORTURE_BOOT_IMAGE
 TORTURE_BUILDONLY="$TORTURE_BUILDONLY"; export TORTURE_BUILDONLY
 TORTURE_CMDLINE2CONFIG="$TORTURE_CMDLINE2CONFIG"; export TORTURE_CMDLINE2CONFIG
+TORTURE_CONFIGONLY="$TORTURE_CONFIGONLY"; export TORTURE_CONFIGONLY
 TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG
 TORTURE_INITRD="$TORTURE_INITRD"; export TORTURE_INITRD
 TORTURE_KCONFIG_ARG="$TORTURE_KCONFIG_ARG"; export TORTURE_KCONFIG_ARG
@@ -438,6 +444,7 @@ fi
 ___EOF___
 awk < $T/cfgcpu.pack \
 	-v TORTURE_BUILDONLY="$TORTURE_BUILDONLY" \
+	-v TORTURE_CONFIGONLY="$TORTURE_CONFIGONLY" \
 	-v CONFIGDIR="$CONFIGFRAG/" \
 	-v KVM="$KVM" \
 	-v ncpus=$cpus \
@@ -490,12 +497,14 @@ function dump(first, pastlast, batchnum)
 		print "mkdir " rd cfr[jn] " || :";
 		print "touch " builddir ".wait";
 		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"
-		print "do"
-		print "\tsleep 1"
-		print "done"
-		print "echo ", cfr[jn], cpusr[jn] ovf ": Build complete. `date` | tee -a " rd "log";
+		if (!TORTURE_CONFIGONLY) {
+			print "echo ", cfr[jn], cpusr[jn] ovf ": Waiting for build to complete. `date` | tee -a " rd "log";
+			print "while test -f " builddir ".wait"
+			print "do"
+			print "\tsleep 1"
+			print "done"
+			print "echo ", cfr[jn], cpusr[jn] ovf ": Build complete. `date` | tee -a " rd "log";
+		}
 		jn++;
 	}
 	print "runfiles="
@@ -503,7 +512,7 @@ function dump(first, pastlast, batchnum)
 		builddir=rd cfr[j] "/build";
 		if (TORTURE_BUILDONLY)
 			print "rm -f " builddir ".ready"
-		else
+		else if (!TORTURE_CONFIGONLY)
 			print "mv " builddir ".ready " builddir ".run"
 			print "runfiles=\"$runfiles " builddir ".run\""
 		fi
@@ -517,7 +526,8 @@ function dump(first, pastlast, batchnum)
 		njitter = 0;
 		print "echo Build-only run, so suppressing jitter | tee -a " rd "log"
 	}
-	if (TORTURE_BUILDONLY) {
+
+	if (TORTURE_BUILDONLY || TORTURE_CONFIGONLY) {
 		print "needqemurun="
 	}
 	print "if test -n \"$needqemurun\""
-- 
2.25.1


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

* [PATCH 3/3] torture: Update bare metal advices to latest kvm.sh options
  2021-05-06 13:15 [PATCH 0/3] torture: Update bare metal config generation Frederic Weisbecker
  2021-05-06 13:15 ` [PATCH 1/3] torture: Add --cmdline-to-config parameter to kvm.sh Frederic Weisbecker
  2021-05-06 13:15 ` [PATCH 2/3] torture: Add --configonly parameter for kvm.sh Frederic Weisbecker
@ 2021-05-06 13:15 ` Frederic Weisbecker
  2021-05-07 20:37   ` Paul E. McKenney
  2 siblings, 1 reply; 10+ messages in thread
From: Frederic Weisbecker @ 2021-05-06 13:15 UTC (permalink / raw)
  To: Paul E . McKenney; +Cc: LKML, Frederic Weisbecker

kvm.sh is perfectly able to build a new kernel config from an existing
one instead of using a defconfig. All we need to do is to pass:

	--defconfig oldconfig

This is much easier than manually modifying a .config from a
ConfigFragment file.

Then with the latest parameters that got added on kvm.sh, it's now
easy to build a bare metal .config for a cross target for example:

	./kvm.sh --configs "TREE01" --defconfig oldconfig --configonly
		--cmdline-to-config --kmake-arg ARCH=arm64 --no-initrd

After that all we need to do is to build the updated .config and run
the resulting image.

Update bare metal advices to propose that.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
---
 .../rcutorture/bin/kvm-test-1-run.sh          | 21 ++++++++++---------
 1 file changed, 11 insertions(+), 10 deletions(-)

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 6df9efc77469..47d69668ab37 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
@@ -190,27 +190,28 @@ echo To run this scenario on bare metal: >> $resdir/bare-metal
 echo >> $resdir/bare-metal
 echo " 1." Set your bare-metal build tree to the state shown in this file: >> $resdir/bare-metal
 echo "   " $testid_txt >> $resdir/bare-metal
-echo " 2." Update your bare-metal build tree"'"s .config based on this file: >> $resdir/bare-metal
-echo "   " $resdir/ConfigFragment >> $resdir/bare-metal
-echo " 3." Make the bare-metal kernel"'"s build system aware of your .config updates: >> $resdir/bare-metal
-echo "   " $ 'yes "" | make oldconfig' >> $resdir/bare-metal
-echo " 4." Build your bare-metal kernel. >> $resdir/bare-metal
+echo " 2." Prepare your bare-metal build tree"'"s .config on your root kernel directory >> $resdir/bare-metal
+echo " 3." Run this scenario with "'--defconfig oldconfig --configonly --no-initrd'" >> $resdir/bare-metal
+echo " 4." If you"'"re cross compiling then append the appropriate make arguments >> $resdir/bare-metal
+echo "   " eg: "'--kmake-arg ARCH=arm64'" >> $resdir/bare-metal
 echo " 5." Boot your bare-metal kernel with the following parameters: >> $resdir/bare-metal
 echo "   " $kboot_args >> $resdir/bare-metal
 echo " 6." Start the test with the following command: >> $resdir/bare-metal
 echo "   " $ modprobe $TORTURE_MOD $modprobe_args >> $resdir/bare-metal
 echo " 7." After some time, end the test with the following command: >> $resdir/bare-metal
 echo "   " $ rmmod $TORTURE_MOD >> $resdir/bare-metal
-echo " 8." Copy your bare-metal kernel"'"s .config file, overwriting this file: >> $resdir/bare-metal
+echo " 8." Alternatively if you run rcutorture in a built-in fashion and your kernel arguments are already >> $resdir/bare-metal
+echo "   " hardcoded in the kernel config, skip the previous 5/6/7 steps and append to kvm.sh arguments: >> $resdir/bare-metal
+echo "   " --cmdline-to-config >> $resdir/bare-metal
+echo "   " Then simply boot your kernel and wait for the end of the tests >> $resdir/bare-metal
+echo " 9." Copy your bare-metal kernel"'"s .config file, overwriting this file: >> $resdir/bare-metal
 echo "   " $resdir/.config >> $resdir/bare-metal
-echo " 9." Copy the console output from just before the modprobe to just after >> $resdir/bare-metal
+echo "10." Copy the console output from just before the modprobe to just after >> $resdir/bare-metal
 echo "   " the rmmod into this file: >> $resdir/bare-metal
 echo "   " $resdir/console.log >> $resdir/bare-metal
-echo "10." Check for runtime errors using the following command: >> $resdir/bare-metal
+echo "11." Check for runtime errors using the following command: >> $resdir/bare-metal
 echo "   " $ tools/testing/selftests/rcutorture/bin/kvm-recheck.sh `dirname $resdir` >> $resdir/bare-metal
 echo >> $resdir/bare-metal
-echo Some of the above steps may be skipped if you build your bare-metal >> $resdir/bare-metal
-echo kernel here: `head -n 1 $testid_txt | sed -e 's/^Build directory: //'`  >> $resdir/bare-metal
 
 echo $QEMU $qemu_args -m $TORTURE_QEMU_MEM -kernel $KERNEL -append \"$qemu_append $boot_args\" $TORTURE_QEMU_GDB_ARG > $resdir/qemu-cmd
 echo "# TORTURE_SHUTDOWN_GRACE=$TORTURE_SHUTDOWN_GRACE" >> $resdir/qemu-cmd
-- 
2.25.1


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

* Re: [PATCH 1/3] torture: Add --cmdline-to-config parameter to kvm.sh
  2021-05-06 13:15 ` [PATCH 1/3] torture: Add --cmdline-to-config parameter to kvm.sh Frederic Weisbecker
@ 2021-05-07 19:20   ` Paul E. McKenney
  2021-05-17 10:42     ` Frederic Weisbecker
  0 siblings, 1 reply; 10+ messages in thread
From: Paul E. McKenney @ 2021-05-07 19:20 UTC (permalink / raw)
  To: Frederic Weisbecker; +Cc: LKML

On Thu, May 06, 2021 at 03:15:08PM +0200, Frederic Weisbecker wrote:
> While running rcutorture on bare metal, an easy way to test is to build
> a kernel with the torture scenario parameters built-in using
> CONFIG_CMDLINE="". This way the remote box can simply download the image
> and the boot loader doesn't need to be updated with the new kernel
> parameters.

I had no idea about CONFIG_CMDLINE!  Thank you for introducing me to it!

> Provide kvm.sh with --cmdline-to-config to perform that.

If I understand correctly, kernel-boot parameters are processed after
the CONFIG_CMDLINE parameters.  If so, would it make sense (probably
as a separate patch) for the current --bootargs kernel parameters to be
supplied to CONFIG_CMDLINE in kvm.sh, and to add a --bootargs parameter
to kvm-again.sh which caused additional kernel-boot parameters to be
added to the end of the "-append" list in the qemu-cmd file?

As in, "Re-run this rcutorture run, but with rcutorture.onoff_interval=0
so as to disable CPU-hotplug operations"?

More on-point questions and comments interspersed below.  Well, hopefully
more on-point, anyway!

> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> ---
>  .../selftests/rcutorture/bin/configinit.sh    | 13 +++++++
>  .../selftests/rcutorture/bin/kvm-build.sh     |  4 ++-
>  .../rcutorture/bin/kvm-test-1-run.sh          | 34 +++++++++++--------
>  tools/testing/selftests/rcutorture/bin/kvm.sh |  6 ++++
>  4 files changed, 41 insertions(+), 16 deletions(-)
> 
> diff --git a/tools/testing/selftests/rcutorture/bin/configinit.sh b/tools/testing/selftests/rcutorture/bin/configinit.sh
> index d6e5ce084b1c..d2b8a68114e4 100755
> --- a/tools/testing/selftests/rcutorture/bin/configinit.sh
> +++ b/tools/testing/selftests/rcutorture/bin/configinit.sh
> @@ -23,6 +23,8 @@ mkdir $T
>  
>  c=$1
>  resdir=$2
> +kboot_args=$3
> +modprobe_args=$4
>  
>  sed -e 's/^\(CONFIG[0-9A-Z_]*\)=.*$/grep -v "^# \1" |/' < $c > $T/u.sh
>  sed -e 's/^\(CONFIG[0-9A-Z_]*=\).*$/grep -v \1 |/' < $c >> $T/u.sh
> @@ -35,6 +37,17 @@ fi
>  make $TORTURE_KMAKE_ARG $TORTURE_DEFCONFIG > $resdir/Make.defconfig.out 2>&1
>  mv .config .config.sav
>  sh $T/upd.sh < .config.sav > .config
> +
> +if test -n "$TORTURE_CMDLINE2CONFIG"
> +then
> +	cmdline=$(grep "CONFIG_CMDLINE=" .config | sed -E 's/CONFIG_CMDLINE="(.*)"/\1/')
> +	prefixed_modprobe_args=$(echo $modprobe_args | sed -E -e "s/([^ ]+?)(=[^ ]*)?/rcutorture.\1\2/g")

Doesn't this need to check for locktorture, refscale, rcuscale, and
scftorture as well as for rcutorture?  Maybe use the TORTURE_MOD
environment variable similar to the way you do in your change to
kvm-test-1-run.sh.

> +	cmdline="$kboot_args $prefixed_modprobe_args $cmdline"

This makes a "--kconfig CONFIG_CMDLINE=whatever" override the --bootargs
parameters.  Is that what we want?  Either way, why?

You could ask the same question about the current ordering of kernel
boot parameters from their various sources, and it would be good to do so.

> +	grep -Ev "CONFIG_CMDLINE[= ]" .config > .config.sav
> +	mv .config.sav .config
> +	echo "CONFIG_CMDLINE=\""$cmdline"\"" >> .config
> +fi
> +
>  cp .config .config.new
>  yes '' | make $TORTURE_KMAKE_ARG oldconfig > $resdir/Make.oldconfig.out 2> $resdir/Make.oldconfig.err
>  
> diff --git a/tools/testing/selftests/rcutorture/bin/kvm-build.sh b/tools/testing/selftests/rcutorture/bin/kvm-build.sh
> index 5ad973dca820..9eb4324d42e1 100755
> --- a/tools/testing/selftests/rcutorture/bin/kvm-build.sh
> +++ b/tools/testing/selftests/rcutorture/bin/kvm-build.sh
> @@ -22,6 +22,8 @@ then
>  	exit 1
>  fi
>  resdir=${2}
> +kboot_args=${3}
> +modprobe_args=${4}
>  
>  T=${TMPDIR-/tmp}/test-linux.sh.$$
>  trap 'rm -rf $T' 0
> @@ -34,7 +36,7 @@ CONFIG_VIRTIO_PCI=y
>  CONFIG_VIRTIO_CONSOLE=y
>  ___EOF___
>  
> -configinit.sh $T/config $resdir
> +configinit.sh $T/config $resdir "$kboot_args" "$modprobe_args"
>  retval=$?
>  if test $retval -gt 1
>  then
> 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 420ed5ce9d32..e6aece69d81b 100755
> --- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
> +++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
> @@ -71,6 +71,24 @@ config_override_param "--kcsan options" KcList "$TORTURE_KCONFIG_KCSAN_ARG"
>  config_override_param "--kconfig argument" KcList "$TORTURE_KCONFIG_ARG"
>  cp $T/KcList $resdir/ConfigFragment
>  
> +seconds=$3
> +qemu_args=$4
> +boot_args_in=$5
> +
> +# Pull in Kconfig-fragment boot parameters
> +boot_args="`configfrag_boot_params "$boot_args_in" "$config_template"`"
> +# Generate kernel-version-specific boot parameters
> +boot_args="`per_version_boot_params "$boot_args" $resdir/.config $seconds`"
> +
> +if test -n "$TORTURE_BOOT_GDB_ARG"
> +then
> +	boot_args="$boot_args $TORTURE_BOOT_GDB_ARG"
> +fi
> +
> +modprobe_args="`echo $boot_args | tr -s ' ' '\012' | grep "^$TORTURE_MOD\." | sed -e "s/$TORTURE_MOD\.//g"`"
> +kboot_args="`echo $boot_args | tr -s ' ' '\012' | grep -v "^$TORTURE_MOD\."`"
> +

We are in trouble if a kernel boot parameter contains a space character,
but we probably are already in trouble, so no problem.  ;-)

But don't we want to avoid adding these to the qemu -append argument
if they are already in CONFIG_CMDLINE?  Or is there some benefit to
duplicating them?

> +
>  base_resdir=`echo $resdir | sed -e 's/\.[0-9]\+$//'`
>  if test "$base_resdir" != "$resdir" && test -f $base_resdir/bzImage && test -f $base_resdir/vmlinux
>  then
> @@ -93,7 +111,7 @@ then
>  		mv $resdir/build.wait $resdir/build.ready
>  	fi
>  	exit 1
> -elif kvm-build.sh $T/KcList $resdir
> +elif kvm-build.sh $T/KcList $resdir "$kboot_args" "$modprobe_args"
>  then
>  	# Had to build a kernel for this test.
>  	QEMU="`identify_qemu vmlinux`"
> @@ -131,9 +149,6 @@ while test -f $resdir/build.ready
>  do
>  	sleep 1
>  done
> -seconds=$3
> -qemu_args=$4
> -boot_args_in=$5
>  
>  if test -z "$TORTURE_BUILDONLY"
>  then
> @@ -158,18 +173,7 @@ qemu_args="$qemu_args `identify_qemu_args "$QEMU" "$resdir/console.log"`"
>  # Generate qemu -append arguments
>  qemu_append="`identify_qemu_append "$QEMU"`"
>  
> -# Pull in Kconfig-fragment boot parameters
> -boot_args="`configfrag_boot_params "$boot_args_in" "$config_template"`"
> -# Generate kernel-version-specific boot parameters
> -boot_args="`per_version_boot_params "$boot_args" $resdir/.config $seconds`"
> -if test -n "$TORTURE_BOOT_GDB_ARG"
> -then
> -	boot_args="$boot_args $TORTURE_BOOT_GDB_ARG"
> -fi
> -
>  # Give bare-metal advice
> -modprobe_args="`echo $boot_args | tr -s ' ' '\012' | grep "^$TORTURE_MOD\." | sed -e "s/$TORTURE_MOD\.//g"`"
> -kboot_args="`echo $boot_args | tr -s ' ' '\012' | grep -v "^$TORTURE_MOD\."`"
>  testid_txt="`dirname $resdir`/testid.txt"
>  touch $resdir/bare-metal
>  echo To run this scenario on bare metal: >> $resdir/bare-metal
> diff --git a/tools/testing/selftests/rcutorture/bin/kvm.sh b/tools/testing/selftests/rcutorture/bin/kvm.sh
> index b4ac4ee33222..a05a20135de1 100755
> --- a/tools/testing/selftests/rcutorture/bin/kvm.sh
> +++ b/tools/testing/selftests/rcutorture/bin/kvm.sh
> @@ -33,6 +33,7 @@ TORTURE_ALLOTED_CPUS="`identify_qemu_vcpus`"
>  TORTURE_DEFCONFIG=defconfig
>  TORTURE_BOOT_IMAGE=""
>  TORTURE_BUILDONLY=
> +TORTURE_CMDLINE2CONFIG=
>  TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
>  TORTURE_KCONFIG_ARG=""
>  TORTURE_KCONFIG_GDB_ARG=""
> @@ -64,6 +65,7 @@ usage () {
>  	echo "       --bootargs kernel-boot-arguments"
>  	echo "       --bootimage relative-path-to-kernel-boot-image"
>  	echo "       --buildonly"
> +	echo "       --cmdline-to-config"

Does it make sense to have a way to specify that some kernel-boot
paremeters go in through CONFIG_CMDLINE and others through the qemu
-append argument?

Does it make sense to make kvm.sh unconditionally pass the kernel boot
parameters in via CONFIG_CMDLINE, thus avoiding the need for the new
--cmdline_to_config argument?  (One reason to avoid this is that it is
probably easier to hand-edit the qemu-cmd file than the bzImage file.
Though the qemu-cmd edits would override the bzImage boot parameters,
right?)

>  	echo "       --configs \"config-file list w/ repeat factor (3*TINY01)\""
>  	echo "       --cpus N"
>  	echo "       --datestamp string"
> @@ -108,6 +110,9 @@ do
>  	--buildonly|--build-only)
>  		TORTURE_BUILDONLY=1
>  		;;
> +	--cmdline-to-config)
> +		TORTURE_CMDLINE2CONFIG=1
> +		;;
>  	--configs|--config)
>  		checkarg --configs "(list of config files)" "$#" "$2" '^[^/.a-z]\+$' '^--'
>  		configs="$configs $2"
> @@ -388,6 +393,7 @@ PATH="$PATH"; export PATH
>  TORTURE_ALLOTED_CPUS="$TORTURE_ALLOTED_CPUS"; export TORTURE_ALLOTED_CPUS
>  TORTURE_BOOT_IMAGE="$TORTURE_BOOT_IMAGE"; export TORTURE_BOOT_IMAGE
>  TORTURE_BUILDONLY="$TORTURE_BUILDONLY"; export TORTURE_BUILDONLY
> +TORTURE_CMDLINE2CONFIG="$TORTURE_CMDLINE2CONFIG"; export TORTURE_CMDLINE2CONFIG
>  TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG
>  TORTURE_INITRD="$TORTURE_INITRD"; export TORTURE_INITRD
>  TORTURE_KCONFIG_ARG="$TORTURE_KCONFIG_ARG"; export TORTURE_KCONFIG_ARG
> -- 
> 2.25.1
> 

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

* Re: [PATCH 2/3] torture: Add --configonly parameter for kvm.sh
  2021-05-06 13:15 ` [PATCH 2/3] torture: Add --configonly parameter for kvm.sh Frederic Weisbecker
@ 2021-05-07 20:29   ` Paul E. McKenney
  2021-05-17 10:55     ` Frederic Weisbecker
  0 siblings, 1 reply; 10+ messages in thread
From: Paul E. McKenney @ 2021-05-07 20:29 UTC (permalink / raw)
  To: Frederic Weisbecker; +Cc: LKML

On Thu, May 06, 2021 at 03:15:09PM +0200, Frederic Weisbecker wrote:
> Those who just want the resulting config file to generate for bare metal
> don't need to wait for the build. Provide an option to only produce
> the .config file.
> 
> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>

This one looks good to me, though it depends on 1/3.

I considered asking for a check of both --configonly and --buildonly,
but on second thought I just couldn't see the point.  After all, it
does say why it stopped, either "Config-only run" or "Build-only run"
and that should suffice.

							Thanx, Paul

> ---
>  .../selftests/rcutorture/bin/kvm-build.sh     |  5 ++++
>  .../selftests/rcutorture/bin/kvm-recheck.sh   |  6 ++++-
>  .../rcutorture/bin/kvm-test-1-run.sh          | 12 ++++++++-
>  tools/testing/selftests/rcutorture/bin/kvm.sh | 26 +++++++++++++------
>  4 files changed, 39 insertions(+), 10 deletions(-)
> 
> diff --git a/tools/testing/selftests/rcutorture/bin/kvm-build.sh b/tools/testing/selftests/rcutorture/bin/kvm-build.sh
> index 9eb4324d42e1..463db5590220 100755
> --- a/tools/testing/selftests/rcutorture/bin/kvm-build.sh
> +++ b/tools/testing/selftests/rcutorture/bin/kvm-build.sh
> @@ -43,6 +43,11 @@ then
>  	exit 2
>  fi
>  
> +if test -n "$TORTURE_CONFIGONLY"
> +then
> +    exit 0
> +fi
> +
>  # Tell "make" to use double the number of real CPUs on the build system.
>  ncpus="`getconf _NPROCESSORS_ONLN`"
>  make -j$((2 * ncpus)) $TORTURE_KMAKE_ARG > $resdir/Make.out 2>&1
> diff --git a/tools/testing/selftests/rcutorture/bin/kvm-recheck.sh b/tools/testing/selftests/rcutorture/bin/kvm-recheck.sh
> index e01b31b87044..68b521b5961e 100755
> --- a/tools/testing/selftests/rcutorture/bin/kvm-recheck.sh
> +++ b/tools/testing/selftests/rcutorture/bin/kvm-recheck.sh
> @@ -57,7 +57,11 @@ do
>  				cat $i/Warnings
>  			fi
>  		else
> -			if test -f "$i/buildonly"
> +			if test -f "$i/configonly"
> +			then
> +				echo Config-only run, no build/boot/test
> +				configcheck.sh $i/.config $i/ConfigFragment
> +			elif test -f "$i/buildonly"
>  			then
>  				echo Build-only run, no boot/test
>  				configcheck.sh $i/.config $i/ConfigFragment
> 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 e6aece69d81b..6df9efc77469 100755
> --- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
> +++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
> @@ -113,11 +113,21 @@ then
>  	exit 1
>  elif kvm-build.sh $T/KcList $resdir "$kboot_args" "$modprobe_args"
>  then
> +	cp .config $resdir
> +	if test -n "$TORTURE_CONFIGONLY"
> +	then
> +		if test -f $resdir/build.wait
> +		then
> +			rm $resdir/build.wait
> +		fi
> +		echo Config-only run specified, build/boot/test omitted.
> +		touch $resdir/configonly
> +		exit 0
> +	fi
>  	# Had to build a kernel for this test.
>  	QEMU="`identify_qemu vmlinux`"
>  	BOOT_IMAGE="`identify_boot_image $QEMU`"
>  	cp vmlinux $resdir
> -	cp .config $resdir
>  	cp Module.symvers $resdir > /dev/null || :
>  	cp System.map $resdir > /dev/null || :
>  	if test -n "$BOOT_IMAGE"
> diff --git a/tools/testing/selftests/rcutorture/bin/kvm.sh b/tools/testing/selftests/rcutorture/bin/kvm.sh
> index a05a20135de1..283f5d896234 100755
> --- a/tools/testing/selftests/rcutorture/bin/kvm.sh
> +++ b/tools/testing/selftests/rcutorture/bin/kvm.sh
> @@ -34,6 +34,7 @@ TORTURE_DEFCONFIG=defconfig
>  TORTURE_BOOT_IMAGE=""
>  TORTURE_BUILDONLY=
>  TORTURE_CMDLINE2CONFIG=
> +TORTURE_CONFIGONLY=
>  TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
>  TORTURE_KCONFIG_ARG=""
>  TORTURE_KCONFIG_GDB_ARG=""
> @@ -66,6 +67,7 @@ usage () {
>  	echo "       --bootimage relative-path-to-kernel-boot-image"
>  	echo "       --buildonly"
>  	echo "       --cmdline-to-config"
> +	echo "       --configonly"
>  	echo "       --configs \"config-file list w/ repeat factor (3*TINY01)\""
>  	echo "       --cpus N"
>  	echo "       --datestamp string"
> @@ -113,6 +115,9 @@ do
>  	--cmdline-to-config)
>  		TORTURE_CMDLINE2CONFIG=1
>  		;;
> +	--configonly|--config-only)
> +		TORTURE_CONFIGONLY=1
> +		;;
>  	--configs|--config)
>  		checkarg --configs "(list of config files)" "$#" "$2" '^[^/.a-z]\+$' '^--'
>  		configs="$configs $2"
> @@ -394,6 +399,7 @@ TORTURE_ALLOTED_CPUS="$TORTURE_ALLOTED_CPUS"; export TORTURE_ALLOTED_CPUS
>  TORTURE_BOOT_IMAGE="$TORTURE_BOOT_IMAGE"; export TORTURE_BOOT_IMAGE
>  TORTURE_BUILDONLY="$TORTURE_BUILDONLY"; export TORTURE_BUILDONLY
>  TORTURE_CMDLINE2CONFIG="$TORTURE_CMDLINE2CONFIG"; export TORTURE_CMDLINE2CONFIG
> +TORTURE_CONFIGONLY="$TORTURE_CONFIGONLY"; export TORTURE_CONFIGONLY
>  TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG
>  TORTURE_INITRD="$TORTURE_INITRD"; export TORTURE_INITRD
>  TORTURE_KCONFIG_ARG="$TORTURE_KCONFIG_ARG"; export TORTURE_KCONFIG_ARG
> @@ -438,6 +444,7 @@ fi
>  ___EOF___
>  awk < $T/cfgcpu.pack \
>  	-v TORTURE_BUILDONLY="$TORTURE_BUILDONLY" \
> +	-v TORTURE_CONFIGONLY="$TORTURE_CONFIGONLY" \
>  	-v CONFIGDIR="$CONFIGFRAG/" \
>  	-v KVM="$KVM" \
>  	-v ncpus=$cpus \
> @@ -490,12 +497,14 @@ function dump(first, pastlast, batchnum)
>  		print "mkdir " rd cfr[jn] " || :";
>  		print "touch " builddir ".wait";
>  		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"
> -		print "do"
> -		print "\tsleep 1"
> -		print "done"
> -		print "echo ", cfr[jn], cpusr[jn] ovf ": Build complete. `date` | tee -a " rd "log";
> +		if (!TORTURE_CONFIGONLY) {
> +			print "echo ", cfr[jn], cpusr[jn] ovf ": Waiting for build to complete. `date` | tee -a " rd "log";
> +			print "while test -f " builddir ".wait"
> +			print "do"
> +			print "\tsleep 1"
> +			print "done"
> +			print "echo ", cfr[jn], cpusr[jn] ovf ": Build complete. `date` | tee -a " rd "log";
> +		}
>  		jn++;
>  	}
>  	print "runfiles="
> @@ -503,7 +512,7 @@ function dump(first, pastlast, batchnum)
>  		builddir=rd cfr[j] "/build";
>  		if (TORTURE_BUILDONLY)
>  			print "rm -f " builddir ".ready"
> -		else
> +		else if (!TORTURE_CONFIGONLY)
>  			print "mv " builddir ".ready " builddir ".run"
>  			print "runfiles=\"$runfiles " builddir ".run\""
>  		fi
> @@ -517,7 +526,8 @@ function dump(first, pastlast, batchnum)
>  		njitter = 0;
>  		print "echo Build-only run, so suppressing jitter | tee -a " rd "log"
>  	}
> -	if (TORTURE_BUILDONLY) {
> +
> +	if (TORTURE_BUILDONLY || TORTURE_CONFIGONLY) {
>  		print "needqemurun="
>  	}
>  	print "if test -n \"$needqemurun\""
> -- 
> 2.25.1
> 

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

* Re: [PATCH 3/3] torture: Update bare metal advices to latest kvm.sh options
  2021-05-06 13:15 ` [PATCH 3/3] torture: Update bare metal advices to latest kvm.sh options Frederic Weisbecker
@ 2021-05-07 20:37   ` Paul E. McKenney
  0 siblings, 0 replies; 10+ messages in thread
From: Paul E. McKenney @ 2021-05-07 20:37 UTC (permalink / raw)
  To: Frederic Weisbecker; +Cc: LKML

On Thu, May 06, 2021 at 03:15:10PM +0200, Frederic Weisbecker wrote:
> kvm.sh is perfectly able to build a new kernel config from an existing
> one instead of using a defconfig. All we need to do is to pass:
> 
> 	--defconfig oldconfig
> 
> This is much easier than manually modifying a .config from a
> ConfigFragment file.
> 
> Then with the latest parameters that got added on kvm.sh, it's now
> easy to build a bare metal .config for a cross target for example:
> 
> 	./kvm.sh --configs "TREE01" --defconfig oldconfig --configonly
> 		--cmdline-to-config --kmake-arg ARCH=arm64 --no-initrd
> 
> After that all we need to do is to build the updated .config and run
> the resulting image.
> 
> Update bare metal advices to propose that.
> 
> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>

I am inclined to let you take the lead on this part of the file given
that I take other approaches to bare-metal rcutorture runs.

A few comments below, mostly wordsmithing.

							Thanx, Paul

> ---
>  .../rcutorture/bin/kvm-test-1-run.sh          | 21 ++++++++++---------
>  1 file changed, 11 insertions(+), 10 deletions(-)
> 
> 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 6df9efc77469..47d69668ab37 100755
> --- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
> +++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
> @@ -190,27 +190,28 @@ echo To run this scenario on bare metal: >> $resdir/bare-metal
>  echo >> $resdir/bare-metal
>  echo " 1." Set your bare-metal build tree to the state shown in this file: >> $resdir/bare-metal
>  echo "   " $testid_txt >> $resdir/bare-metal
> -echo " 2." Update your bare-metal build tree"'"s .config based on this file: >> $resdir/bare-metal
> -echo "   " $resdir/ConfigFragment >> $resdir/bare-metal
> -echo " 3." Make the bare-metal kernel"'"s build system aware of your .config updates: >> $resdir/bare-metal
> -echo "   " $ 'yes "" | make oldconfig' >> $resdir/bare-metal
> -echo " 4." Build your bare-metal kernel. >> $resdir/bare-metal
> +echo " 2." Prepare your bare-metal build tree"'"s .config on your root kernel directory >> $resdir/bare-metal
> +echo " 3." Run this scenario with "'--defconfig oldconfig --configonly --no-initrd'" >> $resdir/bare-metal
> +echo " 4." If you"'"re cross compiling then append the appropriate make arguments >> $resdir/bare-metal

In this case, I think that "you are" is going to be nicer than the fun
with quoting quotes.  ;-)

> +echo "   " eg: "'--kmake-arg ARCH=arm64'" >> $resdir/bare-metal
>  echo " 5." Boot your bare-metal kernel with the following parameters: >> $resdir/bare-metal
>  echo "   " $kboot_args >> $resdir/bare-metal
>  echo " 6." Start the test with the following command: >> $resdir/bare-metal
>  echo "   " $ modprobe $TORTURE_MOD $modprobe_args >> $resdir/bare-metal
>  echo " 7." After some time, end the test with the following command: >> $resdir/bare-metal
>  echo "   " $ rmmod $TORTURE_MOD >> $resdir/bare-metal
> -echo " 8." Copy your bare-metal kernel"'"s .config file, overwriting this file: >> $resdir/bare-metal
> +echo " 8." Alternatively if you run rcutorture in a built-in fashion and your kernel arguments are already >> $resdir/bare-metal

"Alternatively,"

Also "if you run rcutorture built in" should work.

> +echo "   " hardcoded in the kernel config, skip the previous 5/6/7 steps and append to kvm.sh arguments: >> $resdir/bare-metal

I suggest letting them know before step 5 that they might be able to skip
step 5.  ;-)

For example, something like: "5. If you run rcutorture as a module,
do steps 6-8, otherwise skip to step 9."

> +echo "   " --cmdline-to-config >> $resdir/bare-metal
> +echo "   " Then simply boot your kernel and wait for the end of the tests >> $resdir/bare-metal
> +echo " 9." Copy your bare-metal kernel"'"s .config file, overwriting this file: >> $resdir/bare-metal
>  echo "   " $resdir/.config >> $resdir/bare-metal
> -echo " 9." Copy the console output from just before the modprobe to just after >> $resdir/bare-metal
> +echo "10." Copy the console output from just before the modprobe to just after >> $resdir/bare-metal
>  echo "   " the rmmod into this file: >> $resdir/bare-metal

But if running built-in, we need the entire console output, correct?

>  echo "   " $resdir/console.log >> $resdir/bare-metal
> -echo "10." Check for runtime errors using the following command: >> $resdir/bare-metal
> +echo "11." Check for runtime errors using the following command: >> $resdir/bare-metal
>  echo "   " $ tools/testing/selftests/rcutorture/bin/kvm-recheck.sh `dirname $resdir` >> $resdir/bare-metal
>  echo >> $resdir/bare-metal
> -echo Some of the above steps may be skipped if you build your bare-metal >> $resdir/bare-metal
> -echo kernel here: `head -n 1 $testid_txt | sed -e 's/^Build directory: //'`  >> $resdir/bare-metal
>  
>  echo $QEMU $qemu_args -m $TORTURE_QEMU_MEM -kernel $KERNEL -append \"$qemu_append $boot_args\" $TORTURE_QEMU_GDB_ARG > $resdir/qemu-cmd
>  echo "# TORTURE_SHUTDOWN_GRACE=$TORTURE_SHUTDOWN_GRACE" >> $resdir/qemu-cmd
> -- 
> 2.25.1
> 

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

* Re: [PATCH 1/3] torture: Add --cmdline-to-config parameter to kvm.sh
  2021-05-07 19:20   ` Paul E. McKenney
@ 2021-05-17 10:42     ` Frederic Weisbecker
  2021-05-17 20:40       ` Paul E. McKenney
  0 siblings, 1 reply; 10+ messages in thread
From: Frederic Weisbecker @ 2021-05-17 10:42 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: LKML

On Fri, May 07, 2021 at 12:20:09PM -0700, Paul E. McKenney wrote:
> On Thu, May 06, 2021 at 03:15:08PM +0200, Frederic Weisbecker wrote:
> > While running rcutorture on bare metal, an easy way to test is to build
> > a kernel with the torture scenario parameters built-in using
> > CONFIG_CMDLINE="". This way the remote box can simply download the image
> > and the boot loader doesn't need to be updated with the new kernel
> > parameters.
> 
> I had no idea about CONFIG_CMDLINE!  Thank you for introducing me to it!
> 
> > Provide kvm.sh with --cmdline-to-config to perform that.
> 
> If I understand correctly, kernel-boot parameters are processed after
> the CONFIG_CMDLINE parameters.  If so, would it make sense (probably
> as a separate patch) for the current --bootargs kernel parameters to be
> supplied to CONFIG_CMDLINE in kvm.sh, and to add a --bootargs parameter
> to kvm-again.sh which caused additional kernel-boot parameters to be
> added to the end of the "-append" list in the qemu-cmd file?
> 
> As in, "Re-run this rcutorture run, but with rcutorture.onoff_interval=0
> so as to disable CPU-hotplug operations"?

Sure that looks possible.

> > diff --git a/tools/testing/selftests/rcutorture/bin/configinit.sh b/tools/testing/selftests/rcutorture/bin/configinit.sh
> > index d6e5ce084b1c..d2b8a68114e4 100755
> > --- a/tools/testing/selftests/rcutorture/bin/configinit.sh
> > +++ b/tools/testing/selftests/rcutorture/bin/configinit.sh
> > @@ -23,6 +23,8 @@ mkdir $T
> >  
> >  c=$1
> >  resdir=$2
> > +kboot_args=$3
> > +modprobe_args=$4
> >  
> >  sed -e 's/^\(CONFIG[0-9A-Z_]*\)=.*$/grep -v "^# \1" |/' < $c > $T/u.sh
> >  sed -e 's/^\(CONFIG[0-9A-Z_]*=\).*$/grep -v \1 |/' < $c >> $T/u.sh
> > @@ -35,6 +37,17 @@ fi
> >  make $TORTURE_KMAKE_ARG $TORTURE_DEFCONFIG > $resdir/Make.defconfig.out 2>&1
> >  mv .config .config.sav
> >  sh $T/upd.sh < .config.sav > .config
> > +
> > +if test -n "$TORTURE_CMDLINE2CONFIG"
> > +then
> > +	cmdline=$(grep "CONFIG_CMDLINE=" .config | sed -E 's/CONFIG_CMDLINE="(.*)"/\1/')
> > +	prefixed_modprobe_args=$(echo $modprobe_args | sed -E -e "s/([^ ]+?)(=[^ ]*)?/rcutorture.\1\2/g")
> 
> Doesn't this need to check for locktorture, refscale, rcuscale, and
> scftorture as well as for rcutorture?  Maybe use the TORTURE_MOD
> environment variable similar to the way you do in your change to
> kvm-test-1-run.sh.

Ah! Right I missed all that. Ok I'll need to handle all those other modules.

> 
> > +	cmdline="$kboot_args $prefixed_modprobe_args $cmdline"
> 
> This makes a "--kconfig CONFIG_CMDLINE=whatever" override the --bootargs
> parameters.  Is that what we want?  Either way, why?

I guess it's up to the user not to try dangerous mixes. But we could forbid
--kconfig CONFIG_CMDLINE= for example.

> You could ask the same question about the current ordering of kernel
> boot parameters from their various sources, and it would be good to do so.

Heh.

> > +seconds=$3
> > +qemu_args=$4
> > +boot_args_in=$5
> > +
> > +# Pull in Kconfig-fragment boot parameters
> > +boot_args="`configfrag_boot_params "$boot_args_in" "$config_template"`"
> > +# Generate kernel-version-specific boot parameters
> > +boot_args="`per_version_boot_params "$boot_args" $resdir/.config $seconds`"
> > +
> > +if test -n "$TORTURE_BOOT_GDB_ARG"
> > +then
> > +	boot_args="$boot_args $TORTURE_BOOT_GDB_ARG"
> > +fi
> > +
> > +modprobe_args="`echo $boot_args | tr -s ' ' '\012' | grep "^$TORTURE_MOD\." | sed -e "s/$TORTURE_MOD\.//g"`"
> > +kboot_args="`echo $boot_args | tr -s ' ' '\012' | grep -v "^$TORTURE_MOD\."`"
> > +
> 
> We are in trouble if a kernel boot parameter contains a space character,
> but we probably are already in trouble, so no problem.  ;-)

:o)

> 
> But don't we want to avoid adding these to the qemu -append argument
> if they are already in CONFIG_CMDLINE?  Or is there some benefit to
> duplicating them?

Indeed I only used it with --configonly so far so I didn't bother checking.
But you're right, I should avoid passing these twice.

> > diff --git a/tools/testing/selftests/rcutorture/bin/kvm.sh b/tools/testing/selftests/rcutorture/bin/kvm.sh
> > index b4ac4ee33222..a05a20135de1 100755
> > --- a/tools/testing/selftests/rcutorture/bin/kvm.sh
> > +++ b/tools/testing/selftests/rcutorture/bin/kvm.sh
> > @@ -33,6 +33,7 @@ TORTURE_ALLOTED_CPUS="`identify_qemu_vcpus`"
> >  TORTURE_DEFCONFIG=defconfig
> >  TORTURE_BOOT_IMAGE=""
> >  TORTURE_BUILDONLY=
> > +TORTURE_CMDLINE2CONFIG=
> >  TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
> >  TORTURE_KCONFIG_ARG=""
> >  TORTURE_KCONFIG_GDB_ARG=""
> > @@ -64,6 +65,7 @@ usage () {
> >  	echo "       --bootargs kernel-boot-arguments"
> >  	echo "       --bootimage relative-path-to-kernel-boot-image"
> >  	echo "       --buildonly"
> > +	echo "       --cmdline-to-config"
> 
> Does it make sense to have a way to specify that some kernel-boot
> paremeters go in through CONFIG_CMDLINE and others through the qemu
> -append argument?
> 
> Does it make sense to make kvm.sh unconditionally pass the kernel boot
> parameters in via CONFIG_CMDLINE, thus avoiding the need for the new
> --cmdline_to_config argument?  (One reason to avoid this is that it is
> probably easier to hand-edit the qemu-cmd file than the bzImage file.
> Though the qemu-cmd edits would override the bzImage boot parameters,
> right?)

I guess it depends if you ever plan to be able to re-launch qemu with different
parameters without rebuilding the bzImage. Perhaps it's even something that can
be done currently?

Thanks!

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

* Re: [PATCH 2/3] torture: Add --configonly parameter for kvm.sh
  2021-05-07 20:29   ` Paul E. McKenney
@ 2021-05-17 10:55     ` Frederic Weisbecker
  0 siblings, 0 replies; 10+ messages in thread
From: Frederic Weisbecker @ 2021-05-17 10:55 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: LKML

On Fri, May 07, 2021 at 01:29:10PM -0700, Paul E. McKenney wrote:
> On Thu, May 06, 2021 at 03:15:09PM +0200, Frederic Weisbecker wrote:
> > Those who just want the resulting config file to generate for bare metal
> > don't need to wait for the build. Provide an option to only produce
> > the .config file.
> > 
> > Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> 
> This one looks good to me, though it depends on 1/3.
> 
> I considered asking for a check of both --configonly and --buildonly,
> but on second thought I just couldn't see the point.  After all, it
> does say why it stopped, either "Config-only run" or "Build-only run"
> and that should suffice.

Ok, I'll resend this one as standalone then so we can think more clearly
on the rest.

Thanks!

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

* Re: [PATCH 1/3] torture: Add --cmdline-to-config parameter to kvm.sh
  2021-05-17 10:42     ` Frederic Weisbecker
@ 2021-05-17 20:40       ` Paul E. McKenney
  0 siblings, 0 replies; 10+ messages in thread
From: Paul E. McKenney @ 2021-05-17 20:40 UTC (permalink / raw)
  To: Frederic Weisbecker; +Cc: LKML

On Mon, May 17, 2021 at 12:42:36PM +0200, Frederic Weisbecker wrote:
> On Fri, May 07, 2021 at 12:20:09PM -0700, Paul E. McKenney wrote:
> > On Thu, May 06, 2021 at 03:15:08PM +0200, Frederic Weisbecker wrote:
> > > While running rcutorture on bare metal, an easy way to test is to build
> > > a kernel with the torture scenario parameters built-in using
> > > CONFIG_CMDLINE="". This way the remote box can simply download the image
> > > and the boot loader doesn't need to be updated with the new kernel
> > > parameters.
> > 
> > I had no idea about CONFIG_CMDLINE!  Thank you for introducing me to it!
> > 
> > > Provide kvm.sh with --cmdline-to-config to perform that.
> > 
> > If I understand correctly, kernel-boot parameters are processed after
> > the CONFIG_CMDLINE parameters.  If so, would it make sense (probably
> > as a separate patch) for the current --bootargs kernel parameters to be
> > supplied to CONFIG_CMDLINE in kvm.sh, and to add a --bootargs parameter
> > to kvm-again.sh which caused additional kernel-boot parameters to be
> > added to the end of the "-append" list in the qemu-cmd file?
> > 
> > As in, "Re-run this rcutorture run, but with rcutorture.onoff_interval=0
> > so as to disable CPU-hotplug operations"?
> 
> Sure that looks possible.
> 
> > > diff --git a/tools/testing/selftests/rcutorture/bin/configinit.sh b/tools/testing/selftests/rcutorture/bin/configinit.sh
> > > index d6e5ce084b1c..d2b8a68114e4 100755
> > > --- a/tools/testing/selftests/rcutorture/bin/configinit.sh
> > > +++ b/tools/testing/selftests/rcutorture/bin/configinit.sh
> > > @@ -23,6 +23,8 @@ mkdir $T
> > >  
> > >  c=$1
> > >  resdir=$2
> > > +kboot_args=$3
> > > +modprobe_args=$4
> > >  
> > >  sed -e 's/^\(CONFIG[0-9A-Z_]*\)=.*$/grep -v "^# \1" |/' < $c > $T/u.sh
> > >  sed -e 's/^\(CONFIG[0-9A-Z_]*=\).*$/grep -v \1 |/' < $c >> $T/u.sh
> > > @@ -35,6 +37,17 @@ fi
> > >  make $TORTURE_KMAKE_ARG $TORTURE_DEFCONFIG > $resdir/Make.defconfig.out 2>&1
> > >  mv .config .config.sav
> > >  sh $T/upd.sh < .config.sav > .config
> > > +
> > > +if test -n "$TORTURE_CMDLINE2CONFIG"
> > > +then
> > > +	cmdline=$(grep "CONFIG_CMDLINE=" .config | sed -E 's/CONFIG_CMDLINE="(.*)"/\1/')
> > > +	prefixed_modprobe_args=$(echo $modprobe_args | sed -E -e "s/([^ ]+?)(=[^ ]*)?/rcutorture.\1\2/g")
> > 
> > Doesn't this need to check for locktorture, refscale, rcuscale, and
> > scftorture as well as for rcutorture?  Maybe use the TORTURE_MOD
> > environment variable similar to the way you do in your change to
> > kvm-test-1-run.sh.
> 
> Ah! Right I missed all that. Ok I'll need to handle all those other modules.
> 
> > > +	cmdline="$kboot_args $prefixed_modprobe_args $cmdline"
> > 
> > This makes a "--kconfig CONFIG_CMDLINE=whatever" override the --bootargs
> > parameters.  Is that what we want?  Either way, why?
> 
> I guess it's up to the user not to try dangerous mixes. But we could forbid
> --kconfig CONFIG_CMDLINE= for example.
> 
> > You could ask the same question about the current ordering of kernel
> > boot parameters from their various sources, and it would be good to do so.
> 
> Heh.
> 
> > > +seconds=$3
> > > +qemu_args=$4
> > > +boot_args_in=$5
> > > +
> > > +# Pull in Kconfig-fragment boot parameters
> > > +boot_args="`configfrag_boot_params "$boot_args_in" "$config_template"`"
> > > +# Generate kernel-version-specific boot parameters
> > > +boot_args="`per_version_boot_params "$boot_args" $resdir/.config $seconds`"
> > > +
> > > +if test -n "$TORTURE_BOOT_GDB_ARG"
> > > +then
> > > +	boot_args="$boot_args $TORTURE_BOOT_GDB_ARG"
> > > +fi
> > > +
> > > +modprobe_args="`echo $boot_args | tr -s ' ' '\012' | grep "^$TORTURE_MOD\." | sed -e "s/$TORTURE_MOD\.//g"`"
> > > +kboot_args="`echo $boot_args | tr -s ' ' '\012' | grep -v "^$TORTURE_MOD\."`"
> > > +
> > 
> > We are in trouble if a kernel boot parameter contains a space character,
> > but we probably are already in trouble, so no problem.  ;-)
> 
> :o)
> 
> > But don't we want to avoid adding these to the qemu -append argument
> > if they are already in CONFIG_CMDLINE?  Or is there some benefit to
> > duplicating them?
> 
> Indeed I only used it with --configonly so far so I didn't bother checking.
> But you're right, I should avoid passing these twice.
> 
> > > diff --git a/tools/testing/selftests/rcutorture/bin/kvm.sh b/tools/testing/selftests/rcutorture/bin/kvm.sh
> > > index b4ac4ee33222..a05a20135de1 100755
> > > --- a/tools/testing/selftests/rcutorture/bin/kvm.sh
> > > +++ b/tools/testing/selftests/rcutorture/bin/kvm.sh
> > > @@ -33,6 +33,7 @@ TORTURE_ALLOTED_CPUS="`identify_qemu_vcpus`"
> > >  TORTURE_DEFCONFIG=defconfig
> > >  TORTURE_BOOT_IMAGE=""
> > >  TORTURE_BUILDONLY=
> > > +TORTURE_CMDLINE2CONFIG=
> > >  TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
> > >  TORTURE_KCONFIG_ARG=""
> > >  TORTURE_KCONFIG_GDB_ARG=""
> > > @@ -64,6 +65,7 @@ usage () {
> > >  	echo "       --bootargs kernel-boot-arguments"
> > >  	echo "       --bootimage relative-path-to-kernel-boot-image"
> > >  	echo "       --buildonly"
> > > +	echo "       --cmdline-to-config"
> > 
> > Does it make sense to have a way to specify that some kernel-boot
> > paremeters go in through CONFIG_CMDLINE and others through the qemu
> > -append argument?
> > 
> > Does it make sense to make kvm.sh unconditionally pass the kernel boot
> > parameters in via CONFIG_CMDLINE, thus avoiding the need for the new
> > --cmdline_to_config argument?  (One reason to avoid this is that it is
> > probably easier to hand-edit the qemu-cmd file than the bzImage file.
> > Though the qemu-cmd edits would override the bzImage boot parameters,
> > right?)
> 
> I guess it depends if you ever plan to be able to re-launch qemu with different
> parameters without rebuilding the bzImage. Perhaps it's even something that can
> be done currently?

One thing that has been on my list (though not the official todo list for
whatever reason) has been to create a clear precedence among the various
sources of kernel boot parameters.  Such a precedence exists (with a few
exceptions) for Kconfig options, so that a --kconfig argument overrides
the contents of the scenario file (e.g., TREE05) which overrides the
contents of the CFcommon file.

And yes, it would be nice to change boot parameters without needing to
rebuild the kernel, but it can be a bit tricky.

							Thanx, Paul

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

end of thread, other threads:[~2021-05-17 20:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06 13:15 [PATCH 0/3] torture: Update bare metal config generation Frederic Weisbecker
2021-05-06 13:15 ` [PATCH 1/3] torture: Add --cmdline-to-config parameter to kvm.sh Frederic Weisbecker
2021-05-07 19:20   ` Paul E. McKenney
2021-05-17 10:42     ` Frederic Weisbecker
2021-05-17 20:40       ` Paul E. McKenney
2021-05-06 13:15 ` [PATCH 2/3] torture: Add --configonly parameter for kvm.sh Frederic Weisbecker
2021-05-07 20:29   ` Paul E. McKenney
2021-05-17 10:55     ` Frederic Weisbecker
2021-05-06 13:15 ` [PATCH 3/3] torture: Update bare metal advices to latest kvm.sh options Frederic Weisbecker
2021-05-07 20:37   ` Paul E. McKenney

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.