Skip to contentSkip to conversation

Torture-test changes for 3.16

PATCH In review Paul E. McKenney 2 participants 106 messages Apr 29, 2014 – May 13, 2014

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover Torture-test changes for 3.16

Hello!

This series provides torture-test updates:

1. Add forward-progress checking to distinguish between stalls in
the RCU implementation and in the torture test itself.

2. Remove the --builddir and --relbuilddir options, which have been
obsoleted by the parallel testing facility.

3. Make "--dryrun sched" output more readable by clearly indicating
where each batch of concurrent runs starts.

4. Make torture-test errors less RCU-specific. ("Hey, why did
my locktorture run complain about RCU???")

5,8-14. Rename variables to reflect the new RCU-independence of a number
of the torture-test scripts.

6. Reduce locktorture sleeping to increase intensity.

7. Add a --defconfig argument to allow other default configs to
be specified.

15. Make config-fragment filtering RCU-independent.

16. Mark private functions as static in kernel/rcu/torture.c,
courtesy of Rashika Kheria.

17-18. Make the output of "--dryrun script" independently runnable.

19. Print negative numbers when SRCU counters wrap instead of
huge 64-bit integers.

20. Fix "Stopping" torture messages.

21. Report any diagnostics issued by qemu.

22. Make kthreads spin during the last jiffy of a stutter period
to increase the intensity of torture stop-start events.

23. Permit multiple qemu and boot arguments to be specified on
the command line.

24. Choose bzImage location based on architecture.

25. Add tracing-enabled variant of TREE02 to aid debugging.

26. Dump the ftrace buffer when the RCU grace period stalls.

27. Export the RCU grace-period kthread wait state to rcutorture
to ease diagnosis of RCU grace-period stalls.

28. Fix bug in raw_cpu_inc_return().

29. Make cond_resched() report RCU quiescent states.

30. Make rcu_torture_reader() use cond_resched() instead of
unconditionally invoking schedule().

31. Complain if an all-zero cpumask is specified during a torture
shuffle operation, courtesy of Iulia Manda.

32. Make build failures more evident.

33. Capture and report the torture_create_kthread() return value when
creating the rcu_torture_fqs kthread.

34. Use elapsed time to detect hangs rather than counting "sleep 1"
commands.

35. Rearrange config fragments to ensure that RCU-sched primitives are
tested in TREE_PREEMPT_RCU kernels.

36. Add rcutorture tests for get_state_synchronize_rcu() and
cond_synchronize_rcu().

37. Add explicit tests for synchronous grace-period primitives.

38. Add missing destroy_timer_on_stack(), courtesy of Thomas Gleixner.

39. Make scripts record "git diff HEAD" to ease reproduction of
an unexpected torture-test result.

40. Run rcu_torture_writer() at normal priority.

41. Put the qemu process into the background to better handle
kernel hangs.

42. Remove reference to a non-existent Kconfig parameter.

43. Refuse to run multiple concurrent torture tests.

44. Remove __init from torture_init_begin() and torture_init_end()
to allow rcutorture to once again work as a loadable module.

45. Remove unused torture_parm() macro.

Thanx, Paul

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

 b/include/linux/percpu.h                                     |    2 
 b/include/linux/rcupdate.h                                   |   19 +
 b/include/linux/rcutiny.h                                    |    4 
 b/include/linux/rcutree.h                                    |    1 
 b/include/linux/torture.h                                    |    2 
 b/kernel/locking/locktorture.c                               |    3 
 b/kernel/rcu/rcutorture.c                                    |   37 ++
 b/kernel/rcu/tree.c                                          |   18 +
 b/kernel/rcu/tree.h                                          |    8 
 b/kernel/rcu/update.c                                        |   18 +
 b/kernel/sched/core.c                                        |    7 
 b/kernel/torture.c                                           |    5 
 b/tools/testing/selftests/rcutorture/bin/configinit.sh       |    2 
 b/tools/testing/selftests/rcutorture/bin/functions.sh        |   12 
 b/tools/testing/selftests/rcutorture/bin/kvm-build.sh        |    2 
 b/tools/testing/selftests/rcutorture/bin/kvm-recheck-lock.sh |    2 
 b/tools/testing/selftests/rcutorture/bin/kvm-recheck-rcu.sh  |    2 
 b/tools/testing/selftests/rcutorture/bin/kvm-recheck.sh      |    2 
 b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh   |    2 
 b/tools/testing/selftests/rcutorture/bin/kvm.sh              |   16 
 b/tools/testing/selftests/rcutorture/bin/parse-torture.sh    |  106 ++++++
 b/tools/testing/selftests/rcutorture/configs/rcu/TREE02-T    |   25 +
 b/tools/testing/selftests/rcutorture/configs/rcu/TREE08.boot |    1 
 include/linux/rcupdate.h                                     |   36 ++
 include/linux/torture.h                                      |    6 
 kernel/locking/locktorture.c                                 |    7 
 kernel/rcu/rcutorture.c                                      |  193 +++++++----
 kernel/rcu/tree.c                                            |   17 
 kernel/torture.c                                             |   36 +-
 tools/testing/selftests/rcutorture/bin/functions.sh          |   35 +
 tools/testing/selftests/rcutorture/bin/kvm-build.sh          |    4 
 tools/testing/selftests/rcutorture/bin/kvm-recheck.sh        |   24 +
 tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh     |   44 +-
 tools/testing/selftests/rcutorture/bin/kvm.sh                |  162 +++++----
 tools/testing/selftests/rcutorture/bin/parse-rcutorture.sh   |  106 ------
 35 files changed, 649 insertions(+), 317 deletions(-)
#3 lore raw

PATCH 3/45 torture: Add batch headers "--dryrun sched"

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit makes the output of "--dryrun sched" more user-friendly, clearly indicating the batch starts.

---
 tools/testing/selftests/rcutorture/bin/kvm.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/kvm.sh +2 -1
index 37a60ef70df3..740676255c6a 100644
@@ -379,7 +379,8 @@ then
 elif test "$dryrun" = sched
 then
 	# Extract the test run schedule from the script.
-	egrep 'start batch|Starting build\.' $T/script |
+	egrep 'Start batch|Starting build\.' $T/script |
+		grep -v ">>" |
 		sed -e 's/:.*$//' -e 's/^echo //'
 	exit 0
 else
Signature · 1 line
1.8.1.5
#67 lore raw

PATCH 32/45 torture: Better summary diagnostics for build failures

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The reaction of kvm-recheck.sh is obscure at best, and easy to miss completely. This commit therefore prints "BUG: Build failed" in the summary at the end of a run.

---
 .../selftests/rcutorture/bin/kvm-recheck-lock.sh   |  2 +-
 .../selftests/rcutorture/bin/kvm-recheck-rcu.sh    |  2 +-
 .../selftests/rcutorture/bin/kvm-recheck.sh        | 24 ++++++++++++++++------
 .../selftests/rcutorture/bin/kvm-test-1-run.sh     |  1 +
 4 files changed, 21 insertions(+), 8 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-recheck-lock.sh +1 -1
index 829186e19eb1..7f1ff1a8fc4b 100755
@@ -35,7 +35,7 @@ configfile=`echo $i | sed -e 's/^.*\///'`
 ncs=`grep "Writes:  Total:" $i/console.log 2> /dev/null | tail -1 | sed -e 's/^.* Total: //' -e 's/ .*$//'`
 if test -z "$ncs"
 then
-	echo $configfile
+	echo "$configfile -------"
 else
 	title="$configfile ------- $ncs acquisitions/releases"
 	dur=`sed -e 's/^.* locktorture.shutdown_secs=//' -e 's/ .*$//' < $i/qemu-cmd 2> /dev/null`
tools/testing/selftests/rcutorture/bin/kvm-recheck-rcu.sh +1 -1
index d75b1dc5ae53..307c4b95f325 100755
@@ -35,7 +35,7 @@ configfile=`echo $i | sed -e 's/^.*\///'`
 ngps=`grep ver: $i/console.log 2> /dev/null | tail -1 | sed -e 's/^.* ver: //' -e 's/ .*$//'`
 if test -z "$ngps"
 then
-	echo $configfile
+	echo "$configfile -------"
 else
 	title="$configfile ------- $ngps grace periods"
 	dur=`sed -e 's/^.* rcutorture.shutdown_secs=//' -e 's/ .*$//' < $i/qemu-cmd 2> /dev/null`
tools/testing/selftests/rcutorture/bin/kvm-recheck.sh +18 -6
index 26d78b7eaccf..ee1f6cae3d70 100755
@@ -25,6 +25,7 @@
 # Authors: Paul E. McKenney <[email protected]>
 
 PATH=`pwd`/tools/testing/selftests/rcutorture/bin:$PATH; export PATH
+. tools/testing/selftests/rcutorture/bin/functions.sh
 for rd in "$@"
 do
 	firsttime=1
@@ -39,13 +40,24 @@ do
 		fi
 		TORTURE_SUITE="`cat $i/../TORTURE_SUITE`"
 		kvm-recheck-${TORTURE_SUITE}.sh $i
-		configcheck.sh $i/.config $i/ConfigFragment
-		parse-build.sh $i/Make.out $configfile
-		parse-torture.sh $i/console.log $configfile
-		parse-console.sh $i/console.log $configfile
-		if test -r $i/Warnings
+		if test -f "$i/console.log"
 		then
-			cat $i/Warnings
+			configcheck.sh $i/.config $i/ConfigFragment
+			parse-build.sh $i/Make.out $configfile
+			parse-torture.sh $i/console.log $configfile
+			parse-console.sh $i/console.log $configfile
+			if test -r $i/Warnings
+			then
+				cat $i/Warnings
+			fi
+		else
+			if test -f "$i/qemu-cmd"
+			then
+				print_bug qemu failed
+			else
+				print_bug Build failed
+			fi
+			echo "   $i"
 		fi
 	done
 done
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +1 -0
index 7a95f86cc85a..51c34a91a375 100755
@@ -106,6 +106,7 @@ then
 	fi
 else
 	cp $builddir/Make*.out $resdir
+	cp $builddir/.config $resdir || :
 	echo Build failed, not running KVM, see $resdir.
 	if test -f $builddir.wait
 	then
Signature · 1 line
1.8.1.5
#31 lore raw

PATCH 14/45 torture: Rename RCU_QEMU_CMD to TORTURE_QEMU_CMD

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit makes the torture scripts a bit more RCU-independent.

---
 tools/testing/selftests/rcutorture/bin/functions.sh | 8 ++++----
 tools/testing/selftests/rcutorture/bin/kvm.sh       | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)
tools/testing/selftests/rcutorture/bin/functions.sh +4 -4
index 41fb52b805e4..6b2adb29b073 100644
@@ -79,12 +79,12 @@ configfrag_hotplug_cpu () {
 # identify_qemu builddir
 #
 # Returns our best guess as to which qemu command is appropriate for
-# the kernel at hand.  Override with the RCU_QEMU_CMD environment variable.
+# the kernel at hand.  Override with the TORTURE_QEMU_CMD environment variable.
 identify_qemu () {
 	local u="`file "$1"`"
-	if test -n "$RCU_QEMU_CMD"
+	if test -n "$TORTURE_QEMU_CMD"
 	then
-		echo $RCU_QEMU_CMD
+		echo $TORTURE_QEMU_CMD
 	elif echo $u | grep -q x86-64
 	then
 		echo qemu-system-x86_64
@@ -98,7 +98,7 @@ identify_qemu () {
 		echo Cannot figure out what qemu command to use! 1>&2
 		echo file $1 output: $u
 		# Usually this will be one of /usr/bin/qemu-system-*
-		# Use RCU_QEMU_CMD environment variable or appropriate
+		# Use TORTURE_QEMU_CMD environment variable or appropriate
 		# argument to top-level script.
 		exit 1
 	fi
tools/testing/selftests/rcutorture/bin/kvm.sh +2 -2
index d397ecc55293..ea59e2950f14 100644
@@ -141,7 +141,7 @@ do
 		;;
 	--qemu-cmd)
 		checkarg --qemu-cmd "(qemu-system-...)" $# "$2" 'qemu-system-' '^--'
-		RCU_QEMU_CMD="$2"; export RCU_QEMU_CMD
+		TORTURE_QEMU_CMD="$2"; export TORTURE_QEMU_CMD
 		shift
 		;;
 	--results)
@@ -377,7 +377,7 @@ then
 	echo TORTURE_BUILDONLY="$TORTURE_BUILDONLY; export TORTURE_BUILDONLY"
 	echo TORTURE_INITRD="$TORTURE_INITRD; export TORTURE_INITRD"
 	echo TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG; export TORTURE_KMAKE_ARG"
-	echo RCU_QEMU_CMD="$RCU_QEMU_CMD; export RCU_QEMU_CMD"
+	echo TORTURE_QEMU_CMD="$TORTURE_QEMU_CMD; export TORTURE_QEMU_CMD"
 	echo TORTURE_QEMU_INTERACTIVE="$TORTURE_QEMU_INTERACTIVE;
 		export TORTURE_QEMU_INTERACTIVE"
 	echo TORTURE_QEMU_MAC="$TORTURE_QEMU_MAC; export TORTURE_QEMU_MAC"
Signature · 1 line
1.8.1.5
#58 lore raw

PATCH 25/45 torture: Add tracing-enabled variant of TREE02

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit adds a CONFIG_RCU_TRACE=y version of TREE02 for debugging purposes.

---
 .../selftests/rcutorture/configs/rcu/TREE02-T      | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 tools/testing/selftests/rcutorture/configs/rcu/TREE02-T
tools/testing/selftests/rcutorture/configs/rcu/TREE02-T new file +25 -0
new file mode 100644
index 000000000000..61c8d9ce5bb2
@@ -0,0 +1,25 @@
+CONFIG_SMP=y
+CONFIG_NR_CPUS=8
+CONFIG_PREEMPT_NONE=n
+CONFIG_PREEMPT_VOLUNTARY=n
+CONFIG_PREEMPT=y
+#CHECK#CONFIG_TREE_PREEMPT_RCU=y
+CONFIG_HZ_PERIODIC=n
+CONFIG_NO_HZ_IDLE=y
+CONFIG_NO_HZ_FULL=n
+CONFIG_RCU_FAST_NO_HZ=n
+CONFIG_RCU_TRACE=y
+CONFIG_HOTPLUG_CPU=n
+CONFIG_SUSPEND=n
+CONFIG_HIBERNATION=n
+CONFIG_RCU_FANOUT=3
+CONFIG_RCU_FANOUT_LEAF=3
+CONFIG_RCU_FANOUT_EXACT=n
+CONFIG_RCU_NOCB_CPU=n
+CONFIG_DEBUG_LOCK_ALLOC=y
+CONFIG_PROVE_LOCKING=n
+CONFIG_PROVE_RCU_DELAY=n
+CONFIG_RCU_CPU_STALL_INFO=n
+CONFIG_RCU_CPU_STALL_VERBOSE=y
+CONFIG_RCU_BOOST=n
+CONFIG_DEBUG_OBJECTS_RCU_HEAD=n
Signature · 1 line
1.8.1.5
#53 lore raw

PATCH 22/45 torture: Increase stutter-end intensity

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Currently, all stuttered kthreads block a jiffy at a time, which can result in them starting at different times. (Note: This is not an energy-efficiency problem unless you run torture tests in production, in which case you have other problems!) This commit increases the intensity of the restart event by causing kthreads to spin through the last jiffy, restarting when they see the variable change.

---
 kernel/torture.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
kernel/torture.c +10 -2
index f329848c3eee..bd768effba9a 100644
@@ -533,7 +533,11 @@ void stutter_wait(const char *title)
 	while (ACCESS_ONCE(stutter_pause_test) ||
 	       (torture_runnable && !ACCESS_ONCE(*torture_runnable))) {
 		if (stutter_pause_test)
-			schedule_timeout_interruptible(1);
+			if (ACCESS_ONCE(stutter_pause_test) == 1)
+				schedule_timeout_interruptible(1);
+			else
+				while (ACCESS_ONCE(stutter_pause_test))
+					cond_resched();
 		else
 			schedule_timeout_interruptible(round_jiffies_relative(HZ));
 		torture_shutdown_absorb(title);
@@ -550,7 +554,11 @@ static int torture_stutter(void *arg)
 	VERBOSE_TOROUT_STRING("torture_stutter task started");
 	do {
 		if (!torture_must_stop()) {
-			schedule_timeout_interruptible(stutter);
+			if (stutter > 1) {
+				schedule_timeout_interruptible(stutter - 1);
+				ACCESS_ONCE(stutter_pause_test) = 2;
+			}
+			schedule_timeout_interruptible(1);
 			ACCESS_ONCE(stutter_pause_test) = 1;
 		}
 		if (!torture_must_stop())
Signature · 1 line
1.8.1.5
#15 lore raw

PATCH 8/45 torture: Rename RCU_KMAKE_ARG to TORTURE_KMAKE_ARG

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit makes the torture scripts a bit more RCU-independent.

---
 tools/testing/selftests/rcutorture/bin/kvm-build.sh | 2 +-
 tools/testing/selftests/rcutorture/bin/kvm.sh       | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-build.sh +1 -1
index d8e68a5e4411..e838c775f709 100755
@@ -60,7 +60,7 @@ then
 	exit 2
 fi
 ncpus=`cpus2use.sh`
-make O=$builddir -j$ncpus $RCU_KMAKE_ARG > $builddir/Make.out 2>&1
+make O=$builddir -j$ncpus $TORTURE_KMAKE_ARG > $builddir/Make.out 2>&1
 retval=$?
 if test $retval -ne 0 || grep "rcu[^/]*": < $builddir/Make.out | egrep -q "Stop|Error|error:|warning:" || egrep -q "Stop|Error|error:" < $builddir/Make.out
 then
tools/testing/selftests/rcutorture/bin/kvm.sh +3 -3
index 59945b7793d9..04ad1f980dfe 100644
@@ -40,7 +40,7 @@ KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
 PATH=${KVM}/bin:$PATH; export PATH
 TORTURE_DEFCONFIG=defconfig
 TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
-RCU_KMAKE_ARG=""; export RCU_KMAKE_ARG
+TORTURE_KMAKE_ARG=""
 TORTURE_SUITE=rcu
 resdir=""
 configs=""
@@ -118,7 +118,7 @@ do
 		;;
 	--kmake-arg)
 		checkarg --kmake-arg "(kernel make arguments)" $# "$2" '.*' '^error$'
-		RCU_KMAKE_ARG="$2"; export RCU_KMAKE_ARG
+		TORTURE_KMAKE_ARG="$2"
 		shift
 		;;
 	--kversion)
@@ -376,7 +376,7 @@ then
 	echo PATH="$PATH; export PATH"
 	echo RCU_BUILDONLY="$RCU_BUILDONLY; export RCU_BUILDONLY"
 	echo TORTURE_INITRD="$TORTURE_INITRD; export TORTURE_INITRD"
-	echo RCU_KMAKE_ARG="$RCU_KMAKE_ARG; export RCU_KMAKE_ARG"
+	echo TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG; export TORTURE_KMAKE_ARG"
 	echo RCU_QEMU_CMD="$RCU_QEMU_CMD; export RCU_QEMU_CMD"
 	echo RCU_QEMU_INTERACTIVE="$RCU_QEMU_INTERACTIVE; export RCU_QEMU_INTERACTIVE"
 	echo RCU_QEMU_MAC="$RCU_QEMU_MAC; export RCU_QEMU_MAC"
Signature · 1 line
1.8.1.5
#9 lore raw

PATCH 7/45 torture: Allow variations of "defconfig" to be specified

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Some environments require some variation on "make defconfig" to initialize the .config file. This commit therefore adds a --defconfig argument to allow this to be specified. The default value is of course "defconfig".

---
 tools/testing/selftests/rcutorture/bin/configinit.sh | 2 +-
 tools/testing/selftests/rcutorture/bin/kvm.sh        | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/configinit.sh +1 -1
index a1be6e62add1..9c3f3d39b934 100755
@@ -62,7 +62,7 @@ grep '^grep' < $T/u.sh > $T/upd.sh
 echo "cat - $c" >> $T/upd.sh
 make mrproper
 make $buildloc distclean > $builddir/Make.distclean 2>&1
-make $buildloc defconfig > $builddir/Make.defconfig.out 2>&1
+make $buildloc $TORTURE_DEFCONFIG > $builddir/Make.defconfig.out 2>&1
 mv $builddir/.config $builddir/.config.sav
 sh $T/upd.sh < $builddir/.config.sav > $builddir/.config
 cp $builddir/.config $builddir/.config.new
tools/testing/selftests/rcutorture/bin/kvm.sh +8 -0
index a52a077ee258..59945b7793d9 100644
@@ -38,6 +38,7 @@ dur=30
 dryrun=""
 KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
 PATH=${KVM}/bin:$PATH; export PATH
+TORTURE_DEFCONFIG=defconfig
 TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
 RCU_KMAKE_ARG=""; export RCU_KMAKE_ARG
 TORTURE_SUITE=rcu
@@ -56,6 +57,7 @@ usage () {
 	echo "       --configs \"config-file list\""
 	echo "       --cpus N"
 	echo "       --datestamp string"
+	echo "       --defconfig string"
 	echo "       --dryrun sched|script"
 	echo "       --duration minutes"
 	echo "       --interactive"
@@ -96,6 +98,11 @@ do
 		ds=$2
 		shift
 		;;
+	--defconfig)
+		checkarg --defconfig "defconfigtype" "$#" "$2" '^[^/][^/]*$' '^--'
+		TORTURE_DEFCONFIG=$2
+		shift
+		;;
 	--dryrun)
 		checkarg --dryrun "sched|script" $# "$2" 'sched\|script' '^--'
 		dryrun=$2
@@ -259,6 +266,7 @@ END {
 # Generate a script to execute the tests in appropriate batches.
 cat << ___EOF___ > $T/script
 TORTURE_SUITE="$TORTURE_SUITE"; export TORTURE_SUITE
+TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG
 ___EOF___
 awk < $T/cfgcpu.pack \
 	-v CONFIGDIR="$CONFIGFRAG/$kversion/" \
Signature · 1 line
1.8.1.5
#43 lore raw

PATCH 20/45 torture: Include "Stopping" string to torture_kthread_stopping()

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Currently, torture_kthread_stopping() prints only the name of the kthread that is stopping, which can be unedifying. This commit therefore adds "Stopping" to make things more evident.

---
 kernel/torture.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/torture.c +4 -1
index acc9afc2f26e..f329848c3eee 100644
@@ -674,8 +674,11 @@ EXPORT_SYMBOL_GPL(torture_must_stop_irq);
  */
 void torture_kthread_stopping(char *title)
 {
+	char buf[128];
+
+	snprintf(buf, sizeof(buf), "Stopping %s", title);
 	if (verbose)
-		VERBOSE_TOROUT_STRING(title);
+		VERBOSE_TOROUT_STRING(buf);
 	while (!kthread_should_stop()) {
 		torture_shutdown_absorb(title);
 		schedule_timeout_uninterruptible(1);
Signature · 1 line
1.8.1.5
#55 lore raw

PATCH 24/45 torture: Choose bzImage location based on architecture

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Currently, the scripts hard-code arch/x86/boot/bzImage, which does not work well for other architectures. This commit therefore provides a identify_boot_image function that selects the correct bzImage location relative to the top of the Linux source tree. This commit also adds a --bootimage argument that allows selecting some other file, for example, "vmlinux".

---
 tools/testing/selftests/rcutorture/bin/functions.sh | 21 +++++++++++++++++++++
 .../selftests/rcutorture/bin/kvm-test-1-run.sh      | 11 +++++------
 tools/testing/selftests/rcutorture/bin/kvm.sh       |  8 ++++++++
 3 files changed, 34 insertions(+), 6 deletions(-)
tools/testing/selftests/rcutorture/bin/functions.sh +21 -0
index 6b2adb29b073..efa95867e1cc 100644
@@ -76,6 +76,27 @@ configfrag_hotplug_cpu () {
 	grep -q '^CONFIG_HOTPLUG_CPU=y$' "$1"
 }
 
+# identify_boot_image qemu-cmd
+#
+# Returns the relative path to the kernel build image.  This will be
+# arch/<arch>/boot/bzImage unless overridden with the TORTURE_BOOT_IMAGE
+# environment variable.
+identify_boot_image () {
+	if test -n "$TORTURE_BOOT_IMAGE"
+	then
+		echo $TORTURE_BOOT_IMAGE
+	else
+		case "$1" in
+		qemu-system-x86_64|qemu-system-i386)
+			echo arch/x86/boot/bzImage
+			;;
+		qemu-system-ppc64)
+			echo arch/powerpc/boot/bzImage
+			;;
+		esac
+	fi
+}
+
 # identify_qemu builddir
 #
 # Returns our best guess as to which qemu command is appropriate for
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +5 -6
index 7848227aa4c1..7a95f86cc85a 100755
@@ -94,9 +94,11 @@ fi
 # CONFIG_YENTA=n
 if kvm-build.sh $config_template $builddir $T
 then
+	QEMU="`identify_qemu $builddir/vmlinux`"
+	BOOT_IMAGE="`identify_boot_image $QEMU`"
 	cp $builddir/Make*.out $resdir
 	cp $builddir/.config $resdir
-	cp $builddir/arch/x86/boot/bzImage $resdir
+	cp $builddir/$BOOT_IMAGE $resdir
 	parse-build.sh $resdir/Make.out $title
 	if test -f $builddir.wait
 	then
@@ -124,9 +126,6 @@ cd $KVM
 kstarttime=`awk 'BEGIN { print systime() }' < /dev/null`
 echo ' ---' `date`: Starting kernel
 
-# Determine the appropriate flavor of qemu command.
-QEMU="`identify_qemu $builddir/vmlinux`"
-
 # Generate -smp qemu argument.
 qemu_args="-nographic $qemu_args"
 cpu_count=`configNR_CPUS.sh $config_template`
@@ -151,13 +150,13 @@ boot_args="`configfrag_boot_params "$boot_args" "$config_template"`"
 # Generate kernel-version-specific boot parameters
 boot_args="`per_version_boot_params "$boot_args" $builddir/.config $seconds`"
 
-echo $QEMU $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd
+echo $QEMU $qemu_args -m 512 -kernel $builddir/$BOOT_IMAGE -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd
 if test -n "$TORTURE_BUILDONLY"
 then
 	echo Build-only run specified, boot/test omitted.
 	exit 0
 fi
-$QEMU $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append "$qemu_append $boot_args"; echo $? > $resdir/qemu-retval &
+$QEMU $qemu_args -m 512 -kernel $builddir/$BOOT_IMAGE -append "$qemu_append $boot_args"; echo $? > $resdir/qemu-retval &
 qemu_pid=$!
 commandcompleted=0
 echo Monitoring qemu job at pid $qemu_pid
tools/testing/selftests/rcutorture/bin/kvm.sh +8 -0
index 9b838c372698..4eed2a4f42c7 100644
@@ -39,6 +39,7 @@ dryrun=""
 KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
 PATH=${KVM}/bin:$PATH; export PATH
 TORTURE_DEFCONFIG=defconfig
+TORTURE_BOOT_IMAGE=""
 TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
 TORTURE_KMAKE_ARG=""
 TORTURE_SUITE=rcu
@@ -53,6 +54,7 @@ kversion=""
 usage () {
 	echo "Usage: $scriptname optional arguments:"
 	echo "       --bootargs kernel-boot-arguments"
+	echo "       --bootimage relative-path-to-kernel-boot-image"
 	echo "       --buildonly"
 	echo "       --configs \"config-file list\""
 	echo "       --cpus N"
@@ -80,6 +82,11 @@ do
 		TORTURE_BOOTARGS="$2"
 		shift
 		;;
+	--bootimage)
+		checkarg --bootimage "(relative path to kernel boot image)" "$#" "$2" '[a-zA-Z0-9][a-zA-Z0-9_]*' '^--'
+		TORTURE_BOOT_IMAGE="$2"
+		shift
+		;;
 	--buildonly)
 		TORTURE_BUILDONLY=1
 		;;
@@ -245,6 +252,7 @@ CONFIGFRAG="$CONFIGFRAG"; export CONFIGFRAG
 KVM="$KVM"; export KVM
 KVPATH="$KVPATH"; export KVPATH
 PATH="$PATH"; export PATH
+TORTURE_BOOT_IMAGE="$TORTURE_BOOT_IMAGE"; export TORTURE_BOOT_IMAGE
 TORTURE_BUILDONLY="$TORTURE_BUILDONLY"; export TORTURE_BUILDONLY
 TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG
 TORTURE_INITRD="$TORTURE_INITRD"; export TORTURE_INITRD
Signature · 1 line
1.8.1.5
#77 lore raw

PATCH 36/45 rcutorture: Add tests for get_state_synchronize_rcu()

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit adds rcutorture testing for get_state_synchronize_rcu() and cond_synchronize_rcu().

---
 kernel/rcu/rcutorture.c | 130 +++++++++++++++++++++++++++++++++++-------------
 1 file changed, 95 insertions(+), 35 deletions(-)
kernel/rcu/rcutorture.c +95 -35
index cf231f508139..9f344ec32e69 100644
@@ -58,6 +58,7 @@ torture_param(int, fqs_duration, 0,
 	      "Duration of fqs bursts (us), 0 to disable");
 torture_param(int, fqs_holdoff, 0, "Holdoff time within fqs bursts (us)");
 torture_param(int, fqs_stutter, 3, "Wait time between fqs bursts (s)");
+torture_param(bool, gp_cond, false, "Use conditional/async GP wait primitives");
 torture_param(bool, gp_exp, false, "Use expedited GP wait primitives");
 torture_param(bool, gp_normal, false,
 	     "Use normal (non-expedited) GP wait primitives");
@@ -144,8 +145,10 @@ static int rcu_torture_writer_state;
 #define RTWS_REPLACE		2
 #define RTWS_DEF_FREE		3
 #define RTWS_EXP_SYNC		4
-#define RTWS_STUTTER		5
-#define RTWS_STOPPING		6
+#define RTWS_COND_GET		5
+#define RTWS_COND_SYNC		6
+#define RTWS_STUTTER		7
+#define RTWS_STOPPING		8
 
 #if defined(MODULE) || defined(CONFIG_RCU_TORTURE_TEST_RUNNABLE)
 #define RCUTORTURE_RUNNABLE_INIT 1
@@ -232,6 +235,8 @@ struct rcu_torture_ops {
 	void (*deferred_free)(struct rcu_torture *p);
 	void (*sync)(void);
 	void (*exp_sync)(void);
+	unsigned long (*get_state)(void);
+	void (*cond_sync)(unsigned long oldstate);
 	void (*call)(struct rcu_head *head, void (*func)(struct rcu_head *rcu));
 	void (*cb_barrier)(void);
 	void (*fqs)(void);
@@ -283,10 +288,48 @@ static int rcu_torture_completed(void)
 	return rcu_batches_completed();
 }
 
+/*
+ * Update callback in the pipe.  This should be invoked after a grace period.
+ */
+static bool
+rcu_torture_pipe_update_one(struct rcu_torture *rp)
+{
+	int i;
+
+	i = rp->rtort_pipe_count;
+	if (i > RCU_TORTURE_PIPE_LEN)
+		i = RCU_TORTURE_PIPE_LEN;
+	atomic_inc(&rcu_torture_wcount[i]);
+	if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
+		rp->rtort_mbtest = 0;
+		return true;
+	}
+	return false;
+}
+
+/*
+ * Update all callbacks in the pipe.  Suitable for synchronous grace-period
+ * primitives.
+ */
+static void
+rcu_torture_pipe_update(struct rcu_torture *old_rp)
+{
+	struct rcu_torture *rp;
+	struct rcu_torture *rp1;
+
+	if (old_rp)
+		list_add(&old_rp->rtort_free, &rcu_torture_removed);
+	list_for_each_entry_safe(rp, rp1, &rcu_torture_removed, rtort_free) {
+		if (rcu_torture_pipe_update_one(rp)) {
+			list_del(&rp->rtort_free);
+			rcu_torture_free(rp);
+		}
+	}
+}
+
 static void
 rcu_torture_cb(struct rcu_head *p)
 {
-	int i;
 	struct rcu_torture *rp = container_of(p, struct rcu_torture, rtort_rcu);
 
 	if (torture_must_stop_irq()) {
@@ -294,16 +337,10 @@ rcu_torture_cb(struct rcu_head *p)
 		/* The next initialization will pick up the pieces. */
 		return;
 	}
-	i = rp->rtort_pipe_count;
-	if (i > RCU_TORTURE_PIPE_LEN)
-		i = RCU_TORTURE_PIPE_LEN;
-	atomic_inc(&rcu_torture_wcount[i]);
-	if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
-		rp->rtort_mbtest = 0;
+	if (rcu_torture_pipe_update_one(rp))
 		rcu_torture_free(rp);
-	} else {
+	else
 		cur_ops->deferred_free(rp);
-	}
 }
 
 static int rcu_no_completed(void)
@@ -331,6 +368,8 @@ static struct rcu_torture_ops rcu_ops = {
 	.deferred_free	= rcu_torture_deferred_free,
 	.sync		= synchronize_rcu,
 	.exp_sync	= synchronize_rcu_expedited,
+	.get_state	= get_state_synchronize_rcu,
+	.cond_sync	= cond_synchronize_rcu,
 	.call		= call_rcu,
 	.cb_barrier	= rcu_barrier,
 	.fqs		= rcu_force_quiescent_state,
@@ -704,16 +743,39 @@ rcu_torture_fqs(void *arg)
 static int
 rcu_torture_writer(void *arg)
 {
-	bool exp;
+	unsigned long gp_snap;
+	bool gp_cond1 = gp_cond, gp_exp1 = gp_exp, gp_normal1 = gp_normal;
 	int i;
 	struct rcu_torture *rp;
-	struct rcu_torture *rp1;
 	struct rcu_torture *old_rp;
 	static DEFINE_TORTURE_RANDOM(rand);
+	int synctype[] = { RTWS_DEF_FREE, RTWS_EXP_SYNC, RTWS_COND_GET };
+	int nsynctypes = 0;
 
 	VERBOSE_TOROUT_STRING("rcu_torture_writer task started");
 	set_user_nice(current, MAX_NICE);
 
+	/* Initialize synctype[] array.  If none set, take default. */
+	if (!gp_cond1 && !gp_exp1 && !gp_normal1)
+		gp_cond1 = gp_exp1 = gp_normal1 = true;
+	if (gp_cond1 && cur_ops->get_state && cur_ops->cond_sync)
+		synctype[nsynctypes++] = RTWS_COND_GET;
+	else if (gp_cond && (!cur_ops->get_state || !cur_ops->cond_sync))
+		pr_alert("rcu_torture_writer: gp_cond without primitives.\n");
+	if (gp_exp1 && cur_ops->exp_sync)
+		synctype[nsynctypes++] = RTWS_EXP_SYNC;
+	else if (gp_exp && !cur_ops->exp_sync)
+		pr_alert("rcu_torture_writer: gp_exp without primitives.\n");
+	if (gp_normal1 && cur_ops->deferred_free)
+		synctype[nsynctypes++] = RTWS_DEF_FREE;
+	else if (gp_normal && !cur_ops->deferred_free)
+		pr_alert("rcu_torture_writer: gp_normal without primitives.\n");
+	if (WARN_ONCE(nsynctypes == 0,
+		      "rcu_torture_writer: No update-side primitives.\n")) {
+		rcu_torture_writer_state = RTWS_STOPPING;
+		torture_kthread_stopping("rcu_torture_writer");
+	}
+
 	do {
 		rcu_torture_writer_state = RTWS_FIXED_DELAY;
 		schedule_timeout_uninterruptible(1);
@@ -735,32 +797,30 @@ rcu_torture_writer(void *arg)
 				i = RCU_TORTURE_PIPE_LEN;
 			atomic_inc(&rcu_torture_wcount[i]);
 			old_rp->rtort_pipe_count++;
-			if (gp_normal == gp_exp)
-				exp = !!(torture_random(&rand) & 0x80);
-			else
-				exp = gp_exp;
-			if (!exp) {
+			switch (synctype[torture_random(&rand) % nsynctypes]) {
+			case RTWS_DEF_FREE:
 				rcu_torture_writer_state = RTWS_DEF_FREE;
 				cur_ops->deferred_free(old_rp);
-			} else {
+				break;
+			case RTWS_EXP_SYNC:
 				rcu_torture_writer_state = RTWS_EXP_SYNC;
 				cur_ops->exp_sync();
-				list_add(&old_rp->rtort_free,
-					 &rcu_torture_removed);
-				list_for_each_entry_safe(rp, rp1,
-							 &rcu_torture_removed,
-							 rtort_free) {
-					i = rp->rtort_pipe_count;
-					if (i > RCU_TORTURE_PIPE_LEN)
-						i = RCU_TORTURE_PIPE_LEN;
-					atomic_inc(&rcu_torture_wcount[i]);
-					if (++rp->rtort_pipe_count >=
-					    RCU_TORTURE_PIPE_LEN) {
-						rp->rtort_mbtest = 0;
-						list_del(&rp->rtort_free);
-						rcu_torture_free(rp);
-					}
-				 }
+				rcu_torture_pipe_update(old_rp);
+				break;
+			case RTWS_COND_GET:
+				rcu_torture_writer_state = RTWS_COND_GET;
+				gp_snap = cur_ops->get_state();
+				i = torture_random(&rand) % 16;
+				if (i != 0)
+					schedule_timeout_interruptible(i);
+				udelay(torture_random(&rand) % 1000);
+				rcu_torture_writer_state = RTWS_COND_SYNC;
+				cur_ops->cond_sync(gp_snap);
+				rcu_torture_pipe_update(old_rp);
+				break;
+			default:
+				WARN_ON_ONCE(1);
+				break;
 			}
 		}
 		rcutorture_record_progress(++rcu_torture_current_version);
Signature · 1 line
1.8.1.5
#80 lore raw

PATCH 39/45 rcutorture: Note diffs from git commits

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The current scripting only keeps track of the git SHA-1 of the current HEAD. This can cause confusion in cases where testing ran in a git tree where changes had not yet been checked in. This commit therefore also records the output of "git diff HEAD" to provide the information needed to reconstruct the source tree that was tested.

---
 tools/testing/selftests/rcutorture/bin/kvm.sh | 5 +++++
 1 file changed, 5 insertions(+)
tools/testing/selftests/rcutorture/bin/kvm.sh +5 -0
index 4eed2a4f42c7..91661845fdec 100644
@@ -277,6 +277,11 @@ if test -d .git
 then
 	git status >> $resdir/$ds/testid.txt
 	git rev-parse HEAD >> $resdir/$ds/testid.txt
+	git diff HEAD > $T/git-diff 2>&1
+	if test -s $T/git-diff
+	then
+		cp $T/git-diff $resdir/$ds
+	fi
 fi
 ___EOF___
 awk < $T/cfgcpu.pack \
Signature · 1 line
1.8.1.5
#91 lore raw

PATCH 43/45 torture: Check for multiple concurrent torture tests

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The torture tests are designed to run in isolation, but do not enforce this isolation. This commit therefore checks for concurrent torture tests, and refuses to start new tests while old tests are running.

---
 include/linux/torture.h      |  2 +-
 kernel/locking/locktorture.c |  3 ++-
 kernel/rcu/rcutorture.c      |  3 ++-
 kernel/torture.c             | 13 +++++++++++--
 4 files changed, 16 insertions(+), 5 deletions(-)
include/linux/torture.h +1 -1
index b2e2b468e511..f998574247fd 100644
@@ -81,7 +81,7 @@ void stutter_wait(const char *title);
 int torture_stutter_init(int s);
 
 /* Initialization and cleanup. */
-void torture_init_begin(char *ttype, bool v, int *runnable);
+bool torture_init_begin(char *ttype, bool v, int *runnable);
 void torture_init_end(void);
 bool torture_cleanup(void);
 bool torture_must_stop(void);
kernel/locking/locktorture.c +2 -1
index 1952466c7db5..dbafeac18e4d 100644
@@ -355,7 +355,8 @@ static int __init lock_torture_init(void)
 		&lock_busted_ops, &spin_lock_ops, &spin_lock_irq_ops,
 	};
 
-	torture_init_begin(torture_type, verbose, &locktorture_runnable);
+	if (!torture_init_begin(torture_type, verbose, &locktorture_runnable))
+		return -EBUSY;
 
 	/* Process args and tell the world that the torturer is on the job. */
 	for (i = 0; i < ARRAY_SIZE(torture_ops); i++) {
kernel/rcu/rcutorture.c +2 -1
index b181b11c398e..1d8559198bd5 100644
@@ -1535,7 +1535,8 @@ rcu_torture_init(void)
 		&rcu_ops, &rcu_bh_ops, &rcu_busted_ops, &srcu_ops, &sched_ops,
 	};
 
-	torture_init_begin(torture_type, verbose, &rcutorture_runnable);
+	if (!torture_init_begin(torture_type, verbose, &rcutorture_runnable))
+		return -EBUSY;
 
 	/* Process args and tell the world that the torturer is on the job. */
 	for (i = 0; i < ARRAY_SIZE(torture_ops); i++) {
kernel/torture.c +11 -2
index c1d57e83e8fe..de440a46331c 100644
@@ -599,14 +599,20 @@ static void torture_stutter_cleanup(void)
  * The runnable parameter points to a flag that controls whether or not
  * the test is currently runnable.  If there is no such flag, pass in NULL.
  */
-void __init torture_init_begin(char *ttype, bool v, int *runnable)
+bool __init torture_init_begin(char *ttype, bool v, int *runnable)
 {
 	mutex_lock(&fullstop_mutex);
+	if (torture_type != NULL) {
+		pr_alert("torture_init_begin: refusing %s init: %s running",
+			 ttype, torture_type);
+		mutex_unlock(&fullstop_mutex);
+		return false;
+	}
 	torture_type = ttype;
 	verbose = v;
 	torture_runnable = runnable;
 	fullstop = FULLSTOP_DONTSTOP;
-
+	return true;
 }
 EXPORT_SYMBOL_GPL(torture_init_begin);
 
@@ -645,6 +651,9 @@ bool torture_cleanup(void)
 	torture_shuffle_cleanup();
 	torture_stutter_cleanup();
 	torture_onoff_cleanup();
+	mutex_lock(&fullstop_mutex);
+	torture_type = NULL;
+	mutex_unlock(&fullstop_mutex);
 	return false;
 }
 EXPORT_SYMBOL_GPL(torture_cleanup);
Signature · 1 line
1.8.1.5
#86 lore raw

PATCH 40/45 rcutorture: Run rcu_torture_writer at normal priority

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

There are usually lots of readers and only one writer, so if there has to be a choice, we would want rcu_torture_writer to win. This commit therefore removes the set_user_nice() from rcu_torture_writer().

---
 kernel/rcu/rcutorture.c | 1 -
 1 file changed, 1 deletion(-)
kernel/rcu/rcutorture.c +0 -1
index a576583dd81e..b181b11c398e 100644
@@ -757,7 +757,6 @@ rcu_torture_writer(void *arg)
 	int nsynctypes = 0;
 
 	VERBOSE_TOROUT_STRING("rcu_torture_writer task started");
-	set_user_nice(current, MAX_NICE);
 
 	/* Initialize synctype[] array.  If none set, take default. */
 	if (!gp_cond1 && !gp_exp1 && !gp_normal1 && !gp_sync)
Signature · 1 line
1.8.1.5
#87 lore raw

PATCH 41/45 torture: Put qemu into the background

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Currently, qemu runs in the foreground, which prevents the script from killing it in case the kernel locks up. This commit therefore places qemu into the background, allowing the script to recover from lockups.

---
 tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +1 -1
index b1e85b049075..67e89f06e77f 100755
@@ -157,7 +157,7 @@ then
 	echo Build-only run specified, boot/test omitted.
 	exit 0
 fi
-$QEMU $qemu_args -m 512 -kernel $builddir/$BOOT_IMAGE -append "$qemu_append $boot_args"; echo $? > $resdir/qemu-retval &
+( $QEMU $qemu_args -m 512 -kernel $builddir/$BOOT_IMAGE -append "$qemu_append $boot_args"; echo $? > $resdir/qemu-retval ) &
 qemu_pid=$!
 commandcompleted=0
 echo Monitoring qemu job at pid $qemu_pid
Signature · 1 line
1.8.1.5
#92 lore raw

PATCH 44/45 torture: Remove __init from torture_init_begin/end

In reply to Paul E. McKenney

From: Pranith Kumar <[email protected]>

Loading rcutorture as a module (as opposed to building it directly into the kernel) results in the following splat:

[Wed Apr 16 15:29:33 2014] BUG: unable to handle kernel paging request at ffffffffa0003000
[Wed Apr 16 15:29:33 2014] IP: [<ffffffffa0003000>] 0xffffffffa0003000
[Wed Apr 16 15:29:33 2014] PGD 1c0f067 PUD 1c10063 PMD 378a6067 PTE 0
[Wed Apr 16 15:29:33 2014] Oops: 0010 [#1] SMP
[Wed Apr 16 15:29:33 2014] Modules linked in: rcutorture(+) torture
[Wed Apr 16 15:29:33 2014] CPU: 0 PID: 4257 Comm: modprobe Not tainted 3.15.0-rc1 #10
[Wed Apr 16 15:29:33 2014] Hardware name: innotek GmbH VirtualBox, BIOS VirtualBox 12/01/2006
[Wed Apr 16 15:29:33 2014] task: ffff8800db1e88d0 ti: ffff8800db25c000 task.ti: ffff8800db25c000
[Wed Apr 16 15:29:33 2014] RIP: 0010:[<ffffffffa0003000>]  [<ffffffffa0003000>] 0xffffffffa0003000
[Wed Apr 16 15:29:33 2014] RSP: 0018:ffff8800db25dca0  EFLAGS: 00010282
[Wed Apr 16 15:29:33 2014] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
[Wed Apr 16 15:29:33 2014] RDX: ffffffffa00090a8 RSI: 0000000000000001 RDI: ffffffffa0008337
[Wed Apr 16 15:29:33 2014] RBP: ffff8800db25dd50 R08: 0000000000000000 R09: 0000000000000000
[Wed Apr 16 15:29:33 2014] R10: ffffea000357b680 R11: ffffffff8113257a R12: ffffffffa000d000
[Wed Apr 16 15:29:33 2014] R13: ffffffffa00094c0 R14: ffffffffa0009510 R15: 0000000000000001
[Wed Apr 16 15:29:33 2014] FS:  00007fee30ce5700(0000) GS:ffff88021fc00000(0000) knlGS:0000000000000000
[Wed Apr 16 15:29:33 2014] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[Wed Apr 16 15:29:33 2014] CR2: ffffffffa0003000 CR3: 00000000d5eb1000 CR4: 00000000000006f0
[Wed Apr 16 15:29:33 2014] Stack:
[Wed Apr 16 15:29:33 2014]  ffffffffa000d02c 0000000000000000 ffff88021700d400 0000000000000000
[Wed Apr 16 15:29:33 2014]  ffff8800db25dd40 ffffffff81647951 ffff8802162bd000 ffff88021541846c
[Wed Apr 16 15:29:33 2014]  0000000000000000 ffffffff817dbe2d ffffffff817dbe2d 0000000000000001
[Wed Apr 16 15:29:33 2014] Call Trace:
[Wed Apr 16 15:29:33 2014]  [<ffffffffa000d02c>] ? rcu_torture_init+0x2c/0x8b4 [rcutorture]
[Wed Apr 16 15:29:33 2014]  [<ffffffff81647951>] ? netlink_broadcast_filtered+0x121/0x3a0
[Wed Apr 16 15:29:33 2014]  [<ffffffff817dbe2d>] ? mutex_lock+0xd/0x2a
[Wed Apr 16 15:29:33 2014]  [<ffffffff817dbe2d>] ? mutex_lock+0xd/0x2a
[Wed Apr 16 15:29:33 2014]  [<ffffffff810e7022>] ? trace_module_notify+0x62/0x1d0
[Wed Apr 16 15:29:33 2014]  [<ffffffffa000d000>] ? 0xffffffffa000cfff
[Wed Apr 16 15:29:33 2014]  [<ffffffff8100034a>] do_one_initcall+0xfa/0x140
[Wed Apr 16 15:29:33 2014]  [<ffffffff8106b4ce>] ? __blocking_notifier_call_chain+0x5e/0x80
[Wed Apr 16 15:29:33 2014]  [<ffffffff810b3481>] load_module+0x1931/0x21b0
[Wed Apr 16 15:29:33 2014]  [<ffffffff810b0330>] ? show_initstate+0x50/0x50
[Wed Apr 16 15:29:33 2014]  [<ffffffff810b3d9e>] SyS_init_module+0x9e/0xc0
[Wed Apr 16 15:29:33 2014]  [<ffffffff817e4c22>] system_call_fastpath+0x16/0x1b
[Wed Apr 16 15:29:33 2014] Code:  Bad RIP value.
[Wed Apr 16 15:29:33 2014] RIP  [<ffffffffa0003000>] 0xffffffffa0003000
[Wed Apr 16 15:29:33 2014]  RSP <ffff8800db25dca0>
[Wed Apr 16 15:29:33 2014] CR2: ffffffffa0003000
[Wed Apr 16 15:29:33 2014] ---[ end trace 3e88c173037af84b ]---

This splat is due to the fact that torture_init_begin() and torture_init_end() are both marked with __init, despite their use at runtime. This commit therefore removes __init from both functions.

---
 kernel/torture.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/torture.c +2 -2
index de440a46331c..db8de702abbc 100644
@@ -599,7 +599,7 @@ static void torture_stutter_cleanup(void)
  * The runnable parameter points to a flag that controls whether or not
  * the test is currently runnable.  If there is no such flag, pass in NULL.
  */
-bool __init torture_init_begin(char *ttype, bool v, int *runnable)
+bool torture_init_begin(char *ttype, bool v, int *runnable)
 {
 	mutex_lock(&fullstop_mutex);
 	if (torture_type != NULL) {
@@ -619,7 +619,7 @@ EXPORT_SYMBOL_GPL(torture_init_begin);
 /*
  * Tell the torture module that initialization is complete.
  */
-void __init torture_init_end(void)
+void torture_init_end(void)
 {
 	mutex_unlock(&fullstop_mutex);
 	register_reboot_notifier(&torture_shutdown_nb);
Signature · 1 line
1.8.1.5
#75 lore raw

PATCH 34/45 torture: Use elapsed time to detect hangs

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The kvm-test-1-run.sh currently counts "sleep 1" commands to detect hangs. This can fail spectacularly on busy systems, where "sleep 1" might take far longer than one second to complete. This commit therefore changes hang detection to use elapsed time measurements.

---
 .../testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +12 -6
index 51c34a91a375..b1e85b049075 100755
@@ -161,14 +161,18 @@ $QEMU $qemu_args -m 512 -kernel $builddir/$BOOT_IMAGE -append "$qemu_append $boo
 qemu_pid=$!
 commandcompleted=0
 echo Monitoring qemu job at pid $qemu_pid
-for ((i=0;i<$seconds;i++))
+while :
 do
+	kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null`
 	if kill -0 $qemu_pid > /dev/null 2>&1
 	then
+		if test $kruntime -ge $seconds
+		then
+			break;
+		fi
 		sleep 1
 	else
 		commandcompleted=1
-		kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null`
 		if test $kruntime -lt $seconds
 		then
 			echo Completed in $kruntime vs. $seconds >> $resdir/Warnings 2>&1
@@ -189,20 +193,22 @@ done
 if test $commandcompleted -eq 0
 then
 	echo Grace period for qemu job at pid $qemu_pid
-	for ((i=0;i<=$grace;i++))
+	while :
 	do
+		kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null`
 		if kill -0 $qemu_pid > /dev/null 2>&1
 		then
-			sleep 1
+			:
 		else
 			break
 		fi
-		if test $i -eq $grace
+		if test $kruntime -ge $((seconds + grace))
 		then
-			kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }'`
 			echo "!!! Hang at $kruntime vs. $seconds seconds" >> $resdir/Warnings 2>&1
 			kill -KILL $qemu_pid
+			break
 		fi
+		sleep 1
 	done
 fi
 
Signature · 1 line
1.8.1.5
#93 lore raw

PATCH 45/45 torture: Remove unused definition

In reply to Paul E. McKenney

From: Pranith Kumar <[email protected]>

The torture_parm() macro is the same as torture_param(), and torture_parm() is not used. This commit therefore removes torture_parm().

---
 include/linux/torture.h | 6 ------
 1 file changed, 6 deletions(-)
include/linux/torture.h +0 -6
index f998574247fd..5ca58fcbaf1b 100644
@@ -49,12 +49,6 @@
 #define VERBOSE_TOROUT_ERRSTRING(s) \
 	do { if (verbose) pr_alert("%s" TORTURE_FLAG "!!! %s\n", torture_type, s); } while (0)
 
-/* Definitions for a non-string torture-test module parameter. */
-#define torture_parm(type, name, init, msg) \
-	static type name = init; \
-	module_param(name, type, 0444); \
-	MODULE_PARM_DESC(name, msg);
-
 /* Definitions for online/offline exerciser. */
 int torture_onoff_init(long ooholdoff, long oointerval);
 char *torture_onoff_stats(char *page);
Signature · 1 line
1.8.1.5
#76 lore raw

PATCH 35/45 rcutorture: Test RCU-sched primitives in TREE_PREEMPT_RCU kernels

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit ensures that RCU-sched primitives are tested in TREE_PREEMPT_RCU kernels, a combination that was previously omitted.

---
 tools/testing/selftests/rcutorture/configs/rcu/TREE08.boot | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 tools/testing/selftests/rcutorture/configs/rcu/TREE08.boot
tools/testing/selftests/rcutorture/configs/rcu/TREE08.boot new file +1 -0
new file mode 100644
index 000000000000..3b42b8b033cd
@@ -0,0 +1 @@
+rcutorture.torture_type=sched
Signature · 1 line
1.8.1.5
#79 lore raw

PATCH 38/45 rcutorture: Add missing destroy_timer_on_stack()

In reply to Paul E. McKenney

From: Thomas Gleixner <[email protected]>

The rcu_torture_reader() function uses an on-stack timer_list structure which it initializes with setup_timer_on_stack(). However, it fails to use destroy_timer_on_stack() before exiting, which results in leaking a tracking object if DEBUG_OBJECTS is enabled. This commit therefore invokes destroy_timer_on_stack() to avoid this leakage.

---
 kernel/rcu/rcutorture.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/rcu/rcutorture.c +3 -1
index 576d12263c81..a576583dd81e 100644
@@ -1022,8 +1022,10 @@ rcu_torture_reader(void *arg)
 		cond_resched();
 		stutter_wait("rcu_torture_reader");
 	} while (!torture_must_stop());
-	if (irqreader && cur_ops->irq_capable)
+	if (irqreader && cur_ops->irq_capable) {
 		del_timer_sync(&t);
+		destroy_timer_on_stack(&t);
+	}
 	torture_kthread_stopping("rcu_torture_reader");
 	return 0;
 }
Signature · 1 line
1.8.1.5
#90 lore raw

PATCH 42/45 locktorture: Remove reference to nonexistent Kconfig parameter

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The locktorture module references CONFIG_LOCK_TORTURE_TEST_RUNNABLE, which does not exist. Which is a good thing, because otherwise randconfig testing could enable both rcutorture and locktorture concurrently, which the torture tests are not set up for. This commit therefore removes the reference, so that test is runnable immediately only when inserted as a module.

---
 kernel/locking/locktorture.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/locking/locktorture.c +2 -2
index b0d3e3c50672..1952466c7db5 100644
@@ -82,14 +82,14 @@ struct lock_writer_stress_stats {
 };
 static struct lock_writer_stress_stats *lwsa;
 
-#if defined(MODULE) || defined(CONFIG_LOCK_TORTURE_TEST_RUNNABLE)
+#if defined(MODULE)
 #define LOCKTORTURE_RUNNABLE_INIT 1
 #else
 #define LOCKTORTURE_RUNNABLE_INIT 0
 #endif
 int locktorture_runnable = LOCKTORTURE_RUNNABLE_INIT;
 module_param(locktorture_runnable, int, 0444);
-MODULE_PARM_DESC(locktorture_runnable, "Start locktorture at boot");
+MODULE_PARM_DESC(locktorture_runnable, "Start locktorture at module init");
 
 /* Forward reference. */
 static void lock_torture_cleanup(void);
Signature · 1 line
1.8.1.5
#32 lore raw

PATCH 15/45 torture: Make config-fragment filtering RCU-independent

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The torture tests need to set specific values for their respective Kconfig options (e.g., CONFIG_LOCK_TORTURE_TEST), and must therefore filter any conflicting definitions from the Kconfig fragment file. Unfortunately, the code in kvm-build.sh was looking only for CONFIG_RCU_TORTURE_TEST. This commit therefore handles the general case of CONFIG_[A-Z]*TORTURE_TEST.

---
 tools/testing/selftests/rcutorture/bin/kvm-build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/kvm-build.sh +1 -1
index e838c775f709..6d0b76d918f4 100755
@@ -45,7 +45,7 @@ T=/tmp/test-linux.sh.$$
 trap 'rm -rf $T' 0
 mkdir $T
 
-cat ${config_template} | grep -v CONFIG_RCU_TORTURE_TEST > $T/config
+cat ${config_template} | grep -v 'CONFIG_[A-Z]*_TORTURE_TEST' > $T/config
 cat << ___EOF___ >> $T/config
 CONFIG_INITRAMFS_SOURCE="$TORTURE_INITRD"
 CONFIG_VIRTIO_PCI=y
Signature · 1 line
1.8.1.5
#37 lore raw

PATCH 18/45 torture: Make "--dryrun script" use same environment as normal run

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

In a normal torture-test run, the script inherits its environment variables, but this does not work when producing a script that is to run later. Therefore, definitions and exports are prepended to a dryrun script but not to a script that is run immediately. This commit reconciles this by placing definitions and exports at the beginning of the script in both cases.

---
 tools/testing/selftests/rcutorture/bin/kvm.sh | 28 ++++++++++++---------------
 1 file changed, 12 insertions(+), 16 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm.sh +12 -16
index 8aa62a2dccb5..93a6c5a8517d 100644
@@ -241,8 +241,19 @@ END {
 
 # Generate a script to execute the tests in appropriate batches.
 cat << ___EOF___ > $T/script
-TORTURE_SUITE="$TORTURE_SUITE"; export TORTURE_SUITE
+CONFIGFRAG="$CONFIGFRAG"; export CONFIGFRAG
+KVM="$KVM"; export KVM
+KVPATH="$KVPATH"; export KVPATH
+PATH="$PATH"; export PATH
+TORTURE_BUILDONLY="$TORTURE_BUILDONLY"; export TORTURE_BUILDONLY
 TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG
+TORTURE_INITRD="$TORTURE_INITRD"; export TORTURE_INITRD
+TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG"; export TORTURE_KMAKE_ARG
+TORTURE_QEMU_CMD="$TORTURE_QEMU_CMD"; export TORTURE_QEMU_CMD
+TORTURE_QEMU_INTERACTIVE="$TORTURE_QEMU_INTERACTIVE";
+	export TORTURE_QEMU_INTERACTIVE
+TORTURE_QEMU_MAC="$TORTURE_QEMU_MAC"; export TORTURE_QEMU_MAC
+TORTURE_SUITE="$TORTURE_SUITE"; export TORTURE_SUITE
 if ! test -e $resdir
 then
 	mkdir -p "$resdir" || :
@@ -371,21 +382,6 @@ ___EOF___
 
 if test "$dryrun" = script
 then
-	# Dump out the script, but define the environment variables that
-	# it needs to run standalone.
-	echo CONFIGFRAG="$CONFIGFRAG; export CONFIGFRAG"
-	echo KVM="$KVM; export KVM"
-	echo KVPATH="$KVPATH; export KVPATH"
-	echo PATH="$PATH; export PATH"
-	echo TORTURE_BUILDONLY="$TORTURE_BUILDONLY; export TORTURE_BUILDONLY"
-	echo TORTURE_INITRD="$TORTURE_INITRD; export TORTURE_INITRD"
-	echo TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG; export TORTURE_KMAKE_ARG"
-	echo TORTURE_QEMU_CMD="$TORTURE_QEMU_CMD; export TORTURE_QEMU_CMD"
-	echo TORTURE_QEMU_INTERACTIVE="$TORTURE_QEMU_INTERACTIVE;
-		export TORTURE_QEMU_INTERACTIVE"
-	echo TORTURE_QEMU_MAC="$TORTURE_QEMU_MAC; export TORTURE_QEMU_MAC"
-	echo "mkdir -p "$resdir" || :"
-	echo "mkdir $resdir/$ds"
 	cat $T/script
 	exit 0
 elif test "$dryrun" = sched
Signature · 1 line
1.8.1.5
#66 lore raw

PATCH 31/45 torture: Notice if an all-zero cpumask is passed inside a critical section

In reply to Paul E. McKenney

From: Iulia Manda <[email protected]>

In torture_shuffle_tasks function, the check if an all-zero mask can be passed to set_cpus_allowed_ptr() is redundant after clearing the shuffle_idle_cpu bit. If the mask had more than one bit set, after clearing a bit it has at least one bit set. If the mask had only one bit set, a check is made at the beginning, where the function returns, as there is no need to shuffle only one cpu.

Also, this code is executed inside a critical section, delimited by get_online_cpus(), and put_online_cpus(), preventing CPUs from leaving between the check of num_online_cpus and the calls to set_cpus_allowed_ptr() function.

---
 kernel/torture.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
kernel/torture.c +1 -6
index bd768effba9a..c1d57e83e8fe 100644
@@ -335,13 +335,8 @@ static void torture_shuffle_tasks(void)
 	shuffle_idle_cpu = cpumask_next(shuffle_idle_cpu, shuffle_tmp_mask);
 	if (shuffle_idle_cpu >= nr_cpu_ids)
 		shuffle_idle_cpu = -1;
-	if (shuffle_idle_cpu != -1) {
+	else
 		cpumask_clear_cpu(shuffle_idle_cpu, shuffle_tmp_mask);
-		if (cpumask_empty(shuffle_tmp_mask)) {
-			put_online_cpus();
-			return;
-		}
-	}
 
 	mutex_lock(&shuffle_task_mutex);
 	list_for_each_entry(stp, &shuffle_task_list, st_l)
Signature · 1 line
1.8.1.5
#78 lore raw

PATCH 37/45 rcutorture: Explicitly test synchronous grace-period primitives

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The original rcu_torture_writer() avoided testing the synchronous grace-period primitives because they were simply wrappers around call_rcu() invocations. The testing of these synchronous primitives was delegated to the fake writers. However, there really is no excuse not to test them, especially in the case of SRCU, where the wrappering is somewhat more elaborate. This commit therefore makes the default rcutorture parameters cause rcu_torture_writer() to include synchronous grace-period primitives in its testing.

---
 kernel/rcu/rcutorture.c | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)
kernel/rcu/rcutorture.c +23 -5
index 9f344ec32e69..576d12263c81 100644
@@ -62,6 +62,7 @@ torture_param(bool, gp_cond, false, "Use conditional/async GP wait primitives");
 torture_param(bool, gp_exp, false, "Use expedited GP wait primitives");
 torture_param(bool, gp_normal, false,
 	     "Use normal (non-expedited) GP wait primitives");
+torture_param(bool, gp_sync, false, "Use synchronous GP wait primitives");
 torture_param(int, irqreader, 1, "Allow RCU readers from irq handlers");
 torture_param(int, n_barrier_cbs, 0,
 	     "# of callbacks/kthreads for barrier testing");
@@ -147,8 +148,9 @@ static int rcu_torture_writer_state;
 #define RTWS_EXP_SYNC		4
 #define RTWS_COND_GET		5
 #define RTWS_COND_SYNC		6
-#define RTWS_STUTTER		7
-#define RTWS_STOPPING		8
+#define RTWS_SYNC		7
+#define RTWS_STUTTER		8
+#define RTWS_STOPPING		9
 
 #if defined(MODULE) || defined(CONFIG_RCU_TORTURE_TEST_RUNNABLE)
 #define RCUTORTURE_RUNNABLE_INIT 1
@@ -745,19 +747,21 @@ rcu_torture_writer(void *arg)
 {
 	unsigned long gp_snap;
 	bool gp_cond1 = gp_cond, gp_exp1 = gp_exp, gp_normal1 = gp_normal;
+	bool gp_sync1 = gp_sync;
 	int i;
 	struct rcu_torture *rp;
 	struct rcu_torture *old_rp;
 	static DEFINE_TORTURE_RANDOM(rand);
-	int synctype[] = { RTWS_DEF_FREE, RTWS_EXP_SYNC, RTWS_COND_GET };
+	int synctype[] = { RTWS_DEF_FREE, RTWS_EXP_SYNC,
+			   RTWS_COND_GET, RTWS_SYNC };
 	int nsynctypes = 0;
 
 	VERBOSE_TOROUT_STRING("rcu_torture_writer task started");
 	set_user_nice(current, MAX_NICE);
 
 	/* Initialize synctype[] array.  If none set, take default. */
-	if (!gp_cond1 && !gp_exp1 && !gp_normal1)
-		gp_cond1 = gp_exp1 = gp_normal1 = true;
+	if (!gp_cond1 && !gp_exp1 && !gp_normal1 && !gp_sync)
+		gp_cond1 = gp_exp1 = gp_normal1 = gp_sync1 = true;
 	if (gp_cond1 && cur_ops->get_state && cur_ops->cond_sync)
 		synctype[nsynctypes++] = RTWS_COND_GET;
 	else if (gp_cond && (!cur_ops->get_state || !cur_ops->cond_sync))
@@ -770,8 +774,17 @@ rcu_torture_writer(void *arg)
 		synctype[nsynctypes++] = RTWS_DEF_FREE;
 	else if (gp_normal && !cur_ops->deferred_free)
 		pr_alert("rcu_torture_writer: gp_normal without primitives.\n");
+	if (gp_sync1 && cur_ops->sync)
+		synctype[nsynctypes++] = RTWS_SYNC;
+	else if (gp_sync && !cur_ops->sync)
+		pr_alert("rcu_torture_writer: gp_sync without primitives.\n");
 	if (WARN_ONCE(nsynctypes == 0,
 		      "rcu_torture_writer: No update-side primitives.\n")) {
+		/*
+		 * No updates primitives, so don't try updating.
+		 * The resulting test won't be testing much, hence the
+		 * above WARN_ONCE().
+		 */
 		rcu_torture_writer_state = RTWS_STOPPING;
 		torture_kthread_stopping("rcu_torture_writer");
 	}
@@ -818,6 +831,11 @@ rcu_torture_writer(void *arg)
 				cur_ops->cond_sync(gp_snap);
 				rcu_torture_pipe_update(old_rp);
 				break;
+			case RTWS_SYNC:
+				rcu_torture_writer_state = RTWS_SYNC;
+				cur_ops->sync();
+				rcu_torture_pipe_update(old_rp);
+				break;
 			default:
 				WARN_ON_ONCE(1);
 				break;
Signature · 1 line
1.8.1.5
#54 lore raw

PATCH 23/45 torture: Permit multi-word qemu and boot arguments

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit applies quotes to permit multi-word --qemu-args and --bootargs arguments.

---
 tools/testing/selftests/rcutorture/bin/kvm.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm.sh +2 -2
index 93a6c5a8517d..9b838c372698 100644
@@ -277,8 +277,8 @@ awk < $T/cfgcpu.pack \
 	-v ncpus=$cpus \
 	-v rd=$resdir/$ds/ \
 	-v dur=$dur \
-	-v TORTURE_QEMU_ARG=$TORTURE_QEMU_ARG \
-	-v TORTURE_BOOTARGS=$TORTURE_BOOTARGS \
+	-v TORTURE_QEMU_ARG="$TORTURE_QEMU_ARG" \
+	-v TORTURE_BOOTARGS="$TORTURE_BOOTARGS" \
 'BEGIN {
 	i = 0;
 }
Signature · 1 line
1.8.1.5
#74 lore raw

PATCH 33/45 rcutorture: Check for rcu_torture_fqs creation errors

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The return value from torture_create_kthread() is currently ignored when creating the rcu_torture_fqs kthread. This commit therefore captures the return value so that it can be tested for errors.

---
 kernel/rcu/rcutorture.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcu/rcutorture.c +2 -1
index ea8af005ea3f..cf231f508139 100644
@@ -1576,7 +1576,8 @@ rcu_torture_init(void)
 		fqs_duration = 0;
 	if (fqs_duration) {
 		/* Create the fqs thread */
-		torture_create_kthread(rcu_torture_fqs, NULL, fqs_task);
+		firsterr = torture_create_kthread(rcu_torture_fqs, NULL,
+						  fqs_task);
 		if (firsterr)
 			goto unwind;
 	}
Signature · 1 line
1.8.1.5
#19 lore raw

PATCH 10/45 torture: Rename RCU_BUILDONLY to TORTURE_BUILDONLY

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit makes the torture scripts a bit more RCU-independent.

---
 tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 2 +-
 tools/testing/selftests/rcutorture/bin/kvm.sh            | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +1 -1
index e82f4f201c8c..86e6ffe6df45 100755
@@ -152,7 +152,7 @@ boot_args="`configfrag_boot_params "$boot_args" "$config_template"`"
 boot_args="`per_version_boot_params "$boot_args" $builddir/.config $seconds`"
 
 echo $QEMU $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd
-if test -n "$RCU_BUILDONLY"
+if test -n "$TORTURE_BUILDONLY"
 then
 	echo Build-only run specified, boot/test omitted.
 	exit 0
tools/testing/selftests/rcutorture/bin/kvm.sh +6 -3
index 08c90cba79d2..73c586f6bdf6 100644
@@ -81,7 +81,7 @@ do
 		shift
 		;;
 	--buildonly)
-		RCU_BUILDONLY=1; export RCU_BUILDONLY
+		TORTURE_BUILDONLY=1
 		;;
 	--configs)
 		checkarg --configs "(list of config files)" "$#" "$2" '^[^/]*$' '^--'
@@ -374,7 +374,7 @@ then
 	echo KVM="$KVM; export KVM"
 	echo KVPATH="$KVPATH; export KVPATH"
 	echo PATH="$PATH; export PATH"
-	echo RCU_BUILDONLY="$RCU_BUILDONLY; export RCU_BUILDONLY"
+	echo TORTURE_BUILDONLY="$TORTURE_BUILDONLY; export TORTURE_BUILDONLY"
 	echo TORTURE_INITRD="$TORTURE_INITRD; export TORTURE_INITRD"
 	echo TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG; export TORTURE_KMAKE_ARG"
 	echo RCU_QEMU_CMD="$RCU_QEMU_CMD; export RCU_QEMU_CMD"
@@ -402,4 +402,7 @@ echo
 echo
 echo " --- `date` Test summary:"
 echo Results directory: $resdir/$ds
-kvm-recheck.sh $resdir/$ds
+if test -n "$TORTURE_BUILDONLY"
+then
+	kvm-recheck.sh $resdir/$ds
+fi
Signature · 1 line
1.8.1.5
#64 lore raw

PATCH 29/45 sched,rcu: Make cond_resched() report RCU quiescent states

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Given a CPU running a loop containing cond_resched(), with no other tasks runnable on that CPU, RCU will eventually report RCU CPU stall warnings due to lack of quiescent states. Fortunately, every call to cond_resched() is a perfectly good quiescent state. Unfortunately, invoking rcu_note_context_switch() is a bit heavyweight for cond_resched(), especially given the need to disable preemption, and, for RCU-preempt, interrupts as well.

This commit therefore maintains a per-CPU counter that causes cond_resched(), cond_resched_lock(), and cond_resched_softirq() to call rcu_note_context_switch(), but only about once per 256 invocations. This ratio was chosen in keeping with the relative time constants of RCU grace periods.

---
 include/linux/rcupdate.h | 36 ++++++++++++++++++++++++++++++++++++
 kernel/rcu/update.c      | 18 ++++++++++++++++++
 kernel/sched/core.c      |  7 ++++++-
 3 files changed, 60 insertions(+), 1 deletion(-)
include/linux/rcupdate.h +36 -0
index a6c3898e141e..baead1bd0556 100644
@@ -44,6 +44,7 @@
 #include <linux/debugobjects.h>
 #include <linux/bug.h>
 #include <linux/compiler.h>
+#include <linux/percpu.h>
 #include <asm/barrier.h>
 
 extern int rcu_expedited; /* for sysctl */
@@ -287,6 +288,41 @@ bool __rcu_is_watching(void);
 #endif /* #if defined(CONFIG_DEBUG_LOCK_ALLOC) || defined(CONFIG_RCU_TRACE) || defined(CONFIG_SMP) */
 
 /*
+ * Hooks for cond_resched() and friends to avoid RCU CPU stall warnings.
+ */
+
+#define RCU_COND_RESCHED_LIM 256	/* ms vs. 100s of ms. */
+DECLARE_PER_CPU(int, rcu_cond_resched_count);
+void rcu_resched(void);
+
+/*
+ * Is it time to report RCU quiescent states?
+ *
+ * Note unsynchronized access to rcu_cond_resched_count.  Yes, we might
+ * increment some random CPU's count, and possibly also load the result from
+ * yet another CPU's count.  We might even clobber some other CPU's attempt
+ * to zero its counter.  This is all OK because the goal is not precision,
+ * but rather reasonable amortization of rcu_note_context_switch() overhead
+ * and extremely high probability of avoiding RCU CPU stall warnings.
+ * Note that this function has to be preempted in just the wrong place,
+ * many thousands of times in a row, for anything bad to happen.
+ */
+static inline bool rcu_should_resched(void)
+{
+	return raw_cpu_inc_return(rcu_cond_resched_count) >=
+	       RCU_COND_RESCHED_LIM;
+}
+
+/*
+ * Report quiscent states to RCU if it is time to do so.
+ */
+static inline void rcu_cond_resched(void)
+{
+	if (unlikely(rcu_should_resched()))
+		rcu_resched();
+}
+
+/*
  * Infrastructure to implement the synchronize_() primitives in
  * TREE_RCU and rcu_barrier_() primitives in TINY_RCU.
  */
kernel/rcu/update.c +18 -0
index 4c0a9b0af469..ed7a0d72562c 100644
@@ -338,3 +338,21 @@ static int __init check_cpu_stall_init(void)
 early_initcall(check_cpu_stall_init);
 
 #endif /* #ifdef CONFIG_RCU_STALL_COMMON */
+
+/*
+ * Hooks for cond_resched() and friends to avoid RCU CPU stall warnings.
+ */
+
+DEFINE_PER_CPU(int, rcu_cond_resched_count);
+
+/*
+ * Report a set of RCU quiescent states, for use by cond_resched()
+ * and friends.  Out of line due to being called infrequently.
+ */
+void rcu_resched(void)
+{
+	preempt_disable();
+	__this_cpu_write(rcu_cond_resched_count, 0);
+	rcu_note_context_switch(smp_processor_id());
+	preempt_enable();
+}
kernel/sched/core.c +6 -1
index 268a45ea238c..9f530c9ed911 100644
@@ -4051,6 +4051,7 @@ static void __cond_resched(void)
 
 int __sched _cond_resched(void)
 {
+	rcu_cond_resched();
 	if (should_resched()) {
 		__cond_resched();
 		return 1;
@@ -4069,15 +4070,18 @@ EXPORT_SYMBOL(_cond_resched);
  */
 int __cond_resched_lock(spinlock_t *lock)
 {
+	bool need_rcu_resched = rcu_should_resched();
 	int resched = should_resched();
 	int ret = 0;
 
 	lockdep_assert_held(lock);
 
-	if (spin_needbreak(lock) || resched) {
+	if (spin_needbreak(lock) || resched || need_rcu_resched) {
 		spin_unlock(lock);
 		if (resched)
 			__cond_resched();
+		else if (unlikely(need_rcu_resched))
+			rcu_resched();
 		else
 			cpu_relax();
 		ret = 1;
@@ -4091,6 +4095,7 @@ int __sched __cond_resched_softirq(void)
 {
 	BUG_ON(!in_softirq());
 
+	rcu_cond_resched();  /* BH disabled OK, just recording QSes. */
 	if (should_resched()) {
 		local_bh_enable();
 		__cond_resched();
Signature · 1 line
1.8.1.5
#40 lore raw

PATCH 19/45 rcutorture: Print negatives for SRCU counter wraparound

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The srcu_torture_stats() function prints SRCU's per-CPU c[] array with an unsigned format, which means that the number one less than zero is a very large number. This commit therefore prints this array with a signed format in order to improve readability of the rcutorture output.

---
 kernel/rcu/rcutorture.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/rcu/rcutorture.c +4 -3
index 3845ea99ccd4..0141fcff6bb9 100644
@@ -486,15 +486,16 @@ static void srcu_torture_barrier(void)
 
 static void srcu_torture_stats(char *page)
 {
+	long c0, c1;
 	int cpu;
 	int idx = srcu_ctl.completed & 0x1;
 
 	page += sprintf(page, "%s%s per-CPU(idx=%d):",
 		       torture_type, TORTURE_FLAG, idx);
 	for_each_possible_cpu(cpu) {
-		page += sprintf(page, " %d(%lu,%lu)", cpu,
-			       per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[!idx],
-			       per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[idx]);
+		c0 = (long)per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[!idx];
+		c1 = (long)per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[idx];
+		page += sprintf(page, " %d(%ld,%ld)", cpu, c0, c1);
 	}
 	sprintf(page, "\n");
 }
Signature · 1 line
1.8.1.5
#65 lore raw

PATCH 30/45 rcutorture: Make rcu_torture_reader() use cond_resched()

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The rcu_torture_reader() function currently uses schedule(). This commit therefore speeds things up a bit by substituting cond_resched(). This change makes rcu_torture_reader() more CPU-bound, so this commit also adjusts the number of readers (the "nreaders" module parameter, which feeds into the "nrealreaders" variable) to allow one CPU to be free of readers on SMP systems. The point of this is to increase the probability that readers will be watching while an updater makes a change.

---
 kernel/rcu/rcutorture.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
kernel/rcu/rcutorture.c +7 -4
index 15af04177e7e..ea8af005ea3f 100644
@@ -941,7 +941,7 @@ rcu_torture_reader(void *arg)
 		__this_cpu_inc(rcu_torture_batch[completed]);
 		preempt_enable();
 		cur_ops->readunlock(idx);
-		schedule();
+		cond_resched();
 		stutter_wait("rcu_torture_reader");
 	} while (!torture_must_stop());
 	if (irqreader && cur_ops->irq_capable)
@@ -1481,10 +1481,13 @@ rcu_torture_init(void)
 	if (cur_ops->init)
 		cur_ops->init(); /* no "goto unwind" prior to this point!!! */
 
-	if (nreaders >= 0)
+	if (nreaders >= 0) {
 		nrealreaders = nreaders;
-	else
-		nrealreaders = 2 * num_online_cpus();
+	} else {
+		nrealreaders = num_online_cpus() - 1;
+		if (nrealreaders <= 0)
+			nrealreaders = 1;
+	}
 	rcu_torture_print_module_parms(cur_ops, "Start of test");
 
 	/* Set up the freelist. */
Signature · 1 line
1.8.1.5
#59 lore raw

PATCH 26/45 torture: Dump ftrace buffer when the RCU grace period stalls

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit adds a call to rcutorture_trace_dump() to dump the ftrace buffer when the RCU grace period stalls in order to help debug the stall. Note that this is different than the RCU CPU stall warning, as it is rcutorture detecting the stall rather than the underlying RCU implementation.

---
 kernel/rcu/rcutorture.c | 1 +
 1 file changed, 1 insertion(+)
kernel/rcu/rcutorture.c +1 -0
index 0141fcff6bb9..50c26a7b6d97 100644
@@ -1033,6 +1033,7 @@ rcu_torture_printk(char *page)
 				"??? Writer stall state %d g%lu c%lu f%#x\n",
 				rcu_torture_writer_state,
 				gpnum, completed, flags);
+		rcutorture_trace_dump();
 	}
 	rtcv_snap = rcu_torture_current_version;
 }
Signature · 1 line
1.8.1.5
#18 lore raw

PATCH 9/45 torture: Rename RCU_BOOTARGS to TORTURE_BOOTARGS

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit makes the torture scripts a bit more RCU-independent.

---
 tools/testing/selftests/rcutorture/bin/kvm.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm.sh +3 -3
index 04ad1f980dfe..08c90cba79d2 100644
@@ -77,7 +77,7 @@ do
 	case "$1" in
 	--bootargs)
 		checkarg --bootargs "(list of kernel boot arguments)" "$#" "$2" '.*' '^--'
-		RCU_BOOTARGS="$2"
+		TORTURE_BOOTARGS="$2"
 		shift
 		;;
 	--buildonly)
@@ -275,7 +275,7 @@ awk < $T/cfgcpu.pack \
 	-v rd=$resdir/$ds/ \
 	-v dur=$dur \
 	-v RCU_QEMU_ARG=$RCU_QEMU_ARG \
-	-v RCU_BOOTARGS=$RCU_BOOTARGS \
+	-v TORTURE_BOOTARGS=$TORTURE_BOOTARGS \
 'BEGIN {
 	i = 0;
 }
@@ -312,7 +312,7 @@ function dump(first, pastlast)
 		print "touch " builddir ".wait";
 		print "mkdir " builddir " > /dev/null 2>&1 || :";
 		print "mkdir " rd cfr[jn] " || :";
-		print "kvm-test-1-run.sh " CONFIGDIR cf[j], builddir, rd cfr[jn], dur " \"" RCU_QEMU_ARG "\" \"" RCU_BOOTARGS "\" > " rd cfr[jn]  "/kvm-test-1-run.sh.out 2>&1 &"
+		print "kvm-test-1-run.sh " CONFIGDIR cf[j], builddir, rd cfr[jn], dur " \"" RCU_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`";
 		print "echo ", cfr[jn], cpusr[jn] ovf ": Waiting for build to complete. `date` >> " rd "/log";
 		print "while test -f " builddir ".wait"
Signature · 1 line
1.8.1.5
#35 lore raw

PATCH 16/45 rcutorture: Mark function as static in kernel/rcu/torture.c

In reply to Paul E. McKenney

From: Rashika Kheria <[email protected]>

Mark functions as static in kernel/rcu/torture.c because they are not used outside this file.

This eliminates the following warning in kernel/rcu/torture.c:
kernel/rcu/torture.c:902:6: warning: no previous prototype for ‘rcutorture_trace_dump’ [-Wmissing-prototypes] kernel/rcu/torture.c:1572:6: warning: no previous prototype for ‘rcu_torture_barrier_cbf’ [-Wmissing-prototypes]

---
 kernel/rcu/rcutorture.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/rcutorture.c +2 -2
index 1110db210318..3845ea99ccd4 100644
@@ -806,7 +806,7 @@ rcu_torture_fakewriter(void *arg)
 	return 0;
 }
 
-void rcutorture_trace_dump(void)
+static void rcutorture_trace_dump(void)
 {
 	static atomic_t beenhere = ATOMIC_INIT(0);
 
@@ -1183,7 +1183,7 @@ static int __init rcu_torture_stall_init(void)
 }
 
 /* Callback function for RCU barrier testing. */
-void rcu_torture_barrier_cbf(struct rcu_head *rcu)
+static void rcu_torture_barrier_cbf(struct rcu_head *rcu)
 {
 	atomic_inc(&barrier_cbs_invoked);
 }
Signature · 1 line
1.8.1.5
#60 lore raw

PATCH 27/45 rcutorture: Export RCU grace-period kthread wait state to rcutorture

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit allows rcutorture to print additional state for the RCU grace-period kthreads in cases where RCU seems reluctant to start a new grace period.

---
 include/linux/rcutiny.h |  4 ++++
 include/linux/rcutree.h |  1 +
 kernel/rcu/rcutorture.c |  1 +
 kernel/rcu/tree.c       | 17 +++++++++++++++++
 kernel/rcu/tree.h       |  8 +++++++-
 5 files changed, 30 insertions(+), 1 deletion(-)
include/linux/rcutiny.h +4 -0
index 425c659d54e5..d40a6a451330 100644
@@ -119,6 +119,10 @@ static inline void rcu_sched_force_quiescent_state(void)
 {
 }
 
+static inline void show_rcu_gp_kthreads(void)
+{
+}
+
 static inline void rcu_cpu_stall_reset(void)
 {
 }
include/linux/rcutree.h +1 -0
index a59ca05fd4e3..3e2f5d432743 100644
@@ -84,6 +84,7 @@ extern unsigned long rcutorture_vernum;
 long rcu_batches_completed(void);
 long rcu_batches_completed_bh(void);
 long rcu_batches_completed_sched(void);
+void show_rcu_gp_kthreads(void);
 
 void rcu_force_quiescent_state(void);
 void rcu_bh_force_quiescent_state(void);
kernel/rcu/rcutorture.c +1 -0
index 50c26a7b6d97..15af04177e7e 100644
@@ -1033,6 +1033,7 @@ rcu_torture_printk(char *page)
 				"??? Writer stall state %d g%lu c%lu f%#x\n",
 				rcu_torture_writer_state,
 				gpnum, completed, flags);
+		show_rcu_gp_kthreads();
 		rcutorture_trace_dump();
 	}
 	rtcv_snap = rcu_torture_current_version;
kernel/rcu/tree.c +17 -0
index 032106df7391..3107bd935b2b 100644
@@ -280,6 +280,21 @@ void rcu_bh_force_quiescent_state(void)
 EXPORT_SYMBOL_GPL(rcu_bh_force_quiescent_state);
 
 /*
+ * Show the state of the grace-period kthreads.
+ */
+void show_rcu_gp_kthreads(void)
+{
+	struct rcu_state *rsp;
+
+	for_each_rcu_flavor(rsp) {
+		pr_info("%s: wait state: %d ->state: %#lx\n",
+			rsp->name, rsp->gp_state, rsp->gp_kthread->state);
+		/* sched_show_task(rsp->gp_kthread); */
+	}
+}
+EXPORT_SYMBOL_GPL(show_rcu_gp_kthreads);
+
+/*
  * Record the number of times rcutorture tests have been initiated and
  * terminated.  This information allows the debugfs tracing stats to be
  * correlated to the rcutorture messages, even when the rcutorture module
@@ -1611,6 +1626,7 @@ static int __noreturn rcu_gp_kthread(void *arg)
 			trace_rcu_grace_period(rsp->name,
 					       ACCESS_ONCE(rsp->gpnum),
 					       TPS("reqwait"));
+			rsp->gp_state = RCU_GP_WAIT_GPS;
 			wait_event_interruptible(rsp->gp_wq,
 						 ACCESS_ONCE(rsp->gp_flags) &
 						 RCU_GP_FLAG_INIT);
@@ -1638,6 +1654,7 @@ static int __noreturn rcu_gp_kthread(void *arg)
 			trace_rcu_grace_period(rsp->name,
 					       ACCESS_ONCE(rsp->gpnum),
 					       TPS("fqswait"));
+			rsp->gp_state = RCU_GP_WAIT_FQS;
 			ret = wait_event_interruptible_timeout(rsp->gp_wq,
 					((gf = ACCESS_ONCE(rsp->gp_flags)) &
 					 RCU_GP_FLAG_FQS) ||
kernel/rcu/tree.h +7 -1
index 75dc3c39a02a..c2fd1e722879 100644
@@ -406,7 +406,8 @@ struct rcu_state {
 	unsigned long completed;		/* # of last completed gp. */
 	struct task_struct *gp_kthread;		/* Task for grace periods. */
 	wait_queue_head_t gp_wq;		/* Where GP task waits. */
-	int gp_flags;				/* Commands for GP task. */
+	short gp_flags;				/* Commands for GP task. */
+	short gp_state;				/* GP kthread sleep state. */
 
 	/* End of fields guarded by root rcu_node's lock. */
 
@@ -469,6 +470,11 @@ struct rcu_state {
 #define RCU_GP_FLAG_INIT 0x1	/* Need grace-period initialization. */
 #define RCU_GP_FLAG_FQS  0x2	/* Need grace-period quiescent-state forcing. */
 
+/* Values for rcu_state structure's gp_flags field. */
+#define RCU_GP_WAIT_INIT 0	/* Initial state. */
+#define RCU_GP_WAIT_GPS  1	/* Wait for grace-period start. */
+#define RCU_GP_WAIT_FQS  2	/* Wait for force-quiescent-state time. */
+
 extern struct list_head rcu_struct_flavors;
 
 /* Sequence through rcu_state structures for each RCU flavor. */
Signature · 1 line
1.8.1.5
#50 lore raw

PATCH 21/45 torture: Report diagnostics from qemu

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The current script does record qemu diagnostics, but the user has to know where to look for them. This commit therefore puts them into the Warnings file so that kvm-recheck.sh will display them. This change is especially useful if you are in the habit of killing the qemu process when you realize that you messed something up, but then later on wonder why the process terminated early.

---
 tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +9 -1
index 86e6ffe6df45..7848227aa4c1 100755
@@ -157,7 +157,7 @@ then
 	echo Build-only run specified, boot/test omitted.
 	exit 0
 fi
-$QEMU $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append "$qemu_append $boot_args" &
+$QEMU $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append "$qemu_append $boot_args"; echo $? > $resdir/qemu-retval &
 qemu_pid=$!
 commandcompleted=0
 echo Monitoring qemu job at pid $qemu_pid
@@ -172,6 +172,14 @@ do
 		if test $kruntime -lt $seconds
 		then
 			echo Completed in $kruntime vs. $seconds >> $resdir/Warnings 2>&1
+			grep "^(qemu) qemu:" $resdir/kvm-test-1-run.sh.out >> $resdir/Warnings 2>&1
+			killpid="`grep "^(qemu) qemu: terminating on signal [0-9]* from pid" $resdir/kvm-test-1-run.sh.out`"
+			if test -n "$killpid"
+			then
+				pscmd="`echo $killpid | sed -e 's/^.*from pid/ps -ef | grep/'`"
+				echo $pscmd >> $resdir/Warnings
+				echo $pscmd | sh >> $resdir/Warnings 2>&1
+			fi
 		else
 			echo ' ---' `date`: Kernel done
 		fi
Signature · 1 line
1.8.1.5
#63 lore raw

PATCH 28/45 percpu: Fix raw_cpu_inc_return()

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The definition for raw_cpu_add_return() uses the operation prefix "raw_add_return_", but the definitions in the various percpu.h files expect "raw_cpu_add_return_". This commit therefore appropriately adjusts the definition of raw_cpu_add_return().

---
 include/linux/percpu.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/percpu.h +1 -1
index e7a0b95ed527..495c6543a8f2 100644
@@ -639,7 +639,7 @@ do {									\
 #  define raw_cpu_add_return_8(pcp, val)	raw_cpu_generic_add_return(pcp, val)
 # endif
 # define raw_cpu_add_return(pcp, val)	\
-	__pcpu_size_call_return2(raw_add_return_, pcp, val)
+	__pcpu_size_call_return2(raw_cpu_add_return_, pcp, val)
 #endif
 
 #define raw_cpu_sub_return(pcp, val)	raw_cpu_add_return(pcp, -(typeof(pcp))(val))
Signature · 1 line
1.8.1.5
#36 lore raw

PATCH 17/45 torture: Make "--dryrun script" output self-sufficient

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The scripts produced by kvm.sh's "--dryrun script" argument were intended for debugging rather than to run, but it is easier to debug if the script output matches exactly what is run. This commit therefore makes this script runnable.

---
 tools/testing/selftests/rcutorture/bin/kvm.sh | 60 ++++++++++++---------------
 1 file changed, 27 insertions(+), 33 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm.sh +27 -33
index ea59e2950f14..8aa62a2dccb5 100644
@@ -175,30 +175,6 @@ then
 	resdir=$KVM/res
 fi
 
-if test "$dryrun" = ""
-then
-	if ! test -e $resdir
-	then
-		mkdir -p "$resdir" || :
-	fi
-	mkdir $resdir/$ds
-
-	# Be noisy only if running the script.
-	echo Results directory: $resdir/$ds
-	echo $scriptname $args
-
-	touch $resdir/$ds/log
-	echo $scriptname $args >> $resdir/$ds/log
-	echo ${TORTURE_SUITE} > $resdir/$ds/TORTURE_SUITE
-
-	pwd > $resdir/$ds/testid.txt
-	if test -d .git
-	then
-		git status >> $resdir/$ds/testid.txt
-		git rev-parse HEAD >> $resdir/$ds/testid.txt
-	fi
-fi
-
 # Create a file of test-name/#cpus pairs, sorted by decreasing #cpus.
 touch $T/cfgcpu
 for CF in $configs
@@ -267,6 +243,22 @@ END {
 cat << ___EOF___ > $T/script
 TORTURE_SUITE="$TORTURE_SUITE"; export TORTURE_SUITE
 TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG
+if ! test -e $resdir
+then
+	mkdir -p "$resdir" || :
+fi
+mkdir $resdir/$ds
+echo Results directory: $resdir/$ds
+echo $scriptname $args
+touch $resdir/$ds/log
+echo $scriptname $args >> $resdir/$ds/log
+echo ${TORTURE_SUITE} > $resdir/$ds/TORTURE_SUITE
+pwd > $resdir/$ds/testid.txt
+if test -d .git
+then
+	git status >> $resdir/$ds/testid.txt
+	git rev-parse HEAD >> $resdir/$ds/testid.txt
+fi
 ___EOF___
 awk < $T/cfgcpu.pack \
 	-v CONFIGDIR="$CONFIGFRAG/$kversion/" \
@@ -366,6 +358,17 @@ END {
 		dump(first, i);
 }' >> $T/script
 
+cat << ___EOF___ >> $T/script
+echo
+echo
+echo " --- `date` Test summary:"
+echo Results directory: $resdir/$ds
+if test -z "$TORTURE_BUILDONLY"
+then
+	kvm-recheck.sh $resdir/$ds
+fi
+___EOF___
+
 if test "$dryrun" = script
 then
 	# Dump out the script, but define the environment variables that
@@ -398,12 +401,3 @@ else
 fi
 
 # Tracing: trace_event=rcu:rcu_grace_period,rcu:rcu_future_grace_period,rcu:rcu_grace_period_init,rcu:rcu_nocb_wake,rcu:rcu_preempt_task,rcu:rcu_unlock_preempted_task,rcu:rcu_quiescent_state_report,rcu:rcu_fqs,rcu:rcu_callback,rcu:rcu_kfree_callback,rcu:rcu_batch_start,rcu:rcu_invoke_callback,rcu:rcu_invoke_kfree_callback,rcu:rcu_batch_end,rcu:rcu_torture_read,rcu:rcu_barrier
-
-echo
-echo
-echo " --- `date` Test summary:"
-echo Results directory: $resdir/$ds
-if test -n "$TORTURE_BUILDONLY"
-then
-	kvm-recheck.sh $resdir/$ds
-fi
Signature · 1 line
1.8.1.5
#4 lore raw

PATCH 4/45 torture: Make parse-rcutorture.sh less RCU-specific

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

It can be a bit jarring to see a locking test complain about RCU, so this commit renames parse-rcutorture.sh to parse-torture.sh and makes the messages it emits more generic.

---
 .../selftests/rcutorture/bin/kvm-recheck.sh        |   2 +-
 .../selftests/rcutorture/bin/kvm-test-1-run.sh     |   2 +-
 .../selftests/rcutorture/bin/parse-rcutorture.sh   | 106 ---------------------
 .../selftests/rcutorture/bin/parse-torture.sh      | 106 +++++++++++++++++++++
 4 files changed, 108 insertions(+), 108 deletions(-)
 delete mode 100755 tools/testing/selftests/rcutorture/bin/parse-rcutorture.sh
 create mode 100755 tools/testing/selftests/rcutorture/bin/parse-torture.sh
tools/testing/selftests/rcutorture/bin/kvm-recheck.sh +1 -1
index a44daaa259a9..26d78b7eaccf 100755
@@ -41,7 +41,7 @@ do
 		kvm-recheck-${TORTURE_SUITE}.sh $i
 		configcheck.sh $i/.config $i/ConfigFragment
 		parse-build.sh $i/Make.out $configfile
-		parse-rcutorture.sh $i/console.log $configfile
+		parse-torture.sh $i/console.log $configfile
 		parse-console.sh $i/console.log $configfile
 		if test -r $i/Warnings
 		then
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +1 -1
index 94b28bb37d36..e82f4f201c8c 100755
@@ -199,5 +199,5 @@ then
 fi
 
 cp $builddir/console.log $resdir
-parse-${TORTURE_SUITE}torture.sh $resdir/console.log $title
+parse-torture.sh $resdir/console.log $title
 parse-console.sh $resdir/console.log $title
tools/testing/selftests/rcutorture/bin/parse-rcutorture.sh deleted +0 -106

106 lines not on this page · raw message

tools/testing/selftests/rcutorture/bin/parse-torture.sh new file +106 -0

106 lines not on this page · raw message

Signature · 1 line
1.8.1.5
#27 lore raw

PATCH 12/45 torture: Rename RCU_QEMU_MAC to TORTURE_QEMU_MAC

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit makes the torture scripts a bit more RCU-independent.

---
 tools/testing/selftests/rcutorture/bin/functions.sh | 6 +++---
 tools/testing/selftests/rcutorture/bin/kvm.sh       | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)
tools/testing/selftests/rcutorture/bin/functions.sh +3 -3
index 623939cf814e..41fb52b805e4 100644
@@ -124,7 +124,7 @@ identify_qemu_append () {
 
 # identify_qemu_args qemu-cmd serial-file
 #
-# Output arguments for qemu arguments based on the RCU_QEMU_MAC
+# Output arguments for qemu arguments based on the TORTURE_QEMU_MAC
 # and TORTURE_QEMU_INTERACTIVE environment variables.
 identify_qemu_args () {
 	case "$1" in
@@ -133,9 +133,9 @@ identify_qemu_args () {
 	qemu-system-ppc64)
 		echo -enable-kvm -M pseries -cpu POWER7 -nodefaults
 		echo -device spapr-vscsi
-		if test -n "$TORTURE_QEMU_INTERACTIVE" -a -n "$RCU_QEMU_MAC"
+		if test -n "$TORTURE_QEMU_INTERACTIVE" -a -n "$TORTURE_QEMU_MAC"
 		then
-			echo -device spapr-vlan,netdev=net0,mac=$RCU_QEMU_MAC
+			echo -device spapr-vlan,netdev=net0,mac=$TORTURE_QEMU_MAC
 			echo -netdev bridge,br=br0,id=net0
 		elif test -n "$TORTURE_QEMU_INTERACTIVE"
 		then
tools/testing/selftests/rcutorture/bin/kvm.sh +2 -2
index 2f9605ed5b58..1a4a68c76914 100644
@@ -128,7 +128,7 @@ do
 		;;
 	--mac)
 		checkarg --mac "(MAC address)" $# "$2" '^\([0-9a-fA-F]\{2\}:\)\{5\}[0-9a-fA-F]\{2\}$' error
-		RCU_QEMU_MAC=$2; export RCU_QEMU_MAC
+		TORTURE_QEMU_MAC=$2; export TORTURE_QEMU_MAC
 		shift
 		;;
 	--no-initrd)
@@ -380,7 +380,7 @@ then
 	echo RCU_QEMU_CMD="$RCU_QEMU_CMD; export RCU_QEMU_CMD"
 	echo TORTURE_QEMU_INTERACTIVE="$TORTURE_QEMU_INTERACTIVE;
 		export TORTURE_QEMU_INTERACTIVE"
-	echo RCU_QEMU_MAC="$RCU_QEMU_MAC; export RCU_QEMU_MAC"
+	echo TORTURE_QEMU_MAC="$TORTURE_QEMU_MAC; export TORTURE_QEMU_MAC"
 	echo "mkdir -p "$resdir" || :"
 	echo "mkdir $resdir/$ds"
 	cat $T/script
Signature · 1 line
1.8.1.5
#30 lore raw

PATCH 13/45 torture: Rename RCU_QEMU_ARG to TORTURE_QEMU_ARG

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit makes the torture scripts a bit more RCU-independent.

---
 tools/testing/selftests/rcutorture/bin/kvm.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm.sh +3 -3
index 1a4a68c76914..d397ecc55293 100644
@@ -136,7 +136,7 @@ do
 		;;
 	--qemu-args)
 		checkarg --qemu-args "-qemu args" $# "$2" '^-' '^error'
-		RCU_QEMU_ARG="$2"
+		TORTURE_QEMU_ARG="$2"
 		shift
 		;;
 	--qemu-cmd)
@@ -274,7 +274,7 @@ awk < $T/cfgcpu.pack \
 	-v ncpus=$cpus \
 	-v rd=$resdir/$ds/ \
 	-v dur=$dur \
-	-v RCU_QEMU_ARG=$RCU_QEMU_ARG \
+	-v TORTURE_QEMU_ARG=$TORTURE_QEMU_ARG \
 	-v TORTURE_BOOTARGS=$TORTURE_BOOTARGS \
 'BEGIN {
 	i = 0;
@@ -312,7 +312,7 @@ function dump(first, pastlast)
 		print "touch " builddir ".wait";
 		print "mkdir " builddir " > /dev/null 2>&1 || :";
 		print "mkdir " rd cfr[jn] " || :";
-		print "kvm-test-1-run.sh " CONFIGDIR cf[j], builddir, rd cfr[jn], dur " \"" RCU_QEMU_ARG "\" \"" TORTURE_BOOTARGS "\" > " rd cfr[jn]  "/kvm-test-1-run.sh.out 2>&1 &"
+		print "kvm-test-1-run.sh " CONFIGDIR cf[j], builddir, 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`";
 		print "echo ", cfr[jn], cpusr[jn] ovf ": Waiting for build to complete. `date` >> " rd "/log";
 		print "while test -f " builddir ".wait"
Signature · 1 line
1.8.1.5
#22 lore raw

PATCH 11/45 torture: Rename RCU_QEMU_INTERACTIVE to TORTURE_QEMU_INTERACTIVE

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit makes the torture scripts a bit more RCU-independent.

---
 tools/testing/selftests/rcutorture/bin/functions.sh | 12 ++++++------
 tools/testing/selftests/rcutorture/bin/kvm.sh       |  5 +++--
 2 files changed, 9 insertions(+), 8 deletions(-)
tools/testing/selftests/rcutorture/bin/functions.sh +6 -6
index 9b17e810ddc3..623939cf814e 100644
@@ -107,14 +107,14 @@ identify_qemu () {
 # identify_qemu_append qemu-cmd
 #
 # Output arguments for the qemu "-append" string based on CPU type
-# and the RCU_QEMU_INTERACTIVE environment variable.
+# and the TORTURE_QEMU_INTERACTIVE environment variable.
 identify_qemu_append () {
 	case "$1" in
 	qemu-system-x86_64|qemu-system-i386)
 		echo noapic selinux=0 initcall_debug debug
 		;;
 	esac
-	if test -n "$RCU_QEMU_INTERACTIVE"
+	if test -n "$TORTURE_QEMU_INTERACTIVE"
 	then
 		echo root=/dev/sda
 	else
@@ -125,7 +125,7 @@ identify_qemu_append () {
 # identify_qemu_args qemu-cmd serial-file
 #
 # Output arguments for qemu arguments based on the RCU_QEMU_MAC
-# and RCU_QEMU_INTERACTIVE environment variables.
+# and TORTURE_QEMU_INTERACTIVE environment variables.
 identify_qemu_args () {
 	case "$1" in
 	qemu-system-x86_64|qemu-system-i386)
@@ -133,17 +133,17 @@ identify_qemu_args () {
 	qemu-system-ppc64)
 		echo -enable-kvm -M pseries -cpu POWER7 -nodefaults
 		echo -device spapr-vscsi
-		if test -n "$RCU_QEMU_INTERACTIVE" -a -n "$RCU_QEMU_MAC"
+		if test -n "$TORTURE_QEMU_INTERACTIVE" -a -n "$RCU_QEMU_MAC"
 		then
 			echo -device spapr-vlan,netdev=net0,mac=$RCU_QEMU_MAC
 			echo -netdev bridge,br=br0,id=net0
-		elif test -n "$RCU_QEMU_INTERACTIVE"
+		elif test -n "$TORTURE_QEMU_INTERACTIVE"
 		then
 			echo -net nic -net user
 		fi
 		;;
 	esac
-	if test -n "$RCU_QEMU_INTERACTIVE"
+	if test -n "$TORTURE_QEMU_INTERACTIVE"
 	then
 		echo -monitor stdio -serial pty -S
 	else
tools/testing/selftests/rcutorture/bin/kvm.sh +3 -2
index 73c586f6bdf6..2f9605ed5b58 100644
@@ -114,7 +114,7 @@ do
 		shift
 		;;
 	--interactive)
-		RCU_QEMU_INTERACTIVE=1; export RCU_QEMU_INTERACTIVE
+		TORTURE_QEMU_INTERACTIVE=1; export TORTURE_QEMU_INTERACTIVE
 		;;
 	--kmake-arg)
 		checkarg --kmake-arg "(kernel make arguments)" $# "$2" '.*' '^error$'
@@ -378,7 +378,8 @@ then
 	echo TORTURE_INITRD="$TORTURE_INITRD; export TORTURE_INITRD"
 	echo TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG; export TORTURE_KMAKE_ARG"
 	echo RCU_QEMU_CMD="$RCU_QEMU_CMD; export RCU_QEMU_CMD"
-	echo RCU_QEMU_INTERACTIVE="$RCU_QEMU_INTERACTIVE; export RCU_QEMU_INTERACTIVE"
+	echo TORTURE_QEMU_INTERACTIVE="$TORTURE_QEMU_INTERACTIVE;
+		export TORTURE_QEMU_INTERACTIVE"
 	echo RCU_QEMU_MAC="$RCU_QEMU_MAC; export RCU_QEMU_MAC"
 	echo "mkdir -p "$resdir" || :"
 	echo "mkdir $resdir/$ds"
Signature · 1 line
1.8.1.5
#6 lore raw

PATCH 6/45 torture: Intensify locking test

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The current lock_torture_writer() spends too much time sleeping and not enough time hammering locks, as in an eight-CPU test will often only be utilizing a CPU or two. This commit therefore makes lock_torture_writer() sleep less and hammer more.

---
 kernel/locking/locktorture.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/locking/locktorture.c +2 -1
index f26b1a18e34e..b0d3e3c50672 100644
@@ -219,7 +219,8 @@ static int lock_torture_writer(void *arg)
 	set_user_nice(current, 19);
 
 	do {
-		schedule_timeout_uninterruptible(1);
+		if ((torture_random(&rand) & 0xfffff) == 0)
+			schedule_timeout_uninterruptible(1);
 		cur_ops->writelock();
 		if (WARN_ON_ONCE(lock_is_write_held))
 			lwsp->n_write_lock_fail++;
Signature · 1 line
1.8.1.5
#5 lore raw

PATCH 5/45 torture: Rename RCU_INITRD to TORTURE_INITRD

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit makes the torture scripts a bit more RCU-independent.

---
 tools/testing/selftests/rcutorture/bin/kvm-build.sh | 2 +-
 tools/testing/selftests/rcutorture/bin/kvm.sh       | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-build.sh +1 -1
index 197901ec10bf..d8e68a5e4411 100755
@@ -47,7 +47,7 @@ mkdir $T
 
 cat ${config_template} | grep -v CONFIG_RCU_TORTURE_TEST > $T/config
 cat << ___EOF___ >> $T/config
-CONFIG_INITRAMFS_SOURCE="$RCU_INITRD"
+CONFIG_INITRAMFS_SOURCE="$TORTURE_INITRD"
 CONFIG_VIRTIO_PCI=y
 CONFIG_VIRTIO_CONSOLE=y
 ___EOF___
tools/testing/selftests/rcutorture/bin/kvm.sh +3 -3
index 740676255c6a..a52a077ee258 100644
@@ -38,7 +38,7 @@ dur=30
 dryrun=""
 KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
 PATH=${KVM}/bin:$PATH; export PATH
-RCU_INITRD="$KVM/initrd"; export RCU_INITRD
+TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
 RCU_KMAKE_ARG=""; export RCU_KMAKE_ARG
 TORTURE_SUITE=rcu
 resdir=""
@@ -125,7 +125,7 @@ do
 		shift
 		;;
 	--no-initrd)
-		RCU_INITRD=""; export RCU_INITRD
+		TORTURE_INITRD=""; export TORTURE_INITRD
 		;;
 	--qemu-args)
 		checkarg --qemu-args "-qemu args" $# "$2" '^-' '^error'
@@ -367,7 +367,7 @@ then
 	echo KVPATH="$KVPATH; export KVPATH"
 	echo PATH="$PATH; export PATH"
 	echo RCU_BUILDONLY="$RCU_BUILDONLY; export RCU_BUILDONLY"
-	echo RCU_INITRD="$RCU_INITRD; export RCU_INITRD"
+	echo TORTURE_INITRD="$TORTURE_INITRD; export TORTURE_INITRD"
 	echo RCU_KMAKE_ARG="$RCU_KMAKE_ARG; export RCU_KMAKE_ARG"
 	echo RCU_QEMU_CMD="$RCU_QEMU_CMD; export RCU_QEMU_CMD"
 	echo RCU_QEMU_INTERACTIVE="$RCU_QEMU_INTERACTIVE; export RCU_QEMU_INTERACTIVE"
Signature · 1 line
1.8.1.5
#1 lore raw

PATCH 1/45 rcutorture: Add forward-progress checking for writer

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The rcutorture output currently does not distinguish between stalls in the RCU implementation and stalls in the rcu_torture_writer() kthreads. This commit therefore adds some diagnostics to help distinguish between these two conditions, at least for the non-SRCU implementations. (SRCU does not provide evidence of update-side forward progress by design.)

---
 include/linux/rcupdate.h | 19 +++++++++++++++++++
 kernel/rcu/rcutorture.c  | 37 +++++++++++++++++++++++++++++++++++++
 kernel/rcu/tree.c        | 18 ++++++++++++++++++
 3 files changed, 74 insertions(+)
include/linux/rcupdate.h +19 -0
index 00a7fd61b3c6..a6c3898e141e 100644
@@ -51,7 +51,17 @@ extern int rcu_expedited; /* for sysctl */
 extern int rcutorture_runnable; /* for sysctl */
 #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
 
+enum rcutorture_type {
+	RTORT_BUSTED,
+	RTORT_RCU,
+	RTORT_RCU_BH,
+	RTORT_RCU_SCHED,
+	RTORT_SRCU
+};
+
 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU)
+void rcutorture_get_gp_data(enum rcutorture_type test_type, int *flags,
+			    unsigned long *gpnum, unsigned long *completed);
 void rcutorture_record_test_transition(void);
 void rcutorture_record_progress(unsigned long vernum);
 void do_trace_rcu_torture_read(const char *rcutorturename,
@@ -60,6 +70,15 @@ void do_trace_rcu_torture_read(const char *rcutorturename,
 			       unsigned long c_old,
 			       unsigned long c);
 #else
+static inline void rcutorture_get_gp_data(enum rcutorture_type test_type,
+					  int *flags,
+					  unsigned long *gpnum,
+					  unsigned long *completed)
+{
+	*flags = 0;
+	*gpnum = 0;
+	*completed = 0;
+}
 static inline void rcutorture_record_test_transition(void)
 {
 }
kernel/rcu/rcutorture.c +37 -0
index bd30bc61bc05..1110db210318 100644
@@ -138,6 +138,15 @@ static long n_barrier_attempts;
 static long n_barrier_successes;
 static struct list_head rcu_torture_removed;
 
+static int rcu_torture_writer_state;
+#define RTWS_FIXED_DELAY	0
+#define RTWS_DELAY		1
+#define RTWS_REPLACE		2
+#define RTWS_DEF_FREE		3
+#define RTWS_EXP_SYNC		4
+#define RTWS_STUTTER		5
+#define RTWS_STOPPING		6
+
 #if defined(MODULE) || defined(CONFIG_RCU_TORTURE_TEST_RUNNABLE)
 #define RCUTORTURE_RUNNABLE_INIT 1
 #else
@@ -214,6 +223,7 @@ rcu_torture_free(struct rcu_torture *p)
  */
 
 struct rcu_torture_ops {
+	int ttype;
 	void (*init)(void);
 	int (*readlock)(void);
 	void (*read_delay)(struct torture_random_state *rrsp);
@@ -312,6 +322,7 @@ static void rcu_sync_torture_init(void)
 }
 
 static struct rcu_torture_ops rcu_ops = {
+	.ttype		= RTORT_RCU,
 	.init		= rcu_sync_torture_init,
 	.readlock	= rcu_torture_read_lock,
 	.read_delay	= rcu_read_delay,
@@ -355,6 +366,7 @@ static void rcu_bh_torture_deferred_free(struct rcu_torture *p)
 }
 
 static struct rcu_torture_ops rcu_bh_ops = {
+	.ttype		= RTORT_RCU_BH,
 	.init		= rcu_sync_torture_init,
 	.readlock	= rcu_bh_torture_read_lock,
 	.read_delay	= rcu_read_delay,  /* just reuse rcu's version. */
@@ -397,6 +409,7 @@ call_rcu_busted(struct rcu_head *head, void (*func)(struct rcu_head *rcu))
 }
 
 static struct rcu_torture_ops rcu_busted_ops = {
+	.ttype		= RTORT_BUSTED,
 	.init		= rcu_sync_torture_init,
 	.readlock	= rcu_torture_read_lock,
 	.read_delay	= rcu_read_delay,  /* just reuse rcu's version. */
@@ -492,6 +505,7 @@ static void srcu_torture_synchronize_expedited(void)
 }
 
 static struct rcu_torture_ops srcu_ops = {
+	.ttype		= RTORT_SRCU,
 	.init		= rcu_sync_torture_init,
 	.readlock	= srcu_torture_read_lock,
 	.read_delay	= srcu_read_delay,
@@ -527,6 +541,7 @@ static void rcu_sched_torture_deferred_free(struct rcu_torture *p)
 }
 
 static struct rcu_torture_ops sched_ops = {
+	.ttype		= RTORT_RCU_SCHED,
 	.init		= rcu_sync_torture_init,
 	.readlock	= sched_torture_read_lock,
 	.read_delay	= rcu_read_delay,  /* just reuse rcu's version. */
@@ -699,12 +714,15 @@ rcu_torture_writer(void *arg)
 	set_user_nice(current, MAX_NICE);
 
 	do {
+		rcu_torture_writer_state = RTWS_FIXED_DELAY;
 		schedule_timeout_uninterruptible(1);
 		rp = rcu_torture_alloc();
 		if (rp == NULL)
 			continue;
 		rp->rtort_pipe_count = 0;
+		rcu_torture_writer_state = RTWS_DELAY;
 		udelay(torture_random(&rand) & 0x3ff);
+		rcu_torture_writer_state = RTWS_REPLACE;
 		old_rp = rcu_dereference_check(rcu_torture_current,
 					       current == writer_task);
 		rp->rtort_mbtest = 1;
@@ -721,8 +739,10 @@ rcu_torture_writer(void *arg)
 			else
 				exp = gp_exp;
 			if (!exp) {
+				rcu_torture_writer_state = RTWS_DEF_FREE;
 				cur_ops->deferred_free(old_rp);
 			} else {
+				rcu_torture_writer_state = RTWS_EXP_SYNC;
 				cur_ops->exp_sync();
 				list_add(&old_rp->rtort_free,
 					 &rcu_torture_removed);
@@ -743,8 +763,10 @@ rcu_torture_writer(void *arg)
 			}
 		}
 		rcutorture_record_progress(++rcu_torture_current_version);
+		rcu_torture_writer_state = RTWS_STUTTER;
 		stutter_wait("rcu_torture_writer");
 	} while (!torture_must_stop());
+	rcu_torture_writer_state = RTWS_STOPPING;
 	torture_kthread_stopping("rcu_torture_writer");
 	return 0;
 }
@@ -937,6 +959,7 @@ rcu_torture_printk(char *page)
 	int i;
 	long pipesummary[RCU_TORTURE_PIPE_LEN + 1] = { 0 };
 	long batchsummary[RCU_TORTURE_PIPE_LEN + 1] = { 0 };
+	static unsigned long rtcv_snap = ULONG_MAX;
 
 	for_each_possible_cpu(cpu) {
 		for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
@@ -997,6 +1020,20 @@ rcu_torture_printk(char *page)
 	page += sprintf(page, "\n");
 	if (cur_ops->stats)
 		cur_ops->stats(page);
+	if (rtcv_snap == rcu_torture_current_version &&
+	    rcu_torture_current != NULL) {
+		int __maybe_unused flags;
+		unsigned long __maybe_unused gpnum;
+		unsigned long __maybe_unused completed;
+
+		rcutorture_get_gp_data(cur_ops->ttype,
+				       &flags, &gpnum, &completed);
+		page += sprintf(page,
+				"??? Writer stall state %d g%lu c%lu f%#x\n",
+				rcu_torture_writer_state,
+				gpnum, completed, flags);
+	}
+	rtcv_snap = rcu_torture_current_version;
 }
 
 /*
kernel/rcu/tree.c +18 -0
index 0c47e300210a..032106df7391 100644
@@ -294,6 +294,24 @@ void rcutorture_record_test_transition(void)
 EXPORT_SYMBOL_GPL(rcutorture_record_test_transition);
 
 /*
+ * Send along grace-period-related data for rcutorture diagnostics.
+ */
+void rcutorture_get_gp_data(enum rcutorture_type test_type, int *flags,
+			    unsigned long *gpnum, unsigned long *completed)
+{
+	if (test_type == RTORT_SRCU || test_type == RTORT_BUSTED) {
+		*flags = 0;
+		*gpnum = 0;
+		*completed = 0;
+		return;
+	}
+	*flags = ACCESS_ONCE(rcu_state->gp_flags);
+	*gpnum = ACCESS_ONCE(rcu_state->gpnum);
+	*completed = ACCESS_ONCE(rcu_state->completed);
+}
+EXPORT_SYMBOL_GPL(rcutorture_get_gp_data);
+
+/*
  * Record the number of writer passes through the current rcutorture test.
  * This is also used to correlate debugfs tracing stats with the rcutorture
  * messages.
Signature · 1 line
1.8.1.5
#2 lore raw

PATCH 2/45 torture: Remove obsolete builddir options

From: "Paul E. McKenney" <[email protected]>

The --builddir and --relbuilddir options were initially intended to handle parallel tests. However, since commit 43e38ab3d518 (Enable concurrent rcutorture runs), the script manages multiple build directories as needed for parallel testing. This commit therefore removes these two obsolete options.

---
 tools/testing/selftests/rcutorture/bin/kvm.sh | 16 ----------------
 1 file changed, 16 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm.sh +0 -16
index 5a78cbf55f06..37a60ef70df3 100644
@@ -38,7 +38,6 @@ dur=30
 dryrun=""
 KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
 PATH=${KVM}/bin:$PATH; export PATH
-builddir="${KVM}/b1"
 RCU_INITRD="$KVM/initrd"; export RCU_INITRD
 RCU_KMAKE_ARG=""; export RCU_KMAKE_ARG
 TORTURE_SUITE=rcu
@@ -53,7 +52,6 @@ kversion=""
 usage () {
 	echo "Usage: $scriptname optional arguments:"
 	echo "       --bootargs kernel-boot-arguments"
-	echo "       --builddir absolute-pathname"
 	echo "       --buildonly"
 	echo "       --configs \"config-file list\""
 	echo "       --cpus N"
@@ -67,7 +65,6 @@ usage () {
 	echo "       --no-initrd"
 	echo "       --qemu-args qemu-system-..."
 	echo "       --qemu-cmd qemu-system-..."
-	echo "       --relbuilddir relative-pathname"
 	echo "       --results absolute-pathname"
 	echo "       --torture rcu"
 	exit 1
@@ -81,12 +78,6 @@ do
 		RCU_BOOTARGS="$2"
 		shift
 		;;
-	--builddir)
-		checkarg --builddir "(absolute pathname)" "$#" "$2" '^/' '^error'
-		builddir=$2
-		gotbuilddir=1
-		shift
-		;;
 	--buildonly)
 		RCU_BUILDONLY=1; export RCU_BUILDONLY
 		;;
@@ -146,13 +137,6 @@ do
 		RCU_QEMU_CMD="$2"; export RCU_QEMU_CMD
 		shift
 		;;
-	--relbuilddir)
-		checkarg --relbuilddir "(relative pathname)" "$#" "$2" '^[^/]*$' '^--'
-		relbuilddir=$2
-		gotrelbuilddir=1
-		builddir=${KVM}/${relbuilddir}
-		shift
-		;;
 	--results)
 		checkarg --results "(absolute pathname)" "$#" "$2" '^/' '^error'
 		resdir=$2
Signature · 1 line
1.8.1.5
#94 lore raw

Re: [PATCH tip/core/rcu 01/45] rcutorture: Add forward-progress checking for writer

In reply to Paul E. McKenney
Quoted 9 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The rcutorture output currently does not distinguish between stalls in the RCU implementation and stalls in the rcu_torture_writer() kthreads. This commit therefore adds some diagnostics to help distinguish between these two conditions, at least for the non-SRCU implementations. (SRCU does not provide evidence of update-side forward progress by design.)

The concept makes sense, and the writer state annotations seem like a useful debugging mechanism, but having RCU know about RCU torture types seems fundamentally wrong. This mechanism accesses rcu_state, which is already implementation-specific, so why not just only define the function for the RCU implementations that support it, and then have a function pointer in the torture-test structure to report a stall?

- Josh Triplett

Quoted 210 lines
 include/linux/rcupdate.h | 19 +++++++++++++++++++
 kernel/rcu/rcutorture.c  | 37 +++++++++++++++++++++++++++++++++++++
 kernel/rcu/tree.c        | 18 ++++++++++++++++++
 3 files changed, 74 insertions(+)
include/linux/rcupdate.h +19 -0
index 00a7fd61b3c6..a6c3898e141e 100644
@@ -51,7 +51,17 @@ extern int rcu_expedited; /* for sysctl */
 extern int rcutorture_runnable; /* for sysctl */
 #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
 
+enum rcutorture_type {
+	RTORT_BUSTED,
+	RTORT_RCU,
+	RTORT_RCU_BH,
+	RTORT_RCU_SCHED,
+	RTORT_SRCU
+};
+
 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU)
+void rcutorture_get_gp_data(enum rcutorture_type test_type, int *flags,
+			    unsigned long *gpnum, unsigned long *completed);
 void rcutorture_record_test_transition(void);
 void rcutorture_record_progress(unsigned long vernum);
 void do_trace_rcu_torture_read(const char *rcutorturename,
@@ -60,6 +70,15 @@ void do_trace_rcu_torture_read(const char *rcutorturename,
 			       unsigned long c_old,
 			       unsigned long c);
 #else
+static inline void rcutorture_get_gp_data(enum rcutorture_type test_type,
+					  int *flags,
+					  unsigned long *gpnum,
+					  unsigned long *completed)
+{
+	*flags = 0;
+	*gpnum = 0;
+	*completed = 0;
+}
 static inline void rcutorture_record_test_transition(void)
 {
 }
kernel/rcu/rcutorture.c +37 -0
index bd30bc61bc05..1110db210318 100644
@@ -138,6 +138,15 @@ static long n_barrier_attempts;
 static long n_barrier_successes;
 static struct list_head rcu_torture_removed;
 
+static int rcu_torture_writer_state;
+#define RTWS_FIXED_DELAY	0
+#define RTWS_DELAY		1
+#define RTWS_REPLACE		2
+#define RTWS_DEF_FREE		3
+#define RTWS_EXP_SYNC		4
+#define RTWS_STUTTER		5
+#define RTWS_STOPPING		6
+
 #if defined(MODULE) || defined(CONFIG_RCU_TORTURE_TEST_RUNNABLE)
 #define RCUTORTURE_RUNNABLE_INIT 1
 #else
@@ -214,6 +223,7 @@ rcu_torture_free(struct rcu_torture *p)
  */
 
 struct rcu_torture_ops {
+	int ttype;
 	void (*init)(void);
 	int (*readlock)(void);
 	void (*read_delay)(struct torture_random_state *rrsp);
@@ -312,6 +322,7 @@ static void rcu_sync_torture_init(void)
 }
 
 static struct rcu_torture_ops rcu_ops = {
+	.ttype		= RTORT_RCU,
 	.init		= rcu_sync_torture_init,
 	.readlock	= rcu_torture_read_lock,
 	.read_delay	= rcu_read_delay,
@@ -355,6 +366,7 @@ static void rcu_bh_torture_deferred_free(struct rcu_torture *p)
 }
 
 static struct rcu_torture_ops rcu_bh_ops = {
+	.ttype		= RTORT_RCU_BH,
 	.init		= rcu_sync_torture_init,
 	.readlock	= rcu_bh_torture_read_lock,
 	.read_delay	= rcu_read_delay,  /* just reuse rcu's version. */
@@ -397,6 +409,7 @@ call_rcu_busted(struct rcu_head *head, void (*func)(struct rcu_head *rcu))
 }
 
 static struct rcu_torture_ops rcu_busted_ops = {
+	.ttype		= RTORT_BUSTED,
 	.init		= rcu_sync_torture_init,
 	.readlock	= rcu_torture_read_lock,
 	.read_delay	= rcu_read_delay,  /* just reuse rcu's version. */
@@ -492,6 +505,7 @@ static void srcu_torture_synchronize_expedited(void)
 }
 
 static struct rcu_torture_ops srcu_ops = {
+	.ttype		= RTORT_SRCU,
 	.init		= rcu_sync_torture_init,
 	.readlock	= srcu_torture_read_lock,
 	.read_delay	= srcu_read_delay,
@@ -527,6 +541,7 @@ static void rcu_sched_torture_deferred_free(struct rcu_torture *p)
 }
 
 static struct rcu_torture_ops sched_ops = {
+	.ttype		= RTORT_RCU_SCHED,
 	.init		= rcu_sync_torture_init,
 	.readlock	= sched_torture_read_lock,
 	.read_delay	= rcu_read_delay,  /* just reuse rcu's version. */
@@ -699,12 +714,15 @@ rcu_torture_writer(void *arg)
 	set_user_nice(current, MAX_NICE);
 
 	do {
+		rcu_torture_writer_state = RTWS_FIXED_DELAY;
 		schedule_timeout_uninterruptible(1);
 		rp = rcu_torture_alloc();
 		if (rp == NULL)
 			continue;
 		rp->rtort_pipe_count = 0;
+		rcu_torture_writer_state = RTWS_DELAY;
 		udelay(torture_random(&rand) & 0x3ff);
+		rcu_torture_writer_state = RTWS_REPLACE;
 		old_rp = rcu_dereference_check(rcu_torture_current,
 					       current == writer_task);
 		rp->rtort_mbtest = 1;
@@ -721,8 +739,10 @@ rcu_torture_writer(void *arg)
 			else
 				exp = gp_exp;
 			if (!exp) {
+				rcu_torture_writer_state = RTWS_DEF_FREE;
 				cur_ops->deferred_free(old_rp);
 			} else {
+				rcu_torture_writer_state = RTWS_EXP_SYNC;
 				cur_ops->exp_sync();
 				list_add(&old_rp->rtort_free,
 					 &rcu_torture_removed);
@@ -743,8 +763,10 @@ rcu_torture_writer(void *arg)
 			}
 		}
 		rcutorture_record_progress(++rcu_torture_current_version);
+		rcu_torture_writer_state = RTWS_STUTTER;
 		stutter_wait("rcu_torture_writer");
 	} while (!torture_must_stop());
+	rcu_torture_writer_state = RTWS_STOPPING;
 	torture_kthread_stopping("rcu_torture_writer");
 	return 0;
 }
@@ -937,6 +959,7 @@ rcu_torture_printk(char *page)
 	int i;
 	long pipesummary[RCU_TORTURE_PIPE_LEN + 1] = { 0 };
 	long batchsummary[RCU_TORTURE_PIPE_LEN + 1] = { 0 };
+	static unsigned long rtcv_snap = ULONG_MAX;
 
 	for_each_possible_cpu(cpu) {
 		for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
@@ -997,6 +1020,20 @@ rcu_torture_printk(char *page)
 	page += sprintf(page, "\n");
 	if (cur_ops->stats)
 		cur_ops->stats(page);
+	if (rtcv_snap == rcu_torture_current_version &&
+	    rcu_torture_current != NULL) {
+		int __maybe_unused flags;
+		unsigned long __maybe_unused gpnum;
+		unsigned long __maybe_unused completed;
+
+		rcutorture_get_gp_data(cur_ops->ttype,
+				       &flags, &gpnum, &completed);
+		page += sprintf(page,
+				"??? Writer stall state %d g%lu c%lu f%#x\n",
+				rcu_torture_writer_state,
+				gpnum, completed, flags);
+	}
+	rtcv_snap = rcu_torture_current_version;
 }
 
 /*
kernel/rcu/tree.c +18 -0
index 0c47e300210a..032106df7391 100644
@@ -294,6 +294,24 @@ void rcutorture_record_test_transition(void)
 EXPORT_SYMBOL_GPL(rcutorture_record_test_transition);
 
 /*
+ * Send along grace-period-related data for rcutorture diagnostics.
+ */
+void rcutorture_get_gp_data(enum rcutorture_type test_type, int *flags,
+			    unsigned long *gpnum, unsigned long *completed)
+{
+	if (test_type == RTORT_SRCU || test_type == RTORT_BUSTED) {
+		*flags = 0;
+		*gpnum = 0;
+		*completed = 0;
+		return;
+	}
+	*flags = ACCESS_ONCE(rcu_state->gp_flags);
+	*gpnum = ACCESS_ONCE(rcu_state->gpnum);
+	*completed = ACCESS_ONCE(rcu_state->completed);
+}
+EXPORT_SYMBOL_GPL(rcutorture_get_gp_data);
+
+/*
  * Record the number of writer passes through the current rcutorture test.
  * This is also used to correlate debugfs tracing stats with the rcutorture
  * messages.
Signature · 1 line
1.8.1.5
#7 lore raw

Re: [PATCH tip/core/rcu 06/45] torture: Intensify locking test

In reply to Paul E. McKenney
Quoted 17 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The current lock_torture_writer() spends too much time sleeping and not enough time hammering locks, as in an eight-CPU test will often only be utilizing a CPU or two. This commit therefore makes lock_torture_writer() sleep less and hammer more.

---
 kernel/locking/locktorture.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/locking/locktorture.c +0 -0
index f26b1a18e34e..b0d3e3c50672 100644

kernel/locking/locktorture.c static int lock_torture_writer(void *arg) · line 223

Quoted 6 lines
kernel/locking/locktorture.c +2 -1
@@ -219,7 +219,8 @@ static int lock_torture_writer(void *arg)
 	set_user_nice(current, 19);
 
 	do {
-		schedule_timeout_uninterruptible(1);
+		if ((torture_random(&rand) & 0xfffff) == 0)
+			schedule_timeout_uninterruptible(1);

That's a one-in-1048576 chance of sleeping for a jiffy; is that frequent enough to even bother sleeping at all?

Quoted 6 lines
kernel/locking/locktorture.c +0 -0
 		cur_ops->writelock();
 		if (WARN_ON_ONCE(lock_is_write_held))
 			lwsp->n_write_lock_fail++;
Signature · 1 line
1.8.1.5
#10 lore raw

Re: [PATCH tip/core/rcu 07/45] torture: Allow variations of "defconfig" to be specified

In reply to Paul E. McKenney
Quoted 7 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Some environments require some variation on "make defconfig" to initialize the .config file. This commit therefore adds a --defconfig argument to allow this to be specified. The default value is of course "defconfig".

<bikeshed color="blue">
"--defconfig randconfig" or "--defconfig allyesconfig" or similar seems rather odd; how about calling it --kconfig or similar? </bikeshed>

Quoted 60 lines
 tools/testing/selftests/rcutorture/bin/configinit.sh | 2 +-
 tools/testing/selftests/rcutorture/bin/kvm.sh        | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/configinit.sh +1 -1
index a1be6e62add1..9c3f3d39b934 100755
@@ -62,7 +62,7 @@ grep '^grep' < $T/u.sh > $T/upd.sh
 echo "cat - $c" >> $T/upd.sh
 make mrproper
 make $buildloc distclean > $builddir/Make.distclean 2>&1
-make $buildloc defconfig > $builddir/Make.defconfig.out 2>&1
+make $buildloc $TORTURE_DEFCONFIG > $builddir/Make.defconfig.out 2>&1
 mv $builddir/.config $builddir/.config.sav
 sh $T/upd.sh < $builddir/.config.sav > $builddir/.config
 cp $builddir/.config $builddir/.config.new
tools/testing/selftests/rcutorture/bin/kvm.sh +8 -0
index a52a077ee258..59945b7793d9 100644
@@ -38,6 +38,7 @@ dur=30
 dryrun=""
 KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
 PATH=${KVM}/bin:$PATH; export PATH
+TORTURE_DEFCONFIG=defconfig
 TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
 RCU_KMAKE_ARG=""; export RCU_KMAKE_ARG
 TORTURE_SUITE=rcu
@@ -56,6 +57,7 @@ usage () {
 	echo "       --configs \"config-file list\""
 	echo "       --cpus N"
 	echo "       --datestamp string"
+	echo "       --defconfig string"
 	echo "       --dryrun sched|script"
 	echo "       --duration minutes"
 	echo "       --interactive"
@@ -96,6 +98,11 @@ do
 		ds=$2
 		shift
 		;;
+	--defconfig)
+		checkarg --defconfig "defconfigtype" "$#" "$2" '^[^/][^/]*$' '^--'
+		TORTURE_DEFCONFIG=$2
+		shift
+		;;
 	--dryrun)
 		checkarg --dryrun "sched|script" $# "$2" 'sched\|script' '^--'
 		dryrun=$2
@@ -259,6 +266,7 @@ END {
 # Generate a script to execute the tests in appropriate batches.
 cat << ___EOF___ > $T/script
 TORTURE_SUITE="$TORTURE_SUITE"; export TORTURE_SUITE
+TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG
 ___EOF___
 awk < $T/cfgcpu.pack \
 	-v CONFIGDIR="$CONFIGFRAG/$kversion/" \
Signature · 1 line
1.8.1.5
maintainer Reviewed-by on v1 8/45
#16 lore raw

Re: [PATCH tip/core/rcu 08/45] torture: Rename RCU_KMAKE_ARG to TORTURE_KMAKE_ARG

In reply to Paul E. McKenney
Quoted 3 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit makes the torture scripts a bit more RCU-independent.

You've also dropped unnecessary "export" calls; please document that in the commit message. With that change:

Quoted 1 line
Quoted 52 lines
---
 tools/testing/selftests/rcutorture/bin/kvm-build.sh | 2 +-
 tools/testing/selftests/rcutorture/bin/kvm.sh       | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-build.sh +1 -1
index d8e68a5e4411..e838c775f709 100755
@@ -60,7 +60,7 @@ then
 	exit 2
 fi
 ncpus=`cpus2use.sh`
-make O=$builddir -j$ncpus $RCU_KMAKE_ARG > $builddir/Make.out 2>&1
+make O=$builddir -j$ncpus $TORTURE_KMAKE_ARG > $builddir/Make.out 2>&1
 retval=$?
 if test $retval -ne 0 || grep "rcu[^/]*": < $builddir/Make.out | egrep -q "Stop|Error|error:|warning:" || egrep -q "Stop|Error|error:" < $builddir/Make.out
 then
tools/testing/selftests/rcutorture/bin/kvm.sh +3 -3
index 59945b7793d9..04ad1f980dfe 100644
@@ -40,7 +40,7 @@ KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
 PATH=${KVM}/bin:$PATH; export PATH
 TORTURE_DEFCONFIG=defconfig
 TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
-RCU_KMAKE_ARG=""; export RCU_KMAKE_ARG
+TORTURE_KMAKE_ARG=""
 TORTURE_SUITE=rcu
 resdir=""
 configs=""
@@ -118,7 +118,7 @@ do
 		;;
 	--kmake-arg)
 		checkarg --kmake-arg "(kernel make arguments)" $# "$2" '.*' '^error$'
-		RCU_KMAKE_ARG="$2"; export RCU_KMAKE_ARG
+		TORTURE_KMAKE_ARG="$2"
 		shift
 		;;
 	--kversion)
@@ -376,7 +376,7 @@ then
 	echo PATH="$PATH; export PATH"
 	echo RCU_BUILDONLY="$RCU_BUILDONLY; export RCU_BUILDONLY"
 	echo TORTURE_INITRD="$TORTURE_INITRD; export TORTURE_INITRD"
-	echo RCU_KMAKE_ARG="$RCU_KMAKE_ARG; export RCU_KMAKE_ARG"
+	echo TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG; export TORTURE_KMAKE_ARG"
 	echo RCU_QEMU_CMD="$RCU_QEMU_CMD; export RCU_QEMU_CMD"
 	echo RCU_QEMU_INTERACTIVE="$RCU_QEMU_INTERACTIVE; export RCU_QEMU_INTERACTIVE"
 	echo RCU_QEMU_MAC="$RCU_QEMU_MAC; export RCU_QEMU_MAC"
Signature · 1 line
1.8.1.5
maintainer Reviewed-by on v1 10/45
#20 lore raw

Re: [PATCH tip/core/rcu 10/45] torture: Rename RCU_BUILDONLY to TORTURE_BUILDONLY

In reply to Paul E. McKenney
Quoted 3 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit makes the torture scripts a bit more RCU-independent.

And removes unnecessary exports; please document that. With that change:

Quoted 1 line
Quoted 52 lines
---
 tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 2 +-
 tools/testing/selftests/rcutorture/bin/kvm.sh            | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +1 -1
index e82f4f201c8c..86e6ffe6df45 100755
@@ -152,7 +152,7 @@ boot_args="`configfrag_boot_params "$boot_args" "$config_template"`"
 boot_args="`per_version_boot_params "$boot_args" $builddir/.config $seconds`"
 
 echo $QEMU $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd
-if test -n "$RCU_BUILDONLY"
+if test -n "$TORTURE_BUILDONLY"
 then
 	echo Build-only run specified, boot/test omitted.
 	exit 0
tools/testing/selftests/rcutorture/bin/kvm.sh +6 -3
index 08c90cba79d2..73c586f6bdf6 100644
@@ -81,7 +81,7 @@ do
 		shift
 		;;
 	--buildonly)
-		RCU_BUILDONLY=1; export RCU_BUILDONLY
+		TORTURE_BUILDONLY=1
 		;;
 	--configs)
 		checkarg --configs "(list of config files)" "$#" "$2" '^[^/]*$' '^--'
@@ -374,7 +374,7 @@ then
 	echo KVM="$KVM; export KVM"
 	echo KVPATH="$KVPATH; export KVPATH"
 	echo PATH="$PATH; export PATH"
-	echo RCU_BUILDONLY="$RCU_BUILDONLY; export RCU_BUILDONLY"
+	echo TORTURE_BUILDONLY="$TORTURE_BUILDONLY; export TORTURE_BUILDONLY"
 	echo TORTURE_INITRD="$TORTURE_INITRD; export TORTURE_INITRD"
 	echo TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG; export TORTURE_KMAKE_ARG"
 	echo RCU_QEMU_CMD="$RCU_QEMU_CMD; export RCU_QEMU_CMD"
@@ -402,4 +402,7 @@ echo
 echo
 echo " --- `date` Test summary:"
 echo Results directory: $resdir/$ds
-kvm-recheck.sh $resdir/$ds
+if test -n "$TORTURE_BUILDONLY"
+then
+	kvm-recheck.sh $resdir/$ds
+fi
Signature · 1 line
1.8.1.5
maintainer Reviewed-by on v1 11/45
#23 lore raw

Re: [PATCH tip/core/rcu 11/45] torture: Rename RCU_QEMU_INTERACTIVE to TORTURE_QEMU_INTERACTIVE

In reply to Paul E. McKenney
Quoted 5 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit makes the torture scripts a bit more RCU-independent.

Bug below; with that fixed,

Quoted 2 lines
tools/testing/selftests/rcutorture/bin/kvm.sh +0 -0

[...]

tools/testing/selftests/rcutorture/bin/kvm.sh then · line 382

Quoted 7 lines
tools/testing/selftests/rcutorture/bin/kvm.sh +2 -1
@@ -378,7 +378,8 @@ then
 	echo TORTURE_INITRD="$TORTURE_INITRD; export TORTURE_INITRD"
 	echo TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG; export TORTURE_KMAKE_ARG"
 	echo RCU_QEMU_CMD="$RCU_QEMU_CMD; export RCU_QEMU_CMD"
-	echo RCU_QEMU_INTERACTIVE="$RCU_QEMU_INTERACTIVE; export RCU_QEMU_INTERACTIVE"
+	echo TORTURE_QEMU_INTERACTIVE="$TORTURE_QEMU_INTERACTIVE;
+		export TORTURE_QEMU_INTERACTIVE"

Don't break this line in the middle of your quoted string.

#25 lore raw

Re: [PATCH tip/core/rcu 11/45] torture: Rename RCU_QEMU_INTERACTIVE to TORTURE_QEMU_INTERACTIVE

In reply to Paul E. McKenney

tools/testing/selftests/rcutorture/bin/functions.sh identify_qemu_args () { · line 142

Quoted 9 lines · Paul E. McKenney
tools/testing/selftests/rcutorture/bin/functions.sh +2 -2
-		if test -n "$RCU_QEMU_INTERACTIVE" -a -n "$RCU_QEMU_MAC"
+		if test -n "$TORTURE_QEMU_INTERACTIVE" -a -n "$RCU_QEMU_MAC"
 		then
 			echo -device spapr-vlan,netdev=net0,mac=$RCU_QEMU_MAC
 			echo -netdev bridge,br=br0,id=net0
-		elif test -n "$RCU_QEMU_INTERACTIVE"
+		elif test -n "$TORTURE_QEMU_INTERACTIVE"
 		then
 			echo -net nic -net user

Not related to this patch, but: qemu defaults to -net nic -net user, so you don't need to specify it.

- Josh Triplett

maintainer Reviewed-by on v1 12/45
#28 lore raw

Re: [PATCH tip/core/rcu 12/45] torture: Rename RCU_QEMU_MAC to TORTURE_QEMU_MAC

In reply to Paul E. McKenney
Quoted 5 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit makes the torture scripts a bit more RCU-independent.

One comment below; with or without that change:

Quoted 35 lines
---
 tools/testing/selftests/rcutorture/bin/functions.sh | 6 +++---
 tools/testing/selftests/rcutorture/bin/kvm.sh       | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)
tools/testing/selftests/rcutorture/bin/functions.sh +3 -3
index 623939cf814e..41fb52b805e4 100644
@@ -124,7 +124,7 @@ identify_qemu_append () {
 
 # identify_qemu_args qemu-cmd serial-file
 #
-# Output arguments for qemu arguments based on the RCU_QEMU_MAC
+# Output arguments for qemu arguments based on the TORTURE_QEMU_MAC
 # and TORTURE_QEMU_INTERACTIVE environment variables.
 identify_qemu_args () {
 	case "$1" in
@@ -133,9 +133,9 @@ identify_qemu_args () {
 	qemu-system-ppc64)
 		echo -enable-kvm -M pseries -cpu POWER7 -nodefaults
 		echo -device spapr-vscsi
-		if test -n "$TORTURE_QEMU_INTERACTIVE" -a -n "$RCU_QEMU_MAC"
+		if test -n "$TORTURE_QEMU_INTERACTIVE" -a -n "$TORTURE_QEMU_MAC"
 		then
-			echo -device spapr-vlan,netdev=net0,mac=$RCU_QEMU_MAC
+			echo -device spapr-vlan,netdev=net0,mac=$TORTURE_QEMU_MAC
 			echo -netdev bridge,br=br0,id=net0
 		elif test -n "$TORTURE_QEMU_INTERACTIVE"
 		then
tools/testing/selftests/rcutorture/bin/kvm.sh +0 -0
index 2f9605ed5b58..1a4a68c76914 100644

tools/testing/selftests/rcutorture/bin/kvm.sh do · line 131

Quoted 5 lines
tools/testing/selftests/rcutorture/bin/kvm.sh +1 -1
@@ -128,7 +128,7 @@ do
 		;;
 	--mac)
 		checkarg --mac "(MAC address)" $# "$2" '^\([0-9a-fA-F]\{2\}:\)\{5\}[0-9a-fA-F]\{2\}$' error
-		RCU_QEMU_MAC=$2; export RCU_QEMU_MAC
+		TORTURE_QEMU_MAC=$2; export TORTURE_QEMU_MAC

Can't you drop this export the same way you did previous exports?

Quoted 15 lines
tools/testing/selftests/rcutorture/bin/kvm.sh +1 -1
 		shift
 		;;
 	--no-initrd)
@@ -380,7 +380,7 @@ then
 	echo RCU_QEMU_CMD="$RCU_QEMU_CMD; export RCU_QEMU_CMD"
 	echo TORTURE_QEMU_INTERACTIVE="$TORTURE_QEMU_INTERACTIVE;
 		export TORTURE_QEMU_INTERACTIVE"
-	echo RCU_QEMU_MAC="$RCU_QEMU_MAC; export RCU_QEMU_MAC"
+	echo TORTURE_QEMU_MAC="$TORTURE_QEMU_MAC; export TORTURE_QEMU_MAC"
 	echo "mkdir -p "$resdir" || :"
 	echo "mkdir $resdir/$ds"
 	cat $T/script
Signature · 1 line
1.8.1.5
maintainer Reviewed-by on v1 15/45
#33 lore raw

Re: [PATCH tip/core/rcu 15/45] torture: Make config-fragment filtering RCU-independent

In reply to Paul E. McKenney
Quoted 8 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The torture tests need to set specific values for their respective Kconfig options (e.g., CONFIG_LOCK_TORTURE_TEST), and must therefore filter any conflicting definitions from the Kconfig fragment file. Unfortunately, the code in kvm-build.sh was looking only for CONFIG_RCU_TORTURE_TEST. This commit therefore handles the general case of CONFIG_[A-Z]*TORTURE_TEST.

This doesn't match your code below, which includes an _ after the * .

Also, one nit below.

Quoted 1 line

With the commit message fixed:

Quoted 9 lines
---
 tools/testing/selftests/rcutorture/bin/kvm-build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/kvm-build.sh +0 -0
index e838c775f709..6d0b76d918f4 100755

tools/testing/selftests/rcutorture/bin/kvm-build.sh T=/tmp/test-linux.sh.$$ · line 48

Quoted 5 lines
tools/testing/selftests/rcutorture/bin/kvm-build.sh +1 -1
@@ -45,7 +45,7 @@ T=/tmp/test-linux.sh.$$
 trap 'rm -rf $T' 0
 mkdir $T
 
-cat ${config_template} | grep -v CONFIG_RCU_TORTURE_TEST > $T/config
+cat ${config_template} | grep -v 'CONFIG_[A-Z]*_TORTURE_TEST' > $T/config

UUOC (useless use of cat): you can redirect from ${config_template} rather than catting it.

Quoted 6 lines
tools/testing/selftests/rcutorture/bin/kvm-build.sh +0 -0
 cat << ___EOF___ >> $T/config
 CONFIG_INITRAMFS_SOURCE="$TORTURE_INITRD"
 CONFIG_VIRTIO_PCI=y
Signature · 1 line
1.8.1.5
maintainer Reviewed-by on v1 18/45
#38 lore raw

Re: [PATCH tip/core/rcu 18/45] torture: Make "--dryrun script" use same environment as normal run

In reply to Paul E. McKenney
Quoted 8 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

In a normal torture-test run, the script inherits its environment variables, but this does not work when producing a script that is to run later. Therefore, definitions and exports are prepended to a dryrun script but not to a script that is run immediately. This commit reconciles this by placing definitions and exports at the beginning of the script in both cases.

Cleanup idea, not needed in this commit: This has gotten sufficiently long to warrant a loop over a list of environment variables, or possibly a loop over all environment variable starting with TORTURE_* .

Quoted 1 line
Quoted 54 lines
---
 tools/testing/selftests/rcutorture/bin/kvm.sh | 28 ++++++++++++---------------
 1 file changed, 12 insertions(+), 16 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm.sh +12 -16
index 8aa62a2dccb5..93a6c5a8517d 100644
@@ -241,8 +241,19 @@ END {
 
 # Generate a script to execute the tests in appropriate batches.
 cat << ___EOF___ > $T/script
-TORTURE_SUITE="$TORTURE_SUITE"; export TORTURE_SUITE
+CONFIGFRAG="$CONFIGFRAG"; export CONFIGFRAG
+KVM="$KVM"; export KVM
+KVPATH="$KVPATH"; export KVPATH
+PATH="$PATH"; export PATH
+TORTURE_BUILDONLY="$TORTURE_BUILDONLY"; export TORTURE_BUILDONLY
 TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG
+TORTURE_INITRD="$TORTURE_INITRD"; export TORTURE_INITRD
+TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG"; export TORTURE_KMAKE_ARG
+TORTURE_QEMU_CMD="$TORTURE_QEMU_CMD"; export TORTURE_QEMU_CMD
+TORTURE_QEMU_INTERACTIVE="$TORTURE_QEMU_INTERACTIVE";
+	export TORTURE_QEMU_INTERACTIVE
+TORTURE_QEMU_MAC="$TORTURE_QEMU_MAC"; export TORTURE_QEMU_MAC
+TORTURE_SUITE="$TORTURE_SUITE"; export TORTURE_SUITE
 if ! test -e $resdir
 then
 	mkdir -p "$resdir" || :
@@ -371,21 +382,6 @@ ___EOF___
 
 if test "$dryrun" = script
 then
-	# Dump out the script, but define the environment variables that
-	# it needs to run standalone.
-	echo CONFIGFRAG="$CONFIGFRAG; export CONFIGFRAG"
-	echo KVM="$KVM; export KVM"
-	echo KVPATH="$KVPATH; export KVPATH"
-	echo PATH="$PATH; export PATH"
-	echo TORTURE_BUILDONLY="$TORTURE_BUILDONLY; export TORTURE_BUILDONLY"
-	echo TORTURE_INITRD="$TORTURE_INITRD; export TORTURE_INITRD"
-	echo TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG; export TORTURE_KMAKE_ARG"
-	echo TORTURE_QEMU_CMD="$TORTURE_QEMU_CMD; export TORTURE_QEMU_CMD"
-	echo TORTURE_QEMU_INTERACTIVE="$TORTURE_QEMU_INTERACTIVE;
-		export TORTURE_QEMU_INTERACTIVE"
-	echo TORTURE_QEMU_MAC="$TORTURE_QEMU_MAC; export TORTURE_QEMU_MAC"
-	echo "mkdir -p "$resdir" || :"
-	echo "mkdir $resdir/$ds"
 	cat $T/script
 	exit 0
 elif test "$dryrun" = sched
Signature · 1 line
1.8.1.5
maintainer Reviewed-by on v1 19/45
#41 lore raw

Re: [PATCH tip/core/rcu 19/45] rcutorture: Print negatives for SRCU counter wraparound

In reply to Paul E. McKenney
Quoted 8 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The srcu_torture_stats() function prints SRCU's per-CPU c[] array with an unsigned format, which means that the number one less than zero is a very large number. This commit therefore prints this array with a signed format in order to improve readability of the rcutorture output.

Nit below; with that:

Quoted 14 lines
 kernel/rcu/rcutorture.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/rcu/rcutorture.c +1 -0
index 3845ea99ccd4..0141fcff6bb9 100644
@@ -486,15 +486,16 @@ static void srcu_torture_barrier(void)
 
 static void srcu_torture_stats(char *page)
 {
+	long c0, c1;
 	int cpu;
 	int idx = srcu_ctl.completed & 0x1;

kernel/rcu/rcutorture.c static void srcu_torture_barrier(void) · line 498

Quoted 10 lines
kernel/rcu/rcutorture.c +3 -3
 
 	page += sprintf(page, "%s%s per-CPU(idx=%d):",
 		       torture_type, TORTURE_FLAG, idx);
 	for_each_possible_cpu(cpu) {
-		page += sprintf(page, " %d(%lu,%lu)", cpu,
-			       per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[!idx],
-			       per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[idx]);
+		c0 = (long)per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[!idx];
+		c1 = (long)per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[idx];
+		page += sprintf(page, " %d(%ld,%ld)", cpu, c0, c1);

Nit: I'd suggest declaring the variables inside the loop, or not using intermediate variables at all.

- Josh Triplett

#44 lore raw

Re: [PATCH tip/core/rcu 20/45] torture: Include "Stopping" string to torture_kthread_stopping()

In reply to Paul E. McKenney
Quoted 7 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Currently, torture_kthread_stopping() prints only the name of the kthread that is stopping, which can be unedifying. This commit therefore adds "Stopping" to make things more evident.

Feedback below.

Quoted 8 lines
 kernel/torture.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/torture.c +0 -0
index acc9afc2f26e..f329848c3eee 100644

kernel/torture.c EXPORT_SYMBOL_GPL(torture_must_stop_irq); · line 681

Quoted 9 lines
kernel/torture.c +4 -1
@@ -674,8 +674,11 @@ EXPORT_SYMBOL_GPL(torture_must_stop_irq);
  */
 void torture_kthread_stopping(char *title)
 {
+	char buf[128];
+
+	snprintf(buf, sizeof(buf), "Stopping %s", title);
 	if (verbose)
-		VERBOSE_TOROUT_STRING(title);
+		VERBOSE_TOROUT_STRING(buf);

This seems like a case where the macro has led to poorer code; rather than using sprintf into a temporary buffer, this should just print. Please consider fixing the output macros to allow formats, as the pr_* macros do.

Also, why do you need "if (verbose)" if the name of the macro has VERBOSE_ in it; shouldn't that mean it checks verbosity itself? (Another good reason not to create a unique verbosity level mechanism, and to use the kernel mechanisms instead.)

Quoted 6 lines
kernel/torture.c +0 -0
 	while (!kthread_should_stop()) {
 		torture_shutdown_absorb(title);
 		schedule_timeout_uninterruptible(1);
Signature · 1 line
1.8.1.5
#51 lore raw

Re: [PATCH tip/core/rcu 21/45] torture: Report diagnostics from qemu

In reply to Paul E. McKenney
Quoted 10 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The current script does record qemu diagnostics, but the user has to know where to look for them. This commit therefore puts them into the Warnings file so that kvm-recheck.sh will display them. This change is especially useful if you are in the habit of killing the qemu process when you realize that you messed something up, but then later on wonder why the process terminated early.

A couple of issues below.

tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh do · line 176

Quoted 6 lines
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +2 -0
@@ -172,6 +172,14 @@ do
 		if test $kruntime -lt $seconds
 		then
 			echo Completed in $kruntime vs. $seconds >> $resdir/Warnings 2>&1
+			grep "^(qemu) qemu:" $resdir/kvm-test-1-run.sh.out >> $resdir/Warnings 2>&1
+			killpid="`grep "^(qemu) qemu: terminating on signal [0-9]* from pid" $resdir/kvm-test-1-run.sh.out`"

You already searched for lines like this and put them in Warnings in the previous line, so you don't need to search the entire output. Also, you use grep here and sed below; you could just use sed here to directly obtain the PID:

killpid="$(sed -n "s/^(qemu) qemu: terminating on signal [0-9]* from pid \([0-9]*\).*$/\1/p" $resdir/Warnings)"

tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh do · line 182

Quoted 6 lines
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +6 -0
+			if test -n "$killpid"
+			then
+				pscmd="`echo $killpid | sed -e 's/^.*from pid/ps -ef | grep/'`"
+				echo $pscmd >> $resdir/Warnings
+				echo $pscmd | sh >> $resdir/Warnings 2>&1
+			fi

Grepping for a PID is a bad idea; it'll turn up anything that contains that PID anywhere on the line, including as a substring. Given the above change to obtain a numeric $killpid, you can instead pass the PID to ps directly:
if test -n "$killpid"
then
ps -fp $killpid >> $resdir/Warnings 2>&1
fi

maintainer Reviewed-by on v1 24/45
#56 lore raw

Re: [PATCH tip/core/rcu 24/45] torture: Choose bzImage location based on architecture

In reply to Paul E. McKenney
Quoted 10 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Currently, the scripts hard-code arch/x86/boot/bzImage, which does not work well for other architectures. This commit therefore provides a identify_boot_image function that selects the correct bzImage location relative to the top of the Linux source tree. This commit also adds a --bootimage argument that allows selecting some other file, for example, "vmlinux".

Two issues below; with those fixed,

Quoted 20 lines
 tools/testing/selftests/rcutorture/bin/functions.sh | 21 +++++++++++++++++++++
 .../selftests/rcutorture/bin/kvm-test-1-run.sh      | 11 +++++------
 tools/testing/selftests/rcutorture/bin/kvm.sh       |  8 ++++++++
 3 files changed, 34 insertions(+), 6 deletions(-)
tools/testing/selftests/rcutorture/bin/functions.sh +7 -0
index 6b2adb29b073..efa95867e1cc 100644
@@ -76,6 +76,27 @@ configfrag_hotplug_cpu () {
 	grep -q '^CONFIG_HOTPLUG_CPU=y$' "$1"
 }
 
+# identify_boot_image qemu-cmd
+#
+# Returns the relative path to the kernel build image.  This will be
+# arch/<arch>/boot/bzImage unless overridden with the TORTURE_BOOT_IMAGE
+# environment variable.
+identify_boot_image () {
+	if test -n "$TORTURE_BOOT_IMAGE"

tools/testing/selftests/rcutorture/bin/functions.sh configfrag_hotplug_cpu () { · line 95

Quoted 10 lines
tools/testing/selftests/rcutorture/bin/functions.sh +10 -0
+	then
+		echo $TORTURE_BOOT_IMAGE
+	else
+		case "$1" in
+		qemu-system-x86_64|qemu-system-i386)
+			echo arch/x86/boot/bzImage
+			;;
+		qemu-system-ppc64)
+			echo arch/powerpc/boot/bzImage
+			;;

*)
(fail noisily rather than silently)

Quoted 25 lines
tools/testing/selftests/rcutorture/bin/functions.sh +4 -0
+		esac
+	fi
+}
+
 # identify_qemu builddir
 #
 # Returns our best guess as to which qemu command is appropriate for
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +3 -1
index 7848227aa4c1..7a95f86cc85a 100755
@@ -94,9 +94,11 @@ fi
 # CONFIG_YENTA=n
 if kvm-build.sh $config_template $builddir $T
 then
+	QEMU="`identify_qemu $builddir/vmlinux`"
+	BOOT_IMAGE="`identify_boot_image $QEMU`"
 	cp $builddir/Make*.out $resdir
 	cp $builddir/.config $resdir
-	cp $builddir/arch/x86/boot/bzImage $resdir
+	cp $builddir/$BOOT_IMAGE $resdir
 	parse-build.sh $resdir/Make.out $title
 	if test -f $builddir.wait
 	then

tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh cd $KVM · line 129

Quoted 6 lines
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +0 -3
@@ -124,9 +126,6 @@ cd $KVM
 kstarttime=`awk 'BEGIN { print systime() }' < /dev/null`
 echo ' ---' `date`: Starting kernel
 
-# Determine the appropriate flavor of qemu command.
-QEMU="`identify_qemu $builddir/vmlinux`"
-

This change seems related but undocumented.

Quoted 62 lines
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +2 -2
 # Generate -smp qemu argument.
 qemu_args="-nographic $qemu_args"
 cpu_count=`configNR_CPUS.sh $config_template`
@@ -151,13 +150,13 @@ boot_args="`configfrag_boot_params "$boot_args" "$config_template"`"
 # Generate kernel-version-specific boot parameters
 boot_args="`per_version_boot_params "$boot_args" $builddir/.config $seconds`"
 
-echo $QEMU $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd
+echo $QEMU $qemu_args -m 512 -kernel $builddir/$BOOT_IMAGE -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd
 if test -n "$TORTURE_BUILDONLY"
 then
 	echo Build-only run specified, boot/test omitted.
 	exit 0
 fi
-$QEMU $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append "$qemu_append $boot_args"; echo $? > $resdir/qemu-retval &
+$QEMU $qemu_args -m 512 -kernel $builddir/$BOOT_IMAGE -append "$qemu_append $boot_args"; echo $? > $resdir/qemu-retval &
 qemu_pid=$!
 commandcompleted=0
 echo Monitoring qemu job at pid $qemu_pid
tools/testing/selftests/rcutorture/bin/kvm.sh +8 -0
index 9b838c372698..4eed2a4f42c7 100644
@@ -39,6 +39,7 @@ dryrun=""
 KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
 PATH=${KVM}/bin:$PATH; export PATH
 TORTURE_DEFCONFIG=defconfig
+TORTURE_BOOT_IMAGE=""
 TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
 TORTURE_KMAKE_ARG=""
 TORTURE_SUITE=rcu
@@ -53,6 +54,7 @@ kversion=""
 usage () {
 	echo "Usage: $scriptname optional arguments:"
 	echo "       --bootargs kernel-boot-arguments"
+	echo "       --bootimage relative-path-to-kernel-boot-image"
 	echo "       --buildonly"
 	echo "       --configs \"config-file list\""
 	echo "       --cpus N"
@@ -80,6 +82,11 @@ do
 		TORTURE_BOOTARGS="$2"
 		shift
 		;;
+	--bootimage)
+		checkarg --bootimage "(relative path to kernel boot image)" "$#" "$2" '[a-zA-Z0-9][a-zA-Z0-9_]*' '^--'
+		TORTURE_BOOT_IMAGE="$2"
+		shift
+		;;
 	--buildonly)
 		TORTURE_BUILDONLY=1
 		;;
@@ -245,6 +252,7 @@ CONFIGFRAG="$CONFIGFRAG"; export CONFIGFRAG
 KVM="$KVM"; export KVM
 KVPATH="$KVPATH"; export KVPATH
 PATH="$PATH"; export PATH
+TORTURE_BOOT_IMAGE="$TORTURE_BOOT_IMAGE"; export TORTURE_BOOT_IMAGE
 TORTURE_BUILDONLY="$TORTURE_BUILDONLY"; export TORTURE_BUILDONLY
 TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG
 TORTURE_INITRD="$TORTURE_INITRD"; export TORTURE_INITRD
Signature · 1 line
1.8.1.5
maintainer Reviewed-by on v1 27/45
#61 lore raw

Re: [PATCH tip/core/rcu 27/45] rcutorture: Export RCU grace-period kthread wait state to rcutorture

In reply to Paul E. McKenney
Quoted 7 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit allows rcutorture to print additional state for the RCU grace-period kthreads in cases where RCU seems reluctant to start a new grace period.

Should something reset gp_state after fqs finishes?

Quoted 117 lines
 include/linux/rcutiny.h |  4 ++++
 include/linux/rcutree.h |  1 +
 kernel/rcu/rcutorture.c |  1 +
 kernel/rcu/tree.c       | 17 +++++++++++++++++
 kernel/rcu/tree.h       |  8 +++++++-
 5 files changed, 30 insertions(+), 1 deletion(-)
include/linux/rcutiny.h +4 -0
index 425c659d54e5..d40a6a451330 100644
@@ -119,6 +119,10 @@ static inline void rcu_sched_force_quiescent_state(void)
 {
 }
 
+static inline void show_rcu_gp_kthreads(void)
+{
+}
+
 static inline void rcu_cpu_stall_reset(void)
 {
 }
include/linux/rcutree.h +1 -0
index a59ca05fd4e3..3e2f5d432743 100644
@@ -84,6 +84,7 @@ extern unsigned long rcutorture_vernum;
 long rcu_batches_completed(void);
 long rcu_batches_completed_bh(void);
 long rcu_batches_completed_sched(void);
+void show_rcu_gp_kthreads(void);
 
 void rcu_force_quiescent_state(void);
 void rcu_bh_force_quiescent_state(void);
kernel/rcu/rcutorture.c +1 -0
index 50c26a7b6d97..15af04177e7e 100644
@@ -1033,6 +1033,7 @@ rcu_torture_printk(char *page)
 				"??? Writer stall state %d g%lu c%lu f%#x\n",
 				rcu_torture_writer_state,
 				gpnum, completed, flags);
+		show_rcu_gp_kthreads();
 		rcutorture_trace_dump();
 	}
 	rtcv_snap = rcu_torture_current_version;
kernel/rcu/tree.c +17 -0
index 032106df7391..3107bd935b2b 100644
@@ -280,6 +280,21 @@ void rcu_bh_force_quiescent_state(void)
 EXPORT_SYMBOL_GPL(rcu_bh_force_quiescent_state);
 
 /*
+ * Show the state of the grace-period kthreads.
+ */
+void show_rcu_gp_kthreads(void)
+{
+	struct rcu_state *rsp;
+
+	for_each_rcu_flavor(rsp) {
+		pr_info("%s: wait state: %d ->state: %#lx\n",
+			rsp->name, rsp->gp_state, rsp->gp_kthread->state);
+		/* sched_show_task(rsp->gp_kthread); */
+	}
+}
+EXPORT_SYMBOL_GPL(show_rcu_gp_kthreads);
+
+/*
  * Record the number of times rcutorture tests have been initiated and
  * terminated.  This information allows the debugfs tracing stats to be
  * correlated to the rcutorture messages, even when the rcutorture module
@@ -1611,6 +1626,7 @@ static int __noreturn rcu_gp_kthread(void *arg)
 			trace_rcu_grace_period(rsp->name,
 					       ACCESS_ONCE(rsp->gpnum),
 					       TPS("reqwait"));
+			rsp->gp_state = RCU_GP_WAIT_GPS;
 			wait_event_interruptible(rsp->gp_wq,
 						 ACCESS_ONCE(rsp->gp_flags) &
 						 RCU_GP_FLAG_INIT);
@@ -1638,6 +1654,7 @@ static int __noreturn rcu_gp_kthread(void *arg)
 			trace_rcu_grace_period(rsp->name,
 					       ACCESS_ONCE(rsp->gpnum),
 					       TPS("fqswait"));
+			rsp->gp_state = RCU_GP_WAIT_FQS;
 			ret = wait_event_interruptible_timeout(rsp->gp_wq,
 					((gf = ACCESS_ONCE(rsp->gp_flags)) &
 					 RCU_GP_FLAG_FQS) ||
kernel/rcu/tree.h +7 -1
index 75dc3c39a02a..c2fd1e722879 100644
@@ -406,7 +406,8 @@ struct rcu_state {
 	unsigned long completed;		/* # of last completed gp. */
 	struct task_struct *gp_kthread;		/* Task for grace periods. */
 	wait_queue_head_t gp_wq;		/* Where GP task waits. */
-	int gp_flags;				/* Commands for GP task. */
+	short gp_flags;				/* Commands for GP task. */
+	short gp_state;				/* GP kthread sleep state. */
 
 	/* End of fields guarded by root rcu_node's lock. */
 
@@ -469,6 +470,11 @@ struct rcu_state {
 #define RCU_GP_FLAG_INIT 0x1	/* Need grace-period initialization. */
 #define RCU_GP_FLAG_FQS  0x2	/* Need grace-period quiescent-state forcing. */
 
+/* Values for rcu_state structure's gp_flags field. */
+#define RCU_GP_WAIT_INIT 0	/* Initial state. */
+#define RCU_GP_WAIT_GPS  1	/* Wait for grace-period start. */
+#define RCU_GP_WAIT_FQS  2	/* Wait for force-quiescent-state time. */
+
 extern struct list_head rcu_struct_flavors;
 
 /* Sequence through rcu_state structures for each RCU flavor. */
Signature · 1 line
1.8.1.5
#68 lore raw

Re: [PATCH tip/core/rcu 32/45] torture: Better summary diagnostics for build failures

In reply to Paul E. McKenney
Quoted 5 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The reaction of kvm-recheck.sh is obscure at best, and easy to miss completely. This commit therefore prints "BUG: Build failed" in the summary at the end of a run.

This commit also changes a dozen other things about the output that this commit message does not document. :)

Quoted 92 lines
---
 .../selftests/rcutorture/bin/kvm-recheck-lock.sh   |  2 +-
 .../selftests/rcutorture/bin/kvm-recheck-rcu.sh    |  2 +-
 .../selftests/rcutorture/bin/kvm-recheck.sh        | 24 ++++++++++++++++------
 .../selftests/rcutorture/bin/kvm-test-1-run.sh     |  1 +
 4 files changed, 21 insertions(+), 8 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-recheck-lock.sh +1 -1
index 829186e19eb1..7f1ff1a8fc4b 100755
@@ -35,7 +35,7 @@ configfile=`echo $i | sed -e 's/^.*\///'`
 ncs=`grep "Writes:  Total:" $i/console.log 2> /dev/null | tail -1 | sed -e 's/^.* Total: //' -e 's/ .*$//'`
 if test -z "$ncs"
 then
-	echo $configfile
+	echo "$configfile -------"
 else
 	title="$configfile ------- $ncs acquisitions/releases"
 	dur=`sed -e 's/^.* locktorture.shutdown_secs=//' -e 's/ .*$//' < $i/qemu-cmd 2> /dev/null`
tools/testing/selftests/rcutorture/bin/kvm-recheck-rcu.sh +1 -1
index d75b1dc5ae53..307c4b95f325 100755
@@ -35,7 +35,7 @@ configfile=`echo $i | sed -e 's/^.*\///'`
 ngps=`grep ver: $i/console.log 2> /dev/null | tail -1 | sed -e 's/^.* ver: //' -e 's/ .*$//'`
 if test -z "$ngps"
 then
-	echo $configfile
+	echo "$configfile -------"
 else
 	title="$configfile ------- $ngps grace periods"
 	dur=`sed -e 's/^.* rcutorture.shutdown_secs=//' -e 's/ .*$//' < $i/qemu-cmd 2> /dev/null`
tools/testing/selftests/rcutorture/bin/kvm-recheck.sh +18 -6
index 26d78b7eaccf..ee1f6cae3d70 100755
@@ -25,6 +25,7 @@
 # Authors: Paul E. McKenney <[email protected]>
 
 PATH=`pwd`/tools/testing/selftests/rcutorture/bin:$PATH; export PATH
+. tools/testing/selftests/rcutorture/bin/functions.sh
 for rd in "$@"
 do
 	firsttime=1
@@ -39,13 +40,24 @@ do
 		fi
 		TORTURE_SUITE="`cat $i/../TORTURE_SUITE`"
 		kvm-recheck-${TORTURE_SUITE}.sh $i
-		configcheck.sh $i/.config $i/ConfigFragment
-		parse-build.sh $i/Make.out $configfile
-		parse-torture.sh $i/console.log $configfile
-		parse-console.sh $i/console.log $configfile
-		if test -r $i/Warnings
+		if test -f "$i/console.log"
 		then
-			cat $i/Warnings
+			configcheck.sh $i/.config $i/ConfigFragment
+			parse-build.sh $i/Make.out $configfile
+			parse-torture.sh $i/console.log $configfile
+			parse-console.sh $i/console.log $configfile
+			if test -r $i/Warnings
+			then
+				cat $i/Warnings
+			fi
+		else
+			if test -f "$i/qemu-cmd"
+			then
+				print_bug qemu failed
+			else
+				print_bug Build failed
+			fi
+			echo "   $i"
 		fi
 	done
 done
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +1 -0
index 7a95f86cc85a..51c34a91a375 100755
@@ -106,6 +106,7 @@ then
 	fi
 else
 	cp $builddir/Make*.out $resdir
+	cp $builddir/.config $resdir || :
 	echo Build failed, not running KVM, see $resdir.
 	if test -f $builddir.wait
 	then
Signature · 1 line
1.8.1.5
maintainer Reviewed-by on v1 39/45
#81 lore raw

Re: [PATCH tip/core/rcu 39/45] rcutorture: Note diffs from git commits

In reply to Paul E. McKenney
Quoted 9 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The current scripting only keeps track of the git SHA-1 of the current HEAD. This can cause confusion in cases where testing ran in a git tree where changes had not yet been checked in. This commit therefore also records the output of "git diff HEAD" to provide the information needed to reconstruct the source tree that was tested.

Nit below.

Quoted 9 lines
---
 tools/testing/selftests/rcutorture/bin/kvm.sh | 5 +++++
 1 file changed, 5 insertions(+)
tools/testing/selftests/rcutorture/bin/kvm.sh +0 -0
index 4eed2a4f42c7..91661845fdec 100644

tools/testing/selftests/rcutorture/bin/kvm.sh if test -d .git · line 281

Quoted 5 lines
tools/testing/selftests/rcutorture/bin/kvm.sh +2 -0
@@ -277,6 +277,11 @@ if test -d .git
 then
 	git status >> $resdir/$ds/testid.txt
 	git rev-parse HEAD >> $resdir/$ds/testid.txt
+	git diff HEAD > $T/git-diff 2>&1
+	if test -s $T/git-diff

You don't need test here; you can use the return value of git diff.

Quoted 9 lines
tools/testing/selftests/rcutorture/bin/kvm.sh +3 -0
+	then
+		cp $T/git-diff $resdir/$ds
+	fi
 fi
 ___EOF___
 awk < $T/cfgcpu.pack \
Signature · 1 line
1.8.1.5
#88 lore raw

Re: [PATCH tip/core/rcu 41/45] torture: Put qemu into the background

In reply to Paul E. McKenney
Quoted 7 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Currently, qemu runs in the foreground, which prevents the script from killing it in case the kernel locks up. This commit therefore places qemu into the background, allowing the script to recover from lockups.

qemu originally did run in the background before this patch series; please merge this into the patch that introduces the echo and thus breaks that.

Quoted 19 lines
 tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +1 -1
index b1e85b049075..67e89f06e77f 100755
@@ -157,7 +157,7 @@ then
 	echo Build-only run specified, boot/test omitted.
 	exit 0
 fi
-$QEMU $qemu_args -m 512 -kernel $builddir/$BOOT_IMAGE -append "$qemu_append $boot_args"; echo $? > $resdir/qemu-retval &
+( $QEMU $qemu_args -m 512 -kernel $builddir/$BOOT_IMAGE -append "$qemu_append $boot_args"; echo $? > $resdir/qemu-retval ) &
 qemu_pid=$!
 commandcompleted=0
 echo Monitoring qemu job at pid $qemu_pid
Signature · 1 line
1.8.1.5
maintainer Reviewed-by on the v1 series
#105 lore raw
In reply to Paul E. McKenney
Quoted 89 lines · Paul E. McKenney

Hello!

This series provides torture-test updates:

1. Add forward-progress checking to distinguish between stalls in
the RCU implementation and in the torture test itself.

2. Remove the --builddir and --relbuilddir options, which have been
obsoleted by the parallel testing facility.

3. Make "--dryrun sched" output more readable by clearly indicating
where each batch of concurrent runs starts.

4. Make torture-test errors less RCU-specific. ("Hey, why did
my locktorture run complain about RCU???")

5,8-14. Rename variables to reflect the new RCU-independence of a number
of the torture-test scripts.

6. Reduce locktorture sleeping to increase intensity.

7. Add a --defconfig argument to allow other default configs to
be specified.

15. Make config-fragment filtering RCU-independent.

16. Mark private functions as static in kernel/rcu/torture.c,
courtesy of Rashika Kheria.

17-18. Make the output of "--dryrun script" independently runnable.

19. Print negative numbers when SRCU counters wrap instead of
huge 64-bit integers.

20. Fix "Stopping" torture messages.

21. Report any diagnostics issued by qemu.

22. Make kthreads spin during the last jiffy of a stutter period
to increase the intensity of torture stop-start events.

23. Permit multiple qemu and boot arguments to be specified on
the command line.

24. Choose bzImage location based on architecture.

25. Add tracing-enabled variant of TREE02 to aid debugging.

26. Dump the ftrace buffer when the RCU grace period stalls.

27. Export the RCU grace-period kthread wait state to rcutorture
to ease diagnosis of RCU grace-period stalls.

28. Fix bug in raw_cpu_inc_return().

29. Make cond_resched() report RCU quiescent states.

30. Make rcu_torture_reader() use cond_resched() instead of
unconditionally invoking schedule().

31. Complain if an all-zero cpumask is specified during a torture
shuffle operation, courtesy of Iulia Manda.

32. Make build failures more evident.

33. Capture and report the torture_create_kthread() return value when
creating the rcu_torture_fqs kthread.

34. Use elapsed time to detect hangs rather than counting "sleep 1"
commands.

35. Rearrange config fragments to ensure that RCU-sched primitives are
tested in TREE_PREEMPT_RCU kernels.

36. Add rcutorture tests for get_state_synchronize_rcu() and
cond_synchronize_rcu().

37. Add explicit tests for synchronous grace-period primitives.

38. Add missing destroy_timer_on_stack(), courtesy of Thomas Gleixner.

39. Make scripts record "git diff HEAD" to ease reproduction of
an unexpected torture-test result.

40. Run rcu_torture_writer() at normal priority.

41. Put the qemu process into the background to better handle
kernel hangs.

Quoted 8 lines

42. Remove reference to a non-existent Kconfig parameter.

43. Refuse to run multiple concurrent torture tests.

44. Remove __init from torture_init_begin() and torture_init_end()
to allow rcutorture to once again work as a loadable module.

45. Remove unused torture_parm() macro.

I responded with feedback on patches 1, 6, 7, 8, 10, 11, 12, 15, 18, 19, 20, 21, 24, 27, 32, 39, and 41.

For the remaining patches:

#95 lore raw

Re: [PATCH tip/core/rcu 01/45] rcutorture: Add forward-progress checking for writer

In reply to [email protected]
Quoted 9 lines · On Wed, May 07, 2014 at 02:16:49PM -0700, [email protected] wrote:
Quoted 8 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The rcutorture output currently does not distinguish between stalls in the RCU implementation and stalls in the rcu_torture_writer() kthreads. This commit therefore adds some diagnostics to help distinguish between these two conditions, at least for the non-SRCU implementations. (SRCU does not provide evidence of update-side forward progress by design.)

Quoted 8 lines
Quoted 1 line

The concept makes sense, and the writer state annotations seem like a useful debugging mechanism, but having RCU know about RCU torture types seems fundamentally wrong. This mechanism accesses rcu_state, which is already implementation-specific, so why not just only define the function for the RCU implementations that support it, and then have a function pointer in the torture-test structure to report a stall?

Ouch. It is worse than that! When running RCU-bh or RCU-sched, the current code incorrectly returns the statistics for RCU. So I do need some way for rcutorture to tell RCU which flavor it is testing.

One thing I could do would be to pass in a pointer to the call_rcu() function (cur_ops->call from rcutorture's viewpoint), then scan the rcu_state structures looking for the selected flavor (rsp->call from tree.c's viewpoint). In the SRCU and RCU-busted cases, the flavor would not be found, and I could then just set everything to zero.

Does that seem reasonable, or is there a better way to do this?

Thanx, Paul

Quoted 213 lines

- Josh Triplett

Quoted 210 lines
 include/linux/rcupdate.h | 19 +++++++++++++++++++
 kernel/rcu/rcutorture.c  | 37 +++++++++++++++++++++++++++++++++++++
 kernel/rcu/tree.c        | 18 ++++++++++++++++++
 3 files changed, 74 insertions(+)
include/linux/rcupdate.h +19 -0
index 00a7fd61b3c6..a6c3898e141e 100644
@@ -51,7 +51,17 @@ extern int rcu_expedited; /* for sysctl */
 extern int rcutorture_runnable; /* for sysctl */
 #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
 
+enum rcutorture_type {
+	RTORT_BUSTED,
+	RTORT_RCU,
+	RTORT_RCU_BH,
+	RTORT_RCU_SCHED,
+	RTORT_SRCU
+};
+
 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU)
+void rcutorture_get_gp_data(enum rcutorture_type test_type, int *flags,
+			    unsigned long *gpnum, unsigned long *completed);
 void rcutorture_record_test_transition(void);
 void rcutorture_record_progress(unsigned long vernum);
 void do_trace_rcu_torture_read(const char *rcutorturename,
@@ -60,6 +70,15 @@ void do_trace_rcu_torture_read(const char *rcutorturename,
 			       unsigned long c_old,
 			       unsigned long c);
 #else
+static inline void rcutorture_get_gp_data(enum rcutorture_type test_type,
+					  int *flags,
+					  unsigned long *gpnum,
+					  unsigned long *completed)
+{
+	*flags = 0;
+	*gpnum = 0;
+	*completed = 0;
+}
 static inline void rcutorture_record_test_transition(void)
 {
 }
kernel/rcu/rcutorture.c +37 -0
index bd30bc61bc05..1110db210318 100644
@@ -138,6 +138,15 @@ static long n_barrier_attempts;
 static long n_barrier_successes;
 static struct list_head rcu_torture_removed;
 
+static int rcu_torture_writer_state;
+#define RTWS_FIXED_DELAY	0
+#define RTWS_DELAY		1
+#define RTWS_REPLACE		2
+#define RTWS_DEF_FREE		3
+#define RTWS_EXP_SYNC		4
+#define RTWS_STUTTER		5
+#define RTWS_STOPPING		6
+
 #if defined(MODULE) || defined(CONFIG_RCU_TORTURE_TEST_RUNNABLE)
 #define RCUTORTURE_RUNNABLE_INIT 1
 #else
@@ -214,6 +223,7 @@ rcu_torture_free(struct rcu_torture *p)
  */
 
 struct rcu_torture_ops {
+	int ttype;
 	void (*init)(void);
 	int (*readlock)(void);
 	void (*read_delay)(struct torture_random_state *rrsp);
@@ -312,6 +322,7 @@ static void rcu_sync_torture_init(void)
 }
 
 static struct rcu_torture_ops rcu_ops = {
+	.ttype		= RTORT_RCU,
 	.init		= rcu_sync_torture_init,
 	.readlock	= rcu_torture_read_lock,
 	.read_delay	= rcu_read_delay,
@@ -355,6 +366,7 @@ static void rcu_bh_torture_deferred_free(struct rcu_torture *p)
 }
 
 static struct rcu_torture_ops rcu_bh_ops = {
+	.ttype		= RTORT_RCU_BH,
 	.init		= rcu_sync_torture_init,
 	.readlock	= rcu_bh_torture_read_lock,
 	.read_delay	= rcu_read_delay,  /* just reuse rcu's version. */
@@ -397,6 +409,7 @@ call_rcu_busted(struct rcu_head *head, void (*func)(struct rcu_head *rcu))
 }
 
 static struct rcu_torture_ops rcu_busted_ops = {
+	.ttype		= RTORT_BUSTED,
 	.init		= rcu_sync_torture_init,
 	.readlock	= rcu_torture_read_lock,
 	.read_delay	= rcu_read_delay,  /* just reuse rcu's version. */
@@ -492,6 +505,7 @@ static void srcu_torture_synchronize_expedited(void)
 }
 
 static struct rcu_torture_ops srcu_ops = {
+	.ttype		= RTORT_SRCU,
 	.init		= rcu_sync_torture_init,
 	.readlock	= srcu_torture_read_lock,
 	.read_delay	= srcu_read_delay,
@@ -527,6 +541,7 @@ static void rcu_sched_torture_deferred_free(struct rcu_torture *p)
 }
 
 static struct rcu_torture_ops sched_ops = {
+	.ttype		= RTORT_RCU_SCHED,
 	.init		= rcu_sync_torture_init,
 	.readlock	= sched_torture_read_lock,
 	.read_delay	= rcu_read_delay,  /* just reuse rcu's version. */
@@ -699,12 +714,15 @@ rcu_torture_writer(void *arg)
 	set_user_nice(current, MAX_NICE);
 
 	do {
+		rcu_torture_writer_state = RTWS_FIXED_DELAY;
 		schedule_timeout_uninterruptible(1);
 		rp = rcu_torture_alloc();
 		if (rp == NULL)
 			continue;
 		rp->rtort_pipe_count = 0;
+		rcu_torture_writer_state = RTWS_DELAY;
 		udelay(torture_random(&rand) & 0x3ff);
+		rcu_torture_writer_state = RTWS_REPLACE;
 		old_rp = rcu_dereference_check(rcu_torture_current,
 					       current == writer_task);
 		rp->rtort_mbtest = 1;
@@ -721,8 +739,10 @@ rcu_torture_writer(void *arg)
 			else
 				exp = gp_exp;
 			if (!exp) {
+				rcu_torture_writer_state = RTWS_DEF_FREE;
 				cur_ops->deferred_free(old_rp);
 			} else {
+				rcu_torture_writer_state = RTWS_EXP_SYNC;
 				cur_ops->exp_sync();
 				list_add(&old_rp->rtort_free,
 					 &rcu_torture_removed);
@@ -743,8 +763,10 @@ rcu_torture_writer(void *arg)
 			}
 		}
 		rcutorture_record_progress(++rcu_torture_current_version);
+		rcu_torture_writer_state = RTWS_STUTTER;
 		stutter_wait("rcu_torture_writer");
 	} while (!torture_must_stop());
+	rcu_torture_writer_state = RTWS_STOPPING;
 	torture_kthread_stopping("rcu_torture_writer");
 	return 0;
 }
@@ -937,6 +959,7 @@ rcu_torture_printk(char *page)
 	int i;
 	long pipesummary[RCU_TORTURE_PIPE_LEN + 1] = { 0 };
 	long batchsummary[RCU_TORTURE_PIPE_LEN + 1] = { 0 };
+	static unsigned long rtcv_snap = ULONG_MAX;
 
 	for_each_possible_cpu(cpu) {
 		for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
@@ -997,6 +1020,20 @@ rcu_torture_printk(char *page)
 	page += sprintf(page, "\n");
 	if (cur_ops->stats)
 		cur_ops->stats(page);
+	if (rtcv_snap == rcu_torture_current_version &&
+	    rcu_torture_current != NULL) {
+		int __maybe_unused flags;
+		unsigned long __maybe_unused gpnum;
+		unsigned long __maybe_unused completed;
+
+		rcutorture_get_gp_data(cur_ops->ttype,
+				       &flags, &gpnum, &completed);
+		page += sprintf(page,
+				"??? Writer stall state %d g%lu c%lu f%#x\n",
+				rcu_torture_writer_state,
+				gpnum, completed, flags);
+	}
+	rtcv_snap = rcu_torture_current_version;
 }
 
 /*
kernel/rcu/tree.c +18 -0
index 0c47e300210a..032106df7391 100644
@@ -294,6 +294,24 @@ void rcutorture_record_test_transition(void)
 EXPORT_SYMBOL_GPL(rcutorture_record_test_transition);
 
 /*
+ * Send along grace-period-related data for rcutorture diagnostics.
+ */
+void rcutorture_get_gp_data(enum rcutorture_type test_type, int *flags,
+			    unsigned long *gpnum, unsigned long *completed)
+{
+	if (test_type == RTORT_SRCU || test_type == RTORT_BUSTED) {
+		*flags = 0;
+		*gpnum = 0;
+		*completed = 0;
+		return;
+	}
+	*flags = ACCESS_ONCE(rcu_state->gp_flags);
+	*gpnum = ACCESS_ONCE(rcu_state->gpnum);
+	*completed = ACCESS_ONCE(rcu_state->completed);
+}
+EXPORT_SYMBOL_GPL(rcutorture_get_gp_data);
+
+/*
  * Record the number of writer passes through the current rcutorture test.
  * This is also used to correlate debugfs tracing stats with the rcutorture
  * messages.
Signature · 1 line
1.8.1.5
#11 lore raw

Re: [PATCH tip/core/rcu 07/45] torture: Allow variations of "defconfig" to be specified

In reply to [email protected]
Quoted 7 lines · On Wed, May 07, 2014 at 02:22:19PM -0700, [email protected] wrote:
Quoted 6 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Some environments require some variation on "make defconfig" to initialize the .config file. This commit therefore adds a --defconfig argument to allow this to be specified. The default value is of course "defconfig".

Quoted 6 lines
Quoted 1 line

<bikeshed color="blue">
"--defconfig randconfig" or "--defconfig allyesconfig" or similar seems rather odd; how about calling it --kconfig or similar? </bikeshed>

Some day I am going to have to feed that to a browser and see what happens. ;-)

I must confess that I hadn't considered feeding randconfig or allyesconfig to that argument, partly because I figured that I would have to also supply Kconfig constraints in those cases in order to ensure that the resulting kernel would actually run under qemu. I was instead thinking in terms of a --configs option beginning with "RAND", which would pick up the Kconfig constraints from the appropriate configs directory, for example:

tools/testing/selftests/rcutorture/configs/rcu/RAND1

That said, I haven't thought that far down that path.

So for the --defconfig argument, I was thinking more in terms of things like pseries_defconfig or versatile_defconfig.

Thanx, Paul

Quoted 61 lines
Quoted 60 lines
 tools/testing/selftests/rcutorture/bin/configinit.sh | 2 +-
 tools/testing/selftests/rcutorture/bin/kvm.sh        | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/configinit.sh +1 -1
index a1be6e62add1..9c3f3d39b934 100755
@@ -62,7 +62,7 @@ grep '^grep' < $T/u.sh > $T/upd.sh
 echo "cat - $c" >> $T/upd.sh
 make mrproper
 make $buildloc distclean > $builddir/Make.distclean 2>&1
-make $buildloc defconfig > $builddir/Make.defconfig.out 2>&1
+make $buildloc $TORTURE_DEFCONFIG > $builddir/Make.defconfig.out 2>&1
 mv $builddir/.config $builddir/.config.sav
 sh $T/upd.sh < $builddir/.config.sav > $builddir/.config
 cp $builddir/.config $builddir/.config.new
tools/testing/selftests/rcutorture/bin/kvm.sh +8 -0
index a52a077ee258..59945b7793d9 100644
@@ -38,6 +38,7 @@ dur=30
 dryrun=""
 KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
 PATH=${KVM}/bin:$PATH; export PATH
+TORTURE_DEFCONFIG=defconfig
 TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
 RCU_KMAKE_ARG=""; export RCU_KMAKE_ARG
 TORTURE_SUITE=rcu
@@ -56,6 +57,7 @@ usage () {
 	echo "       --configs \"config-file list\""
 	echo "       --cpus N"
 	echo "       --datestamp string"
+	echo "       --defconfig string"
 	echo "       --dryrun sched|script"
 	echo "       --duration minutes"
 	echo "       --interactive"
@@ -96,6 +98,11 @@ do
 		ds=$2
 		shift
 		;;
+	--defconfig)
+		checkarg --defconfig "defconfigtype" "$#" "$2" '^[^/][^/]*$' '^--'
+		TORTURE_DEFCONFIG=$2
+		shift
+		;;
 	--dryrun)
 		checkarg --dryrun "sched|script" $# "$2" 'sched\|script' '^--'
 		dryrun=$2
@@ -259,6 +266,7 @@ END {
 # Generate a script to execute the tests in appropriate batches.
 cat << ___EOF___ > $T/script
 TORTURE_SUITE="$TORTURE_SUITE"; export TORTURE_SUITE
+TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG
 ___EOF___
 awk < $T/cfgcpu.pack \
 	-v CONFIGDIR="$CONFIGFRAG/$kversion/" \
Signature · 1 line
1.8.1.5
#8 lore raw

Re: [PATCH tip/core/rcu 06/45] torture: Intensify locking test

In reply to [email protected]
Quoted 20 lines · On Wed, May 07, 2014 at 02:20:15PM -0700, [email protected] wrote:
Quoted 19 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The current lock_torture_writer() spends too much time sleeping and not enough time hammering locks, as in an eight-CPU test will often only be utilizing a CPU or two. This commit therefore makes lock_torture_writer() sleep less and hammer more.

---
 kernel/locking/locktorture.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/locking/locktorture.c +0 -0
index f26b1a18e34e..b0d3e3c50672 100644
@@ -219,7 +219,8 @@ static int lock_torture_writer(void *arg)
 	set_user_nice(current, 19);
 
Quoted 7 lines

kernel/locking/locktorture.c static int lock_torture_writer(void *arg) · line 223

Quoted 4 lines
kernel/locking/locktorture.c +2 -1
 	do {
-		schedule_timeout_uninterruptible(1);
+		if ((torture_random(&rand) & 0xfffff) == 0)
+			schedule_timeout_uninterruptible(1);

That's a one-in-1048576 chance of sleeping for a jiffy; is that frequent enough to even bother sleeping at all?

On large systems, maybe not. Smallish systems should be able to get through that loop a million times in a few hundreds of milliseconds, though. So longer term a smarter approach might be needed, but this should be a good start.

Thanx, Paul

Quoted 7 lines
Quoted 6 lines
kernel/locking/locktorture.c +0 -0
 		cur_ops->writelock();
 		if (WARN_ON_ONCE(lock_is_write_held))
 			lwsp->n_write_lock_fail++;
Signature · 1 line
1.8.1.5
#26 lore raw

Re: [PATCH tip/core/rcu 11/45] torture: Rename RCU_QEMU_INTERACTIVE to TORTURE_QEMU_INTERACTIVE

In reply to [email protected]
Quoted 13 lines · On Wed, May 07, 2014 at 02:27:08PM -0700, [email protected] wrote:

tools/testing/selftests/rcutorture/bin/functions.sh identify_qemu_args () { · line 142

Quoted 9 lines · Paul E. McKenney
tools/testing/selftests/rcutorture/bin/functions.sh +2 -2
-		if test -n "$RCU_QEMU_INTERACTIVE" -a -n "$RCU_QEMU_MAC"
+		if test -n "$TORTURE_QEMU_INTERACTIVE" -a -n "$RCU_QEMU_MAC"
 		then
 			echo -device spapr-vlan,netdev=net0,mac=$RCU_QEMU_MAC
 			echo -netdev bridge,br=br0,id=net0
-		elif test -n "$RCU_QEMU_INTERACTIVE"
+		elif test -n "$TORTURE_QEMU_INTERACTIVE"
 		then
 			echo -net nic -net user

Not related to this patch, but: qemu defaults to -net nic -net user, so you don't need to specify it.

Good point, I wasn't aware of that. Paranoia will probably cause me to leave it explicitly specified, though.

And yes, I freely admit that my paranoia is not evenly distributed. ;-)

Thanx, Paul

#29 lore raw

Re: [PATCH tip/core/rcu 12/45] torture: Rename RCU_QEMU_MAC to TORTURE_QEMU_MAC

In reply to [email protected]
Quoted 44 lines · On Wed, May 07, 2014 at 02:27:56PM -0700, [email protected] wrote:
Quoted 5 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit makes the torture scripts a bit more RCU-independent.

One comment below; with or without that change:

Quoted 34 lines
---
 tools/testing/selftests/rcutorture/bin/functions.sh | 6 +++---
 tools/testing/selftests/rcutorture/bin/kvm.sh       | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)
tools/testing/selftests/rcutorture/bin/functions.sh +3 -3
index 623939cf814e..41fb52b805e4 100644
@@ -124,7 +124,7 @@ identify_qemu_append () {
 
 # identify_qemu_args qemu-cmd serial-file
 #
-# Output arguments for qemu arguments based on the RCU_QEMU_MAC
+# Output arguments for qemu arguments based on the TORTURE_QEMU_MAC
 # and TORTURE_QEMU_INTERACTIVE environment variables.
 identify_qemu_args () {
 	case "$1" in
@@ -133,9 +133,9 @@ identify_qemu_args () {
 	qemu-system-ppc64)
 		echo -enable-kvm -M pseries -cpu POWER7 -nodefaults
 		echo -device spapr-vscsi
-		if test -n "$TORTURE_QEMU_INTERACTIVE" -a -n "$RCU_QEMU_MAC"
+		if test -n "$TORTURE_QEMU_INTERACTIVE" -a -n "$TORTURE_QEMU_MAC"
 		then
-			echo -device spapr-vlan,netdev=net0,mac=$RCU_QEMU_MAC
+			echo -device spapr-vlan,netdev=net0,mac=$TORTURE_QEMU_MAC
 			echo -netdev bridge,br=br0,id=net0
 		elif test -n "$TORTURE_QEMU_INTERACTIVE"
 		then
tools/testing/selftests/rcutorture/bin/kvm.sh +0 -0
index 2f9605ed5b58..1a4a68c76914 100644
Quoted 8 lines

tools/testing/selftests/rcutorture/bin/kvm.sh do · line 131

Quoted 6 lines
tools/testing/selftests/rcutorture/bin/kvm.sh +1 -1
@@ -128,7 +128,7 @@ do
 		;;
 	--mac)
 		checkarg --mac "(MAC address)" $# "$2" '^\([0-9a-fA-F]\{2\}:\)\{5\}[0-9a-fA-F]\{2\}$' error
-		RCU_QEMU_MAC=$2; export RCU_QEMU_MAC
+		TORTURE_QEMU_MAC=$2; export TORTURE_QEMU_MAC

Can't you drop this export the same way you did previous exports?

Good point, will do!

Thanx, Paul

Quoted 16 lines
Quoted 15 lines
tools/testing/selftests/rcutorture/bin/kvm.sh +1 -1
 		shift
 		;;
 	--no-initrd)
@@ -380,7 +380,7 @@ then
 	echo RCU_QEMU_CMD="$RCU_QEMU_CMD; export RCU_QEMU_CMD"
 	echo TORTURE_QEMU_INTERACTIVE="$TORTURE_QEMU_INTERACTIVE;
 		export TORTURE_QEMU_INTERACTIVE"
-	echo RCU_QEMU_MAC="$RCU_QEMU_MAC; export RCU_QEMU_MAC"
+	echo TORTURE_QEMU_MAC="$TORTURE_QEMU_MAC; export TORTURE_QEMU_MAC"
 	echo "mkdir -p "$resdir" || :"
 	echo "mkdir $resdir/$ds"
 	cat $T/script
Signature · 1 line
1.8.1.5
#24 lore raw

Re: [PATCH tip/core/rcu 11/45] torture: Rename RCU_QEMU_INTERACTIVE to TORTURE_QEMU_INTERACTIVE

In reply to [email protected]
Quoted 13 lines · On Wed, May 07, 2014 at 02:26:09PM -0700, [email protected] wrote:
Quoted 5 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit makes the torture scripts a bit more RCU-independent.

Bug below; with that fixed,

Quoted 2 lines
tools/testing/selftests/rcutorture/bin/kvm.sh +0 -0

[...]

Quoted 9 lines

tools/testing/selftests/rcutorture/bin/kvm.sh then · line 382

Quoted 7 lines
tools/testing/selftests/rcutorture/bin/kvm.sh +2 -1
@@ -378,7 +378,8 @@ then
 	echo TORTURE_INITRD="$TORTURE_INITRD; export TORTURE_INITRD"
 	echo TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG; export TORTURE_KMAKE_ARG"
 	echo RCU_QEMU_CMD="$RCU_QEMU_CMD; export RCU_QEMU_CMD"
-	echo RCU_QEMU_INTERACTIVE="$RCU_QEMU_INTERACTIVE; export RCU_QEMU_INTERACTIVE"
+	echo TORTURE_QEMU_INTERACTIVE="$TORTURE_QEMU_INTERACTIVE;
+		export TORTURE_QEMU_INTERACTIVE"

Don't break this line in the middle of your quoted string.

Good point, will fix!

Thanx, Paul

#34 lore raw

Re: [PATCH tip/core/rcu 15/45] torture: Make config-fragment filtering RCU-independent

In reply to [email protected]
Quoted 31 lines · On Wed, May 07, 2014 at 02:29:37PM -0700, [email protected] wrote:
Quoted 8 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The torture tests need to set specific values for their respective Kconfig options (e.g., CONFIG_LOCK_TORTURE_TEST), and must therefore filter any conflicting definitions from the Kconfig fragment file. Unfortunately, the code in kvm-build.sh was looking only for CONFIG_RCU_TORTURE_TEST. This commit therefore handles the general case of CONFIG_[A-Z]*TORTURE_TEST.

This doesn't match your code below, which includes an _ after the * .

Also, one nit below.

Quoted 1 line

With the commit message fixed:

Quoted 12 lines
---
 tools/testing/selftests/rcutorture/bin/kvm-build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/kvm-build.sh +0 -0
index e838c775f709..6d0b76d918f4 100755
@@ -45,7 +45,7 @@ T=/tmp/test-linux.sh.$$
 trap 'rm -rf $T' 0
 mkdir $T
 
Quoted 5 lines

tools/testing/selftests/rcutorture/bin/kvm-build.sh T=/tmp/test-linux.sh.$$ · line 48

Quoted 2 lines
tools/testing/selftests/rcutorture/bin/kvm-build.sh +1 -1
-cat ${config_template} | grep -v CONFIG_RCU_TORTURE_TEST > $T/config
+cat ${config_template} | grep -v 'CONFIG_[A-Z]*_TORTURE_TEST' > $T/config

UUOC (useless use of cat): you can redirect from ${config_template} rather than catting it.

Both good points! Back when I was first using UNIX, that extra "cat" would have cost me something like three seconds. How quickly we forget! ;-)

Thanx, Paul

Quoted 7 lines
Quoted 6 lines
tools/testing/selftests/rcutorture/bin/kvm-build.sh +0 -0
 cat << ___EOF___ >> $T/config
 CONFIG_INITRAMFS_SOURCE="$TORTURE_INITRD"
 CONFIG_VIRTIO_PCI=y
Signature · 1 line
1.8.1.5
#39 lore raw

Re: [PATCH tip/core/rcu 18/45] torture: Make "--dryrun script" use same environment as normal run

In reply to [email protected]
Quoted 10 lines · On Wed, May 07, 2014 at 02:33:27PM -0700, [email protected] wrote:
Quoted 8 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

In a normal torture-test run, the script inherits its environment variables, but this does not work when producing a script that is to run later. Therefore, definitions and exports are prepended to a dryrun script but not to a script that is run immediately. This commit reconciles this by placing definitions and exports at the beginning of the script in both cases.

Quoted 3 lines

Cleanup idea, not needed in this commit: This has gotten sufficiently long to warrant a loop over a list of environment variables, or possibly a loop over all environment variable starting with TORTURE_* .

Makes sense on both counts, thank you! Give or take quoting, anyway! ;-)

Thanx, Paul

Quoted 58 lines
Quoted 1 line
Quoted 54 lines
---
 tools/testing/selftests/rcutorture/bin/kvm.sh | 28 ++++++++++++---------------
 1 file changed, 12 insertions(+), 16 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm.sh +12 -16
index 8aa62a2dccb5..93a6c5a8517d 100644
@@ -241,8 +241,19 @@ END {
 
 # Generate a script to execute the tests in appropriate batches.
 cat << ___EOF___ > $T/script
-TORTURE_SUITE="$TORTURE_SUITE"; export TORTURE_SUITE
+CONFIGFRAG="$CONFIGFRAG"; export CONFIGFRAG
+KVM="$KVM"; export KVM
+KVPATH="$KVPATH"; export KVPATH
+PATH="$PATH"; export PATH
+TORTURE_BUILDONLY="$TORTURE_BUILDONLY"; export TORTURE_BUILDONLY
 TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG
+TORTURE_INITRD="$TORTURE_INITRD"; export TORTURE_INITRD
+TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG"; export TORTURE_KMAKE_ARG
+TORTURE_QEMU_CMD="$TORTURE_QEMU_CMD"; export TORTURE_QEMU_CMD
+TORTURE_QEMU_INTERACTIVE="$TORTURE_QEMU_INTERACTIVE";
+	export TORTURE_QEMU_INTERACTIVE
+TORTURE_QEMU_MAC="$TORTURE_QEMU_MAC"; export TORTURE_QEMU_MAC
+TORTURE_SUITE="$TORTURE_SUITE"; export TORTURE_SUITE
 if ! test -e $resdir
 then
 	mkdir -p "$resdir" || :
@@ -371,21 +382,6 @@ ___EOF___
 
 if test "$dryrun" = script
 then
-	# Dump out the script, but define the environment variables that
-	# it needs to run standalone.
-	echo CONFIGFRAG="$CONFIGFRAG; export CONFIGFRAG"
-	echo KVM="$KVM; export KVM"
-	echo KVPATH="$KVPATH; export KVPATH"
-	echo PATH="$PATH; export PATH"
-	echo TORTURE_BUILDONLY="$TORTURE_BUILDONLY; export TORTURE_BUILDONLY"
-	echo TORTURE_INITRD="$TORTURE_INITRD; export TORTURE_INITRD"
-	echo TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG; export TORTURE_KMAKE_ARG"
-	echo TORTURE_QEMU_CMD="$TORTURE_QEMU_CMD; export TORTURE_QEMU_CMD"
-	echo TORTURE_QEMU_INTERACTIVE="$TORTURE_QEMU_INTERACTIVE;
-		export TORTURE_QEMU_INTERACTIVE"
-	echo TORTURE_QEMU_MAC="$TORTURE_QEMU_MAC; export TORTURE_QEMU_MAC"
-	echo "mkdir -p "$resdir" || :"
-	echo "mkdir $resdir/$ds"
 	cat $T/script
 	exit 0
 elif test "$dryrun" = sched
Signature · 1 line
1.8.1.5
#42 lore raw

Re: [PATCH tip/core/rcu 19/45] rcutorture: Print negatives for SRCU counter wraparound

In reply to [email protected]
Quoted 28 lines · On Wed, May 07, 2014 at 02:34:26PM -0700, [email protected] wrote:
Quoted 8 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The srcu_torture_stats() function prints SRCU's per-CPU c[] array with an unsigned format, which means that the number one less than zero is a very large number. This commit therefore prints this array with a signed format in order to improve readability of the rcutorture output.

Nit below; with that:

Quoted 15 lines
 kernel/rcu/rcutorture.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/rcu/rcutorture.c +1 -0
index 3845ea99ccd4..0141fcff6bb9 100644
@@ -486,15 +486,16 @@ static void srcu_torture_barrier(void)
 
 static void srcu_torture_stats(char *page)
 {
+	long c0, c1;
 	int cpu;
 	int idx = srcu_ctl.completed & 0x1;
 
Quoted 12 lines

kernel/rcu/rcutorture.c static void srcu_torture_barrier(void) · line 498

Quoted 9 lines
kernel/rcu/rcutorture.c +3 -3
 	page += sprintf(page, "%s%s per-CPU(idx=%d):",
 		       torture_type, TORTURE_FLAG, idx);
 	for_each_possible_cpu(cpu) {
-		page += sprintf(page, " %d(%lu,%lu)", cpu,
-			       per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[!idx],
-			       per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[idx]);
+		c0 = (long)per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[!idx];
+		c1 = (long)per_cpu_ptr(srcu_ctl.per_cpu_ref, cpu)->c[idx];
+		page += sprintf(page, " %d(%ld,%ld)", cpu, c0, c1);

Nit: I'd suggest declaring the variables inside the loop, or not using intermediate variables at all.

Fair enough! Can't see that I am gaining much by them.

Thanx, Paul

maintainer
#12 lore raw

Re: [PATCH tip/core/rcu 07/45] torture: Allow variations of "defconfig" to be specified

In reply to Paul E. McKenney
Quoted 26 lines · Paul E. McKenney
Quoted 7 lines · On Wed, May 07, 2014 at 02:22:19PM -0700, [email protected] wrote:
Quoted 6 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Some environments require some variation on "make defconfig" to initialize the .config file. This commit therefore adds a --defconfig argument to allow this to be specified. The default value is of course "defconfig".

Quoted 6 lines
Quoted 1 line

<bikeshed color="blue">
"--defconfig randconfig" or "--defconfig allyesconfig" or similar seems rather odd; how about calling it --kconfig or similar? </bikeshed>

Some day I am going to have to feed that to a browser and see what happens. ;-)

I must confess that I hadn't considered feeding randconfig or allyesconfig to that argument, partly because I figured that I would have to also supply Kconfig constraints in those cases in order to ensure that the resulting kernel would actually run under qemu. I was instead thinking in terms of a --configs option beginning with "RAND", which would pick up the Kconfig constraints from the appropriate configs directory, for example:

Quoted 6 lines

tools/testing/selftests/rcutorture/configs/rcu/RAND1

That said, I haven't thought that far down that path.

So for the --defconfig argument, I was thinking more in terms of things like pseries_defconfig or versatile_defconfig.

Ah, I see. --defconfig specifies the base configuration, while --configs specifies the constraints. In that case, how about --baseconfig? It might still make sense to pass --baseconfig allnoconfig or --baseconfig allyesconfig or --baseconfig randconfig, given a sufficiently complete constraints file.

- Josh Triplett

#13 lore raw

Re: [PATCH tip/core/rcu 07/45] torture: Allow variations of "defconfig" to be specified

Quoted 31 lines · Josh Triplett
Quoted 30 lines · Paul E. McKenney
Quoted 7 lines · On Wed, May 07, 2014 at 02:22:19PM -0700, [email protected] wrote:
Quoted 6 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Some environments require some variation on "make defconfig" to initialize the .config file. This commit therefore adds a --defconfig argument to allow this to be specified. The default value is of course "defconfig".

Quoted 6 lines
Quoted 1 line

<bikeshed color="blue">
"--defconfig randconfig" or "--defconfig allyesconfig" or similar seems rather odd; how about calling it --kconfig or similar? </bikeshed>

Some day I am going to have to feed that to a browser and see what happens. ;-)

I must confess that I hadn't considered feeding randconfig or allyesconfig to that argument, partly because I figured that I would have to also supply Kconfig constraints in those cases in order to ensure that the resulting kernel would actually run under qemu. I was instead thinking in terms of a --configs option beginning with "RAND", which would pick up the Kconfig constraints from the appropriate configs directory, for example:

tools/testing/selftests/rcutorture/configs/rcu/RAND1

That said, I haven't thought that far down that path.

Quoted 8 lines
Quoted 2 lines

So for the --defconfig argument, I was thinking more in terms of things like pseries_defconfig or versatile_defconfig.

Ah, I see. --defconfig specifies the base configuration, while --configs specifies the constraints. In that case, how about --baseconfig? It might still make sense to pass --baseconfig allnoconfig or --baseconfig allyesconfig or --baseconfig randconfig, given a sufficiently complete constraints file.

My choice of name was guided by the following:

	$ find arch -name '*defconfig*' -print | wc -l
	469

When I try baseconfig:

	$ find arch -name '*baseconfig*' -print | wc -l
	0

Don't get me wrong, you might be correct here. But the thing is that I like being able to specify all tests in one go. That means that I want to still be able to run my current defconfig-based config files (e.g., TREE01) when I get a randconfig-based setup going. So I would like to be able to specify something like:

	sh kvm.sh --defconfig pseries_defconfig --configs "TREE01 RAND01"

But perhaps there is a better way to do this.

Thanx, Paul

maintainer Reviewed-by
#14 lore raw

Re: [PATCH tip/core/rcu 07/45] torture: Allow variations of "defconfig" to be specified

Quoted 51 lines · Paul E. McKenney
Quoted 31 lines · Josh Triplett
Quoted 30 lines · Paul E. McKenney
Quoted 7 lines · On Wed, May 07, 2014 at 02:22:19PM -0700, [email protected] wrote:
Quoted 6 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Some environments require some variation on "make defconfig" to initialize the .config file. This commit therefore adds a --defconfig argument to allow this to be specified. The default value is of course "defconfig".

Quoted 6 lines
Quoted 1 line

<bikeshed color="blue">
"--defconfig randconfig" or "--defconfig allyesconfig" or similar seems rather odd; how about calling it --kconfig or similar? </bikeshed>

Some day I am going to have to feed that to a browser and see what happens. ;-)

I must confess that I hadn't considered feeding randconfig or allyesconfig to that argument, partly because I figured that I would have to also supply Kconfig constraints in those cases in order to ensure that the resulting kernel would actually run under qemu. I was instead thinking in terms of a --configs option beginning with "RAND", which would pick up the Kconfig constraints from the appropriate configs directory, for example:

tools/testing/selftests/rcutorture/configs/rcu/RAND1

That said, I haven't thought that far down that path.

Quoted 8 lines
Quoted 2 lines

So for the --defconfig argument, I was thinking more in terms of things like pseries_defconfig or versatile_defconfig.

Ah, I see. --defconfig specifies the base configuration, while --configs specifies the constraints. In that case, how about --baseconfig? It might still make sense to pass --baseconfig allnoconfig or --baseconfig allyesconfig or --baseconfig randconfig, given a sufficiently complete constraints file.

My choice of name was guided by the following:

	$ find arch -name '*defconfig*' -print | wc -l
	469

When I try baseconfig:

	$ find arch -name '*baseconfig*' -print | wc -l
	0
Quoted 7 lines

Don't get me wrong, you might be correct here. But the thing is that I like being able to specify all tests in one go. That means that I want to still be able to run my current defconfig-based config files (e.g., TREE01) when I get a randconfig-based setup going. So I would like to be able to specify something like:

	sh kvm.sh --defconfig pseries_defconfig --configs "TREE01 RAND01"

Fair enough.

maintainer
#96 lore raw

Re: [PATCH tip/core/rcu 01/45] rcutorture: Add forward-progress checking for writer

In reply to Paul E. McKenney
Quoted 24 lines · Paul E. McKenney
Quoted 9 lines · On Wed, May 07, 2014 at 02:16:49PM -0700, [email protected] wrote:
Quoted 8 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The rcutorture output currently does not distinguish between stalls in the RCU implementation and stalls in the rcu_torture_writer() kthreads. This commit therefore adds some diagnostics to help distinguish between these two conditions, at least for the non-SRCU implementations. (SRCU does not provide evidence of update-side forward progress by design.)

Quoted 8 lines
Quoted 1 line

The concept makes sense, and the writer state annotations seem like a useful debugging mechanism, but having RCU know about RCU torture types seems fundamentally wrong. This mechanism accesses rcu_state, which is already implementation-specific, so why not just only define the function for the RCU implementations that support it, and then have a function pointer in the torture-test structure to report a stall?

Ouch. It is worse than that! When running RCU-bh or RCU-sched, the current code incorrectly returns the statistics for RCU. So I do need some way for rcutorture to tell RCU which flavor it is testing.

Quoted 7 lines

One thing I could do would be to pass in a pointer to the call_rcu() function (cur_ops->call from rcutorture's viewpoint), then scan the rcu_state structures looking for the selected flavor (rsp->call from tree.c's viewpoint). In the SRCU and RCU-busted cases, the flavor would not be found, and I could then just set everything to zero.

Does that seem reasonable, or is there a better way to do this?

That search seems rather too hackish; why not just declare one stats-returning function per RCU flavor, and put the pointer to the corresponding function in the structure for each test type?

- Josh Triplett

#97 lore raw

Re: [PATCH tip/core/rcu 01/45] rcutorture: Add forward-progress checking for writer

Quoted 31 lines · Josh Triplett
Quoted 30 lines · Paul E. McKenney
Quoted 9 lines · On Wed, May 07, 2014 at 02:16:49PM -0700, [email protected] wrote:
Quoted 8 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The rcutorture output currently does not distinguish between stalls in the RCU implementation and stalls in the rcu_torture_writer() kthreads. This commit therefore adds some diagnostics to help distinguish between these two conditions, at least for the non-SRCU implementations. (SRCU does not provide evidence of update-side forward progress by design.)

Quoted 8 lines
Quoted 1 line

The concept makes sense, and the writer state annotations seem like a useful debugging mechanism, but having RCU know about RCU torture types seems fundamentally wrong. This mechanism accesses rcu_state, which is already implementation-specific, so why not just only define the function for the RCU implementations that support it, and then have a function pointer in the torture-test structure to report a stall?

Ouch. It is worse than that! When running RCU-bh or RCU-sched, the current code incorrectly returns the statistics for RCU. So I do need some way for rcutorture to tell RCU which flavor it is testing.

One thing I could do would be to pass in a pointer to the call_rcu() function (cur_ops->call from rcutorture's viewpoint), then scan the rcu_state structures looking for the selected flavor (rsp->call from tree.c's viewpoint). In the SRCU and RCU-busted cases, the flavor would not be found, and I could then just set everything to zero.

Quoted 5 lines
Quoted 1 line

Does that seem reasonable, or is there a better way to do this?

That search seems rather too hackish; why not just declare one stats-returning function per RCU flavor, and put the pointer to the corresponding function in the structure for each test type?

The problem is that rcutorture doesn't know anything about the structures, as those are internal to the implementation. All it knows is which functions it is using. I -could- EXPORT_SYMBOL_GPL() the rcu_state structures to modules (they are already non-static), then rename TINY_RCU's rcu_ctrlblk to rcu_state to allow the needed type punning, then do some special-case thing for SRCU, and put a pointer to whatever in rcu_torture_ops, but that was feeling a bit hackish as well.

So what did you have in mind to allow rcutorture to communicate the rcuflavor to the underlying RCU implementation?

Thanx, Paul

maintainer
#98 lore raw

Re: [PATCH tip/core/rcu 01/45] rcutorture: Add forward-progress checking for writer

Quoted 46 lines · Paul E. McKenney
Quoted 31 lines · Josh Triplett
Quoted 30 lines · Paul E. McKenney
Quoted 9 lines · On Wed, May 07, 2014 at 02:16:49PM -0700, [email protected] wrote:
Quoted 8 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The rcutorture output currently does not distinguish between stalls in the RCU implementation and stalls in the rcu_torture_writer() kthreads. This commit therefore adds some diagnostics to help distinguish between these two conditions, at least for the non-SRCU implementations. (SRCU does not provide evidence of update-side forward progress by design.)

Quoted 8 lines
Quoted 1 line

The concept makes sense, and the writer state annotations seem like a useful debugging mechanism, but having RCU know about RCU torture types seems fundamentally wrong. This mechanism accesses rcu_state, which is already implementation-specific, so why not just only define the function for the RCU implementations that support it, and then have a function pointer in the torture-test structure to report a stall?

Ouch. It is worse than that! When running RCU-bh or RCU-sched, the current code incorrectly returns the statistics for RCU. So I do need some way for rcutorture to tell RCU which flavor it is testing.

One thing I could do would be to pass in a pointer to the call_rcu() function (cur_ops->call from rcutorture's viewpoint), then scan the rcu_state structures looking for the selected flavor (rsp->call from tree.c's viewpoint). In the SRCU and RCU-busted cases, the flavor would not be found, and I could then just set everything to zero.

Quoted 5 lines
Quoted 1 line

Does that seem reasonable, or is there a better way to do this?

That search seems rather too hackish; why not just declare one stats-returning function per RCU flavor, and put the pointer to the corresponding function in the structure for each test type?

The problem is that rcutorture doesn't know anything about the structures, as those are internal to the implementation. All it knows is which functions it is using. I -could- EXPORT_SYMBOL_GPL() the rcu_state structures to modules (they are already non-static), then rename TINY_RCU's rcu_ctrlblk to rcu_state to allow the needed type punning, then do some special-case thing for SRCU, and put a pointer to whatever in rcu_torture_ops, but that was feeling a bit hackish as well.

Quoted 2 lines

So what did you have in mind to allow rcutorture to communicate the rcuflavor to the underlying RCU implementation?

Rather than EXPORT_SYMBOL_GPLing the rcu_state structures, just EXPORT_SYMBOL_GPL one version of rcutorture_get_gp_data per RCU flavor. (And hide them all behind #ifdef CONFIG_RCU_TORTURE_TEST.) Then add a get_gp_data field to rcu_torture_ops; if NULL, skip the stats. (Or put a no-op version in rcutorture.)

- Josh Triplett

#99 lore raw

Re: [PATCH tip/core/rcu 01/45] rcutorture: Add forward-progress checking for writer

Quoted 47 lines · Josh Triplett
Quoted 46 lines · Paul E. McKenney
Quoted 31 lines · Josh Triplett
Quoted 30 lines · Paul E. McKenney
Quoted 9 lines · On Wed, May 07, 2014 at 02:16:49PM -0700, [email protected] wrote:
Quoted 8 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The rcutorture output currently does not distinguish between stalls in the RCU implementation and stalls in the rcu_torture_writer() kthreads. This commit therefore adds some diagnostics to help distinguish between these two conditions, at least for the non-SRCU implementations. (SRCU does not provide evidence of update-side forward progress by design.)

Quoted 8 lines
Quoted 1 line

The concept makes sense, and the writer state annotations seem like a useful debugging mechanism, but having RCU know about RCU torture types seems fundamentally wrong. This mechanism accesses rcu_state, which is already implementation-specific, so why not just only define the function for the RCU implementations that support it, and then have a function pointer in the torture-test structure to report a stall?

Ouch. It is worse than that! When running RCU-bh or RCU-sched, the current code incorrectly returns the statistics for RCU. So I do need some way for rcutorture to tell RCU which flavor it is testing.

One thing I could do would be to pass in a pointer to the call_rcu() function (cur_ops->call from rcutorture's viewpoint), then scan the rcu_state structures looking for the selected flavor (rsp->call from tree.c's viewpoint). In the SRCU and RCU-busted cases, the flavor would not be found, and I could then just set everything to zero.

Quoted 5 lines
Quoted 1 line

Does that seem reasonable, or is there a better way to do this?

That search seems rather too hackish; why not just declare one stats-returning function per RCU flavor, and put the pointer to the corresponding function in the structure for each test type?

The problem is that rcutorture doesn't know anything about the structures, as those are internal to the implementation. All it knows is which functions it is using. I -could- EXPORT_SYMBOL_GPL() the rcu_state structures to modules (they are already non-static), then rename TINY_RCU's rcu_ctrlblk to rcu_state to allow the needed type punning, then do some special-case thing for SRCU, and put a pointer to whatever in rcu_torture_ops, but that was feeling a bit hackish as well.

Quoted 8 lines
Quoted 2 lines

So what did you have in mind to allow rcutorture to communicate the rcuflavor to the underlying RCU implementation?

Rather than EXPORT_SYMBOL_GPLing the rcu_state structures, just EXPORT_SYMBOL_GPL one version of rcutorture_get_gp_data per RCU flavor. (And hide them all behind #ifdef CONFIG_RCU_TORTURE_TEST.) Then add a get_gp_data field to rcu_torture_ops; if NULL, skip the stats. (Or put a no-op version in rcutorture.)

But that would require me to provide these same exports from TINY_RCU, which does not need them.

How about exporting integers identifying the flavors of RCU to rcutorture, which rcutorture can then pass to rcutorture_get_gp_data()? This allows TINY_RCU to provide a trivial static inline function. TREE_RCU and TREE_PREEMPT_RCU can keep an array of pointers to the corresponding rcu_state structure, with NULL pointers for flavors of RCU that don't have any data to provide.

Would that help?

Thanx, Paul

maintainer
#100 lore raw

Re: [PATCH tip/core/rcu 01/45] rcutorture: Add forward-progress checking for writer

Quoted 60 lines · Paul E. McKenney
Quoted 47 lines · Josh Triplett
Quoted 46 lines · Paul E. McKenney
Quoted 31 lines · Josh Triplett
Quoted 30 lines · Paul E. McKenney
Quoted 9 lines · On Wed, May 07, 2014 at 02:16:49PM -0700, [email protected] wrote:
Quoted 8 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The rcutorture output currently does not distinguish between stalls in the RCU implementation and stalls in the rcu_torture_writer() kthreads. This commit therefore adds some diagnostics to help distinguish between these two conditions, at least for the non-SRCU implementations. (SRCU does not provide evidence of update-side forward progress by design.)

Quoted 8 lines
Quoted 1 line

The concept makes sense, and the writer state annotations seem like a useful debugging mechanism, but having RCU know about RCU torture types seems fundamentally wrong. This mechanism accesses rcu_state, which is already implementation-specific, so why not just only define the function for the RCU implementations that support it, and then have a function pointer in the torture-test structure to report a stall?

Ouch. It is worse than that! When running RCU-bh or RCU-sched, the current code incorrectly returns the statistics for RCU. So I do need some way for rcutorture to tell RCU which flavor it is testing.

One thing I could do would be to pass in a pointer to the call_rcu() function (cur_ops->call from rcutorture's viewpoint), then scan the rcu_state structures looking for the selected flavor (rsp->call from tree.c's viewpoint). In the SRCU and RCU-busted cases, the flavor would not be found, and I could then just set everything to zero.

Quoted 5 lines
Quoted 1 line

Does that seem reasonable, or is there a better way to do this?

That search seems rather too hackish; why not just declare one stats-returning function per RCU flavor, and put the pointer to the corresponding function in the structure for each test type?

The problem is that rcutorture doesn't know anything about the structures, as those are internal to the implementation. All it knows is which functions it is using. I -could- EXPORT_SYMBOL_GPL() the rcu_state structures to modules (they are already non-static), then rename TINY_RCU's rcu_ctrlblk to rcu_state to allow the needed type punning, then do some special-case thing for SRCU, and put a pointer to whatever in rcu_torture_ops, but that was feeling a bit hackish as well.

Quoted 8 lines
Quoted 2 lines

So what did you have in mind to allow rcutorture to communicate the rcuflavor to the underlying RCU implementation?

Rather than EXPORT_SYMBOL_GPLing the rcu_state structures, just EXPORT_SYMBOL_GPL one version of rcutorture_get_gp_data per RCU flavor. (And hide them all behind #ifdef CONFIG_RCU_TORTURE_TEST.) Then add a get_gp_data field to rcu_torture_ops; if NULL, skip the stats. (Or put a no-op version in rcutorture.)

But that would require me to provide these same exports from TINY_RCU, which does not need them.

Quoted 8 lines

How about exporting integers identifying the flavors of RCU to rcutorture, which rcutorture can then pass to rcutorture_get_gp_data()? This allows TINY_RCU to provide a trivial static inline function. TREE_RCU and TREE_PREEMPT_RCU can keep an array of pointers to the corresponding rcu_state structure, with NULL pointers for flavors of RCU that don't have any data to provide.

Would that help?

Either way seems fine: a single function with an extra parameter or a unique function per flavor. But if you're going to provide the RCU-flavor integers, they should be in RCU itself and refer to RCU flavors, rather than being in rcutorture and refering to test types.

- Josh Triplett

#101 lore raw

Re: [PATCH tip/core/rcu 01/45] rcutorture: Add forward-progress checking for writer

Quoted 68 lines · Josh Triplett
Quoted 67 lines · Paul E. McKenney
Quoted 47 lines · Josh Triplett
Quoted 46 lines · Paul E. McKenney
Quoted 31 lines · Josh Triplett
Quoted 30 lines · Paul E. McKenney
Quoted 9 lines · On Wed, May 07, 2014 at 02:16:49PM -0700, [email protected] wrote:
Quoted 8 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The rcutorture output currently does not distinguish between stalls in the RCU implementation and stalls in the rcu_torture_writer() kthreads. This commit therefore adds some diagnostics to help distinguish between these two conditions, at least for the non-SRCU implementations. (SRCU does not provide evidence of update-side forward progress by design.)

Quoted 8 lines
Quoted 1 line

The concept makes sense, and the writer state annotations seem like a useful debugging mechanism, but having RCU know about RCU torture types seems fundamentally wrong. This mechanism accesses rcu_state, which is already implementation-specific, so why not just only define the function for the RCU implementations that support it, and then have a function pointer in the torture-test structure to report a stall?

Ouch. It is worse than that! When running RCU-bh or RCU-sched, the current code incorrectly returns the statistics for RCU. So I do need some way for rcutorture to tell RCU which flavor it is testing.

One thing I could do would be to pass in a pointer to the call_rcu() function (cur_ops->call from rcutorture's viewpoint), then scan the rcu_state structures looking for the selected flavor (rsp->call from tree.c's viewpoint). In the SRCU and RCU-busted cases, the flavor would not be found, and I could then just set everything to zero.

Quoted 5 lines
Quoted 1 line

Does that seem reasonable, or is there a better way to do this?

That search seems rather too hackish; why not just declare one stats-returning function per RCU flavor, and put the pointer to the corresponding function in the structure for each test type?

The problem is that rcutorture doesn't know anything about the structures, as those are internal to the implementation. All it knows is which functions it is using. I -could- EXPORT_SYMBOL_GPL() the rcu_state structures to modules (they are already non-static), then rename TINY_RCU's rcu_ctrlblk to rcu_state to allow the needed type punning, then do some special-case thing for SRCU, and put a pointer to whatever in rcu_torture_ops, but that was feeling a bit hackish as well.

Quoted 8 lines
Quoted 2 lines

So what did you have in mind to allow rcutorture to communicate the rcuflavor to the underlying RCU implementation?

Rather than EXPORT_SYMBOL_GPLing the rcu_state structures, just EXPORT_SYMBOL_GPL one version of rcutorture_get_gp_data per RCU flavor. (And hide them all behind #ifdef CONFIG_RCU_TORTURE_TEST.) Then add a get_gp_data field to rcu_torture_ops; if NULL, skip the stats. (Or put a no-op version in rcutorture.)

But that would require me to provide these same exports from TINY_RCU, which does not need them.

How about exporting integers identifying the flavors of RCU to rcutorture, which rcutorture can then pass to rcutorture_get_gp_data()? This allows TINY_RCU to provide a trivial static inline function. TREE_RCU and TREE_PREEMPT_RCU can keep an array of pointers to the corresponding rcu_state structure, with NULL pointers for flavors of RCU that don't have any data to provide.

Quoted 6 lines
Quoted 1 line

Would that help?

Either way seems fine: a single function with an extra parameter or a unique function per flavor. But if you're going to provide the RCU-flavor integers, they should be in RCU itself and refer to RCU flavors, rather than being in rcutorture and refering to test types.

Fair enough, will take that approach!

I am thinking in terms of something like the following:

RCU_FLAVOR
RCU_BH_FLAVOR
RCU_SCHED_FLAVOR
SRCU_FLAVOR
OTHER_FLAVOR

The "OTHER_FLAVOR" would be what rcutorture uses for the "busted" incorrect-on-purpose flavor of RCU, which is local to rcutorture.

Seem reasonable, or would some other naming scheme be better?

Thanx, Paul

#45 lore raw

Re: [PATCH tip/core/rcu 20/45] torture: Include "Stopping" string to torture_kthread_stopping()

In reply to [email protected]
Quoted 34 lines · On Wed, May 07, 2014 at 02:37:36PM -0700, [email protected] wrote:
Quoted 7 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Currently, torture_kthread_stopping() prints only the name of the kthread that is stopping, which can be unedifying. This commit therefore adds "Stopping" to make things more evident.

Feedback below.

Quoted 8 lines
 kernel/torture.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/torture.c +0 -0
index acc9afc2f26e..f329848c3eee 100644

kernel/torture.c EXPORT_SYMBOL_GPL(torture_must_stop_irq); · line 681

Quoted 9 lines
kernel/torture.c +4 -1
@@ -674,8 +674,11 @@ EXPORT_SYMBOL_GPL(torture_must_stop_irq);
  */
 void torture_kthread_stopping(char *title)
 {
+	char buf[128];
+
+	snprintf(buf, sizeof(buf), "Stopping %s", title);
 	if (verbose)
-		VERBOSE_TOROUT_STRING(title);
+		VERBOSE_TOROUT_STRING(buf);

This seems like a case where the macro has led to poorer code; rather than using sprintf into a temporary buffer, this should just print. Please consider fixing the output macros to allow formats, as the pr_* macros do.

Quoted 4 lines

Also, why do you need "if (verbose)" if the name of the macro has VERBOSE_ in it; shouldn't that mean it checks verbosity itself? (Another good reason not to create a unique verbosity level mechanism, and to use the kernel mechanisms instead.)

Good catch, removed the redundant "if (verbose)".

My attempts in the past to leverage existing in-kernel verbosity controls has caused problems such as the output appearing or not depending on the distro in question.

Thanx, Paul

Quoted 7 lines
Quoted 6 lines
kernel/torture.c +0 -0
 	while (!kthread_should_stop()) {
 		torture_shutdown_absorb(title);
 		schedule_timeout_uninterruptible(1);
Signature · 1 line
1.8.1.5
maintainer
#102 lore raw

Re: [PATCH tip/core/rcu 01/45] rcutorture: Add forward-progress checking for writer

In reply to Paul E. McKenney
Quoted 86 lines · Paul E. McKenney
Quoted 68 lines · Josh Triplett
Quoted 67 lines · Paul E. McKenney
Quoted 47 lines · Josh Triplett
Quoted 46 lines · Paul E. McKenney
Quoted 31 lines · Josh Triplett
Quoted 30 lines · Paul E. McKenney
Quoted 9 lines · On Wed, May 07, 2014 at 02:16:49PM -0700, [email protected] wrote:
Quoted 8 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The rcutorture output currently does not distinguish between stalls in the RCU implementation and stalls in the rcu_torture_writer() kthreads. This commit therefore adds some diagnostics to help distinguish between these two conditions, at least for the non-SRCU implementations. (SRCU does not provide evidence of update-side forward progress by design.)

Quoted 8 lines
Quoted 1 line

The concept makes sense, and the writer state annotations seem like a useful debugging mechanism, but having RCU know about RCU torture types seems fundamentally wrong. This mechanism accesses rcu_state, which is already implementation-specific, so why not just only define the function for the RCU implementations that support it, and then have a function pointer in the torture-test structure to report a stall?

Ouch. It is worse than that! When running RCU-bh or RCU-sched, the current code incorrectly returns the statistics for RCU. So I do need some way for rcutorture to tell RCU which flavor it is testing.

One thing I could do would be to pass in a pointer to the call_rcu() function (cur_ops->call from rcutorture's viewpoint), then scan the rcu_state structures looking for the selected flavor (rsp->call from tree.c's viewpoint). In the SRCU and RCU-busted cases, the flavor would not be found, and I could then just set everything to zero.

Quoted 5 lines
Quoted 1 line

Does that seem reasonable, or is there a better way to do this?

That search seems rather too hackish; why not just declare one stats-returning function per RCU flavor, and put the pointer to the corresponding function in the structure for each test type?

The problem is that rcutorture doesn't know anything about the structures, as those are internal to the implementation. All it knows is which functions it is using. I -could- EXPORT_SYMBOL_GPL() the rcu_state structures to modules (they are already non-static), then rename TINY_RCU's rcu_ctrlblk to rcu_state to allow the needed type punning, then do some special-case thing for SRCU, and put a pointer to whatever in rcu_torture_ops, but that was feeling a bit hackish as well.

Quoted 8 lines
Quoted 2 lines

So what did you have in mind to allow rcutorture to communicate the rcuflavor to the underlying RCU implementation?

Rather than EXPORT_SYMBOL_GPLing the rcu_state structures, just EXPORT_SYMBOL_GPL one version of rcutorture_get_gp_data per RCU flavor. (And hide them all behind #ifdef CONFIG_RCU_TORTURE_TEST.) Then add a get_gp_data field to rcu_torture_ops; if NULL, skip the stats. (Or put a no-op version in rcutorture.)

But that would require me to provide these same exports from TINY_RCU, which does not need them.

How about exporting integers identifying the flavors of RCU to rcutorture, which rcutorture can then pass to rcutorture_get_gp_data()? This allows TINY_RCU to provide a trivial static inline function. TREE_RCU and TREE_PREEMPT_RCU can keep an array of pointers to the corresponding rcu_state structure, with NULL pointers for flavors of RCU that don't have any data to provide.

Quoted 6 lines
Quoted 1 line

Would that help?

Either way seems fine: a single function with an extra parameter or a unique function per flavor. But if you're going to provide the RCU-flavor integers, they should be in RCU itself and refer to RCU flavors, rather than being in rcutorture and refering to test types.

Fair enough, will take that approach!

I am thinking in terms of something like the following:

RCU_FLAVOR
RCU_BH_FLAVOR
RCU_SCHED_FLAVOR
SRCU_FLAVOR
OTHER_FLAVOR

Quoted 4 lines

The "OTHER_FLAVOR" would be what rcutorture uses for the "busted" incorrect-on-purpose flavor of RCU, which is local to rcutorture.

Seem reasonable, or would some other naming scheme be better?

Seems reasonable to me. I'd call the last one "INVALID_RCU_FLAVOR" or similar.

- Josh Triplett

maintainer
#46 lore raw

Re: [PATCH tip/core/rcu 20/45] torture: Include "Stopping" string to torture_kthread_stopping()

In reply to Paul E. McKenney
Quoted 40 lines · Paul E. McKenney
Quoted 34 lines · On Wed, May 07, 2014 at 02:37:36PM -0700, [email protected] wrote:
Quoted 7 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Currently, torture_kthread_stopping() prints only the name of the kthread that is stopping, which can be unedifying. This commit therefore adds "Stopping" to make things more evident.

Feedback below.

Quoted 8 lines
 kernel/torture.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/torture.c +0 -0
index acc9afc2f26e..f329848c3eee 100644

kernel/torture.c EXPORT_SYMBOL_GPL(torture_must_stop_irq); · line 681

Quoted 9 lines
kernel/torture.c +4 -1
@@ -674,8 +674,11 @@ EXPORT_SYMBOL_GPL(torture_must_stop_irq);
  */
 void torture_kthread_stopping(char *title)
 {
+	char buf[128];
+
+	snprintf(buf, sizeof(buf), "Stopping %s", title);
 	if (verbose)
-		VERBOSE_TOROUT_STRING(title);
+		VERBOSE_TOROUT_STRING(buf);

This seems like a case where the macro has led to poorer code; rather than using sprintf into a temporary buffer, this should just print. Please consider fixing the output macros to allow formats, as the pr_* macros do.

Quoted 4 lines

Also, why do you need "if (verbose)" if the name of the macro has VERBOSE_ in it; shouldn't that mean it checks verbosity itself? (Another good reason not to create a unique verbosity level mechanism, and to use the kernel mechanisms instead.)

Quoted 5 lines

Good catch, removed the redundant "if (verbose)".

My attempts in the past to leverage existing in-kernel verbosity controls has caused problems such as the output appearing or not depending on the distro in question.

That aside, though, what do you think about making the macros accept format strings and arguments, in the style of pr_* and pr_fmt?

- Josh Trpilett

#57 lore raw

Re: [PATCH tip/core/rcu 24/45] torture: Choose bzImage location based on architecture

In reply to [email protected]
Quoted 40 lines · On Wed, May 07, 2014 at 03:02:46PM -0700, [email protected] wrote:
Quoted 10 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Currently, the scripts hard-code arch/x86/boot/bzImage, which does not work well for other architectures. This commit therefore provides a identify_boot_image function that selects the correct bzImage location relative to the top of the Linux source tree. This commit also adds a --bootimage argument that allows selecting some other file, for example, "vmlinux".

Two issues below; with those fixed,

Quoted 25 lines
 tools/testing/selftests/rcutorture/bin/functions.sh | 21 +++++++++++++++++++++
 .../selftests/rcutorture/bin/kvm-test-1-run.sh      | 11 +++++------
 tools/testing/selftests/rcutorture/bin/kvm.sh       |  8 ++++++++
 3 files changed, 34 insertions(+), 6 deletions(-)
tools/testing/selftests/rcutorture/bin/functions.sh +12 -0
index 6b2adb29b073..efa95867e1cc 100644
@@ -76,6 +76,27 @@ configfrag_hotplug_cpu () {
 	grep -q '^CONFIG_HOTPLUG_CPU=y$' "$1"
 }
 
+# identify_boot_image qemu-cmd
+#
+# Returns the relative path to the kernel build image.  This will be
+# arch/<arch>/boot/bzImage unless overridden with the TORTURE_BOOT_IMAGE
+# environment variable.
+identify_boot_image () {
+	if test -n "$TORTURE_BOOT_IMAGE"
+	then
+		echo $TORTURE_BOOT_IMAGE
+	else
+		case "$1" in
+		qemu-system-x86_64|qemu-system-i386)
Quoted 8 lines

tools/testing/selftests/rcutorture/bin/functions.sh configfrag_hotplug_cpu () { · line 95

Quoted 5 lines
tools/testing/selftests/rcutorture/bin/functions.sh +5 -0
+			echo arch/x86/boot/bzImage
+			;;
+		qemu-system-ppc64)
+			echo arch/powerpc/boot/bzImage
+			;;

*)
(fail noisily rather than silently)

Good point, fixed here and in kvm-test-1-run.sh.

Quoted 28 lines
Quoted 28 lines
tools/testing/selftests/rcutorture/bin/functions.sh +4 -0
+		esac
+	fi
+}
+
 # identify_qemu builddir
 #
 # Returns our best guess as to which qemu command is appropriate for
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +3 -1
index 7848227aa4c1..7a95f86cc85a 100755
@@ -94,9 +94,11 @@ fi
 # CONFIG_YENTA=n
 if kvm-build.sh $config_template $builddir $T
 then
+	QEMU="`identify_qemu $builddir/vmlinux`"
+	BOOT_IMAGE="`identify_boot_image $QEMU`"
 	cp $builddir/Make*.out $resdir
 	cp $builddir/.config $resdir
-	cp $builddir/arch/x86/boot/bzImage $resdir
+	cp $builddir/$BOOT_IMAGE $resdir
 	parse-build.sh $resdir/Make.out $title
 	if test -f $builddir.wait
 	then
@@ -124,9 +126,6 @@ cd $KVM
 kstarttime=`awk 'BEGIN { print systime() }' < /dev/null`
 echo ' ---' `date`: Starting kernel
 
Quoted 5 lines

tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh cd $KVM · line 129

Quoted 3 lines
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +0 -3
-# Determine the appropriate flavor of qemu command.
-QEMU="`identify_qemu $builddir/vmlinux`"
-

This change seems related but undocumented.

Ah, the value of QEMU is needed above to figure out where to look for the image. Added a sentence to that effect to the changelog.

Thanx, Paul

Quoted 63 lines
Quoted 62 lines
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +2 -2
 # Generate -smp qemu argument.
 qemu_args="-nographic $qemu_args"
 cpu_count=`configNR_CPUS.sh $config_template`
@@ -151,13 +150,13 @@ boot_args="`configfrag_boot_params "$boot_args" "$config_template"`"
 # Generate kernel-version-specific boot parameters
 boot_args="`per_version_boot_params "$boot_args" $builddir/.config $seconds`"
 
-echo $QEMU $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd
+echo $QEMU $qemu_args -m 512 -kernel $builddir/$BOOT_IMAGE -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd
 if test -n "$TORTURE_BUILDONLY"
 then
 	echo Build-only run specified, boot/test omitted.
 	exit 0
 fi
-$QEMU $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append "$qemu_append $boot_args"; echo $? > $resdir/qemu-retval &
+$QEMU $qemu_args -m 512 -kernel $builddir/$BOOT_IMAGE -append "$qemu_append $boot_args"; echo $? > $resdir/qemu-retval &
 qemu_pid=$!
 commandcompleted=0
 echo Monitoring qemu job at pid $qemu_pid
tools/testing/selftests/rcutorture/bin/kvm.sh +8 -0
index 9b838c372698..4eed2a4f42c7 100644
@@ -39,6 +39,7 @@ dryrun=""
 KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
 PATH=${KVM}/bin:$PATH; export PATH
 TORTURE_DEFCONFIG=defconfig
+TORTURE_BOOT_IMAGE=""
 TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
 TORTURE_KMAKE_ARG=""
 TORTURE_SUITE=rcu
@@ -53,6 +54,7 @@ kversion=""
 usage () {
 	echo "Usage: $scriptname optional arguments:"
 	echo "       --bootargs kernel-boot-arguments"
+	echo "       --bootimage relative-path-to-kernel-boot-image"
 	echo "       --buildonly"
 	echo "       --configs \"config-file list\""
 	echo "       --cpus N"
@@ -80,6 +82,11 @@ do
 		TORTURE_BOOTARGS="$2"
 		shift
 		;;
+	--bootimage)
+		checkarg --bootimage "(relative path to kernel boot image)" "$#" "$2" '[a-zA-Z0-9][a-zA-Z0-9_]*' '^--'
+		TORTURE_BOOT_IMAGE="$2"
+		shift
+		;;
 	--buildonly)
 		TORTURE_BUILDONLY=1
 		;;
@@ -245,6 +252,7 @@ CONFIGFRAG="$CONFIGFRAG"; export CONFIGFRAG
 KVM="$KVM"; export KVM
 KVPATH="$KVPATH"; export KVPATH
 PATH="$PATH"; export PATH
+TORTURE_BOOT_IMAGE="$TORTURE_BOOT_IMAGE"; export TORTURE_BOOT_IMAGE
 TORTURE_BUILDONLY="$TORTURE_BUILDONLY"; export TORTURE_BUILDONLY
 TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG
 TORTURE_INITRD="$TORTURE_INITRD"; export TORTURE_INITRD
Signature · 1 line
1.8.1.5
#103 lore raw

Re: [PATCH tip/core/rcu 01/45] rcutorture: Add forward-progress checking for writer

In reply to Josh Triplett
Quoted 87 lines · Josh Triplett
Quoted 86 lines · Paul E. McKenney
Quoted 68 lines · Josh Triplett
Quoted 67 lines · Paul E. McKenney
Quoted 47 lines · Josh Triplett
Quoted 46 lines · Paul E. McKenney
Quoted 31 lines · Josh Triplett
Quoted 30 lines · Paul E. McKenney
Quoted 9 lines · On Wed, May 07, 2014 at 02:16:49PM -0700, [email protected] wrote:
Quoted 8 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The rcutorture output currently does not distinguish between stalls in the RCU implementation and stalls in the rcu_torture_writer() kthreads. This commit therefore adds some diagnostics to help distinguish between these two conditions, at least for the non-SRCU implementations. (SRCU does not provide evidence of update-side forward progress by design.)

Quoted 8 lines
Quoted 1 line

The concept makes sense, and the writer state annotations seem like a useful debugging mechanism, but having RCU know about RCU torture types seems fundamentally wrong. This mechanism accesses rcu_state, which is already implementation-specific, so why not just only define the function for the RCU implementations that support it, and then have a function pointer in the torture-test structure to report a stall?

Ouch. It is worse than that! When running RCU-bh or RCU-sched, the current code incorrectly returns the statistics for RCU. So I do need some way for rcutorture to tell RCU which flavor it is testing.

One thing I could do would be to pass in a pointer to the call_rcu() function (cur_ops->call from rcutorture's viewpoint), then scan the rcu_state structures looking for the selected flavor (rsp->call from tree.c's viewpoint). In the SRCU and RCU-busted cases, the flavor would not be found, and I could then just set everything to zero.

Quoted 5 lines
Quoted 1 line

Does that seem reasonable, or is there a better way to do this?

That search seems rather too hackish; why not just declare one stats-returning function per RCU flavor, and put the pointer to the corresponding function in the structure for each test type?

The problem is that rcutorture doesn't know anything about the structures, as those are internal to the implementation. All it knows is which functions it is using. I -could- EXPORT_SYMBOL_GPL() the rcu_state structures to modules (they are already non-static), then rename TINY_RCU's rcu_ctrlblk to rcu_state to allow the needed type punning, then do some special-case thing for SRCU, and put a pointer to whatever in rcu_torture_ops, but that was feeling a bit hackish as well.

Quoted 8 lines
Quoted 2 lines

So what did you have in mind to allow rcutorture to communicate the rcuflavor to the underlying RCU implementation?

Rather than EXPORT_SYMBOL_GPLing the rcu_state structures, just EXPORT_SYMBOL_GPL one version of rcutorture_get_gp_data per RCU flavor. (And hide them all behind #ifdef CONFIG_RCU_TORTURE_TEST.) Then add a get_gp_data field to rcu_torture_ops; if NULL, skip the stats. (Or put a no-op version in rcutorture.)

But that would require me to provide these same exports from TINY_RCU, which does not need them.

How about exporting integers identifying the flavors of RCU to rcutorture, which rcutorture can then pass to rcutorture_get_gp_data()? This allows TINY_RCU to provide a trivial static inline function. TREE_RCU and TREE_PREEMPT_RCU can keep an array of pointers to the corresponding rcu_state structure, with NULL pointers for flavors of RCU that don't have any data to provide.

Quoted 6 lines
Quoted 1 line

Would that help?

Either way seems fine: a single function with an extra parameter or a unique function per flavor. But if you're going to provide the RCU-flavor integers, they should be in RCU itself and refer to RCU flavors, rather than being in rcutorture and refering to test types.

Fair enough, will take that approach!

I am thinking in terms of something like the following:

RCU_FLAVOR
RCU_BH_FLAVOR
RCU_SCHED_FLAVOR
SRCU_FLAVOR
OTHER_FLAVOR

Quoted 7 lines
Quoted 4 lines

The "OTHER_FLAVOR" would be what rcutorture uses for the "busted" incorrect-on-purpose flavor of RCU, which is local to rcutorture.

Seem reasonable, or would some other naming scheme be better?

Seems reasonable to me. I'd call the last one "INVALID_RCU_FLAVOR" or similar.

Even better!

Thanx, Paul

#62 lore raw

Re: [PATCH tip/core/rcu 27/45] rcutorture: Export RCU grace-period kthread wait state to rcutorture

In reply to [email protected]
Quoted 10 lines · On Wed, May 07, 2014 at 03:05:31PM -0700, [email protected] wrote:
Quoted 7 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit allows rcutorture to print additional state for the RCU grace-period kthreads in cases where RCU seems reluctant to start a new grace period.

Should something reset gp_state after fqs finishes?

If I need more debugging info later on, yes. ;-)

Thanx, Paul

Quoted 120 lines
Quoted 117 lines
 include/linux/rcutiny.h |  4 ++++
 include/linux/rcutree.h |  1 +
 kernel/rcu/rcutorture.c |  1 +
 kernel/rcu/tree.c       | 17 +++++++++++++++++
 kernel/rcu/tree.h       |  8 +++++++-
 5 files changed, 30 insertions(+), 1 deletion(-)
include/linux/rcutiny.h +4 -0
index 425c659d54e5..d40a6a451330 100644
@@ -119,6 +119,10 @@ static inline void rcu_sched_force_quiescent_state(void)
 {
 }
 
+static inline void show_rcu_gp_kthreads(void)
+{
+}
+
 static inline void rcu_cpu_stall_reset(void)
 {
 }
include/linux/rcutree.h +1 -0
index a59ca05fd4e3..3e2f5d432743 100644
@@ -84,6 +84,7 @@ extern unsigned long rcutorture_vernum;
 long rcu_batches_completed(void);
 long rcu_batches_completed_bh(void);
 long rcu_batches_completed_sched(void);
+void show_rcu_gp_kthreads(void);
 
 void rcu_force_quiescent_state(void);
 void rcu_bh_force_quiescent_state(void);
kernel/rcu/rcutorture.c +1 -0
index 50c26a7b6d97..15af04177e7e 100644
@@ -1033,6 +1033,7 @@ rcu_torture_printk(char *page)
 				"??? Writer stall state %d g%lu c%lu f%#x\n",
 				rcu_torture_writer_state,
 				gpnum, completed, flags);
+		show_rcu_gp_kthreads();
 		rcutorture_trace_dump();
 	}
 	rtcv_snap = rcu_torture_current_version;
kernel/rcu/tree.c +17 -0
index 032106df7391..3107bd935b2b 100644
@@ -280,6 +280,21 @@ void rcu_bh_force_quiescent_state(void)
 EXPORT_SYMBOL_GPL(rcu_bh_force_quiescent_state);
 
 /*
+ * Show the state of the grace-period kthreads.
+ */
+void show_rcu_gp_kthreads(void)
+{
+	struct rcu_state *rsp;
+
+	for_each_rcu_flavor(rsp) {
+		pr_info("%s: wait state: %d ->state: %#lx\n",
+			rsp->name, rsp->gp_state, rsp->gp_kthread->state);
+		/* sched_show_task(rsp->gp_kthread); */
+	}
+}
+EXPORT_SYMBOL_GPL(show_rcu_gp_kthreads);
+
+/*
  * Record the number of times rcutorture tests have been initiated and
  * terminated.  This information allows the debugfs tracing stats to be
  * correlated to the rcutorture messages, even when the rcutorture module
@@ -1611,6 +1626,7 @@ static int __noreturn rcu_gp_kthread(void *arg)
 			trace_rcu_grace_period(rsp->name,
 					       ACCESS_ONCE(rsp->gpnum),
 					       TPS("reqwait"));
+			rsp->gp_state = RCU_GP_WAIT_GPS;
 			wait_event_interruptible(rsp->gp_wq,
 						 ACCESS_ONCE(rsp->gp_flags) &
 						 RCU_GP_FLAG_INIT);
@@ -1638,6 +1654,7 @@ static int __noreturn rcu_gp_kthread(void *arg)
 			trace_rcu_grace_period(rsp->name,
 					       ACCESS_ONCE(rsp->gpnum),
 					       TPS("fqswait"));
+			rsp->gp_state = RCU_GP_WAIT_FQS;
 			ret = wait_event_interruptible_timeout(rsp->gp_wq,
 					((gf = ACCESS_ONCE(rsp->gp_flags)) &
 					 RCU_GP_FLAG_FQS) ||
kernel/rcu/tree.h +7 -1
index 75dc3c39a02a..c2fd1e722879 100644
@@ -406,7 +406,8 @@ struct rcu_state {
 	unsigned long completed;		/* # of last completed gp. */
 	struct task_struct *gp_kthread;		/* Task for grace periods. */
 	wait_queue_head_t gp_wq;		/* Where GP task waits. */
-	int gp_flags;				/* Commands for GP task. */
+	short gp_flags;				/* Commands for GP task. */
+	short gp_state;				/* GP kthread sleep state. */
 
 	/* End of fields guarded by root rcu_node's lock. */
 
@@ -469,6 +470,11 @@ struct rcu_state {
 #define RCU_GP_FLAG_INIT 0x1	/* Need grace-period initialization. */
 #define RCU_GP_FLAG_FQS  0x2	/* Need grace-period quiescent-state forcing. */
 
+/* Values for rcu_state structure's gp_flags field. */
+#define RCU_GP_WAIT_INIT 0	/* Initial state. */
+#define RCU_GP_WAIT_GPS  1	/* Wait for grace-period start. */
+#define RCU_GP_WAIT_FQS  2	/* Wait for force-quiescent-state time. */
+
 extern struct list_head rcu_struct_flavors;
 
 /* Sequence through rcu_state structures for each RCU flavor. */
Signature · 1 line
1.8.1.5
#47 lore raw

Re: [PATCH tip/core/rcu 20/45] torture: Include "Stopping" string to torture_kthread_stopping()

In reply to Josh Triplett
Quoted 41 lines · Josh Triplett
Quoted 40 lines · Paul E. McKenney
Quoted 38 lines · On Wed, May 07, 2014 at 02:37:36PM -0700, [email protected] wrote:
Quoted 7 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Currently, torture_kthread_stopping() prints only the name of the kthread that is stopping, which can be unedifying. This commit therefore adds "Stopping" to make things more evident.

Feedback below.

Quoted 8 lines
 kernel/torture.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/torture.c +0 -0
index acc9afc2f26e..f329848c3eee 100644

kernel/torture.c EXPORT_SYMBOL_GPL(torture_must_stop_irq); · line 681

Quoted 9 lines
kernel/torture.c +4 -1
@@ -674,8 +674,11 @@ EXPORT_SYMBOL_GPL(torture_must_stop_irq);
  */
 void torture_kthread_stopping(char *title)
 {
+	char buf[128];
+
+	snprintf(buf, sizeof(buf), "Stopping %s", title);
 	if (verbose)
-		VERBOSE_TOROUT_STRING(title);
+		VERBOSE_TOROUT_STRING(buf);

This seems like a case where the macro has led to poorer code; rather than using sprintf into a temporary buffer, this should just print. Please consider fixing the output macros to allow formats, as the pr_* macros do.

Also, why do you need "if (verbose)" if the name of the macro has VERBOSE_ in it; shouldn't that mean it checks verbosity itself? (Another good reason not to create a unique verbosity level mechanism, and to use the kernel mechanisms instead.)

Quoted 8 lines
Quoted 5 lines

Good catch, removed the redundant "if (verbose)".

My attempts in the past to leverage existing in-kernel verbosity controls has caused problems such as the output appearing or not depending on the distro in question.

That aside, though, what do you think about making the macros accept format strings and arguments, in the style of pr_* and pr_fmt?

If I end up needing this in a few more cases, then it would indeed be worth it.

Thanx, Paul

#69 lore raw

Re: [PATCH tip/core/rcu 32/45] torture: Better summary diagnostics for build failures

In reply to [email protected]
Quoted 9 lines · On Wed, May 07, 2014 at 03:11:39PM -0700, [email protected] wrote:
Quoted 5 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The reaction of kvm-recheck.sh is obscure at best, and easy to miss completely. This commit therefore prints "BUG: Build failed" in the summary at the end of a run.

This commit also changes a dozen other things about the output that this commit message does not document. :)

Well, I don't know about a dozen, but I did upgrade the commit message to read as follows:

The reaction of kvm-recheck.sh is obscure at best, and easy to miss completely. This commit therefore prints "BUG: Build failed" in the summary at the end of a run. This commit also adds the line of dashes in cases where performance info is not available, and also avoids printing nonsense diagnostics in cases where some of the normal test output is not available.

Does that help?

Thanx, Paul

Quoted 93 lines
Quoted 92 lines
---
 .../selftests/rcutorture/bin/kvm-recheck-lock.sh   |  2 +-
 .../selftests/rcutorture/bin/kvm-recheck-rcu.sh    |  2 +-
 .../selftests/rcutorture/bin/kvm-recheck.sh        | 24 ++++++++++++++++------
 .../selftests/rcutorture/bin/kvm-test-1-run.sh     |  1 +
 4 files changed, 21 insertions(+), 8 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-recheck-lock.sh +1 -1
index 829186e19eb1..7f1ff1a8fc4b 100755
@@ -35,7 +35,7 @@ configfile=`echo $i | sed -e 's/^.*\///'`
 ncs=`grep "Writes:  Total:" $i/console.log 2> /dev/null | tail -1 | sed -e 's/^.* Total: //' -e 's/ .*$//'`
 if test -z "$ncs"
 then
-	echo $configfile
+	echo "$configfile -------"
 else
 	title="$configfile ------- $ncs acquisitions/releases"
 	dur=`sed -e 's/^.* locktorture.shutdown_secs=//' -e 's/ .*$//' < $i/qemu-cmd 2> /dev/null`
tools/testing/selftests/rcutorture/bin/kvm-recheck-rcu.sh +1 -1
index d75b1dc5ae53..307c4b95f325 100755
@@ -35,7 +35,7 @@ configfile=`echo $i | sed -e 's/^.*\///'`
 ngps=`grep ver: $i/console.log 2> /dev/null | tail -1 | sed -e 's/^.* ver: //' -e 's/ .*$//'`
 if test -z "$ngps"
 then
-	echo $configfile
+	echo "$configfile -------"
 else
 	title="$configfile ------- $ngps grace periods"
 	dur=`sed -e 's/^.* rcutorture.shutdown_secs=//' -e 's/ .*$//' < $i/qemu-cmd 2> /dev/null`
tools/testing/selftests/rcutorture/bin/kvm-recheck.sh +18 -6
index 26d78b7eaccf..ee1f6cae3d70 100755
@@ -25,6 +25,7 @@
 # Authors: Paul E. McKenney <[email protected]>
 
 PATH=`pwd`/tools/testing/selftests/rcutorture/bin:$PATH; export PATH
+. tools/testing/selftests/rcutorture/bin/functions.sh
 for rd in "$@"
 do
 	firsttime=1
@@ -39,13 +40,24 @@ do
 		fi
 		TORTURE_SUITE="`cat $i/../TORTURE_SUITE`"
 		kvm-recheck-${TORTURE_SUITE}.sh $i
-		configcheck.sh $i/.config $i/ConfigFragment
-		parse-build.sh $i/Make.out $configfile
-		parse-torture.sh $i/console.log $configfile
-		parse-console.sh $i/console.log $configfile
-		if test -r $i/Warnings
+		if test -f "$i/console.log"
 		then
-			cat $i/Warnings
+			configcheck.sh $i/.config $i/ConfigFragment
+			parse-build.sh $i/Make.out $configfile
+			parse-torture.sh $i/console.log $configfile
+			parse-console.sh $i/console.log $configfile
+			if test -r $i/Warnings
+			then
+				cat $i/Warnings
+			fi
+		else
+			if test -f "$i/qemu-cmd"
+			then
+				print_bug qemu failed
+			else
+				print_bug Build failed
+			fi
+			echo "   $i"
 		fi
 	done
 done
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +1 -0
index 7a95f86cc85a..51c34a91a375 100755
@@ -106,6 +106,7 @@ then
 	fi
 else
 	cp $builddir/Make*.out $resdir
+	cp $builddir/.config $resdir || :
 	echo Build failed, not running KVM, see $resdir.
 	if test -f $builddir.wait
 	then
Signature · 1 line
1.8.1.5
#82 lore raw

Re: [PATCH tip/core/rcu 39/45] rcutorture: Note diffs from git commits

In reply to [email protected]
Quoted 18 lines · On Wed, May 07, 2014 at 03:17:42PM -0700, [email protected] wrote:
Quoted 9 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The current scripting only keeps track of the git SHA-1 of the current HEAD. This can cause confusion in cases where testing ran in a git tree where changes had not yet been checked in. This commit therefore also records the output of "git diff HEAD" to provide the information needed to reconstruct the source tree that was tested.

Nit below.

Quoted 4 lines
---
 tools/testing/selftests/rcutorture/bin/kvm.sh | 5 +++++
 1 file changed, 5 insertions(+)
Quoted 12 lines

tools/testing/selftests/rcutorture/bin/kvm.sh if test -d .git · line 281

Quoted 10 lines
tools/testing/selftests/rcutorture/bin/kvm.sh +2 -0
index 4eed2a4f42c7..91661845fdec 100644
@@ -277,6 +277,11 @@ if test -d .git
 then
 	git status >> $resdir/$ds/testid.txt
 	git rev-parse HEAD >> $resdir/$ds/testid.txt
+	git diff HEAD > $T/git-diff 2>&1
+	if test -s $T/git-diff

You don't need test here; you can use the return value of git diff.

Oddly enough, the "git diff" man page does not say anything about the exit value. At least not that I could find...

Thanx, Paul

Quoted 10 lines
Quoted 9 lines
tools/testing/selftests/rcutorture/bin/kvm.sh +3 -0
+	then
+		cp $T/git-diff $resdir/$ds
+	fi
 fi
 ___EOF___
 awk < $T/cfgcpu.pack \
Signature · 1 line
1.8.1.5
maintainer
#48 lore raw

Re: [PATCH tip/core/rcu 20/45] torture: Include "Stopping" string to torture_kthread_stopping()

In reply to Paul E. McKenney
Quoted 48 lines · Paul E. McKenney
Quoted 47 lines · Josh Triplett
Quoted 45 lines · Paul E. McKenney
Quoted 34 lines · On Wed, May 07, 2014 at 02:37:36PM -0700, [email protected] wrote:
Quoted 7 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Currently, torture_kthread_stopping() prints only the name of the kthread that is stopping, which can be unedifying. This commit therefore adds "Stopping" to make things more evident.

Feedback below.

Quoted 8 lines
 kernel/torture.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/torture.c +0 -0
index acc9afc2f26e..f329848c3eee 100644

kernel/torture.c EXPORT_SYMBOL_GPL(torture_must_stop_irq); · line 681

Quoted 9 lines
kernel/torture.c +4 -1
@@ -674,8 +674,11 @@ EXPORT_SYMBOL_GPL(torture_must_stop_irq);
  */
 void torture_kthread_stopping(char *title)
 {
+	char buf[128];
+
+	snprintf(buf, sizeof(buf), "Stopping %s", title);
 	if (verbose)
-		VERBOSE_TOROUT_STRING(title);
+		VERBOSE_TOROUT_STRING(buf);

This seems like a case where the macro has led to poorer code; rather than using sprintf into a temporary buffer, this should just print. Please consider fixing the output macros to allow formats, as the pr_* macros do.

Quoted 4 lines

Also, why do you need "if (verbose)" if the name of the macro has VERBOSE_ in it; shouldn't that mean it checks verbosity itself? (Another good reason not to create a unique verbosity level mechanism, and to use the kernel mechanisms instead.)

Good catch, removed the redundant "if (verbose)".

My attempts in the past to leverage existing in-kernel verbosity controls has caused problems such as the output appearing or not depending on the distro in question.

Quoted 5 lines
Quoted 2 lines

That aside, though, what do you think about making the macros accept format strings and arguments, in the style of pr_* and pr_fmt?

If I end up needing this in a few more cases, then it would indeed be worth it.

I'd argue that it's worth it already: doing snprintf into a temporary buffer seems ridiculous here, when without these macros you'd just call pr_foo("Stopping %s\n", title);

- Josh Triplett

maintainer
#83 lore raw

Re: [PATCH tip/core/rcu 39/45] rcutorture: Note diffs from git commits

In reply to Paul E. McKenney
Quoted 32 lines · Paul E. McKenney
Quoted 18 lines · On Wed, May 07, 2014 at 03:17:42PM -0700, [email protected] wrote:
Quoted 9 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The current scripting only keeps track of the git SHA-1 of the current HEAD. This can cause confusion in cases where testing ran in a git tree where changes had not yet been checked in. This commit therefore also records the output of "git diff HEAD" to provide the information needed to reconstruct the source tree that was tested.

Nit below.

Quoted 4 lines
---
 tools/testing/selftests/rcutorture/bin/kvm.sh | 5 +++++
 1 file changed, 5 insertions(+)
Quoted 12 lines

tools/testing/selftests/rcutorture/bin/kvm.sh if test -d .git · line 281

Quoted 10 lines
tools/testing/selftests/rcutorture/bin/kvm.sh +2 -0
index 4eed2a4f42c7..91661845fdec 100644
@@ -277,6 +277,11 @@ if test -d .git
 then
 	git status >> $resdir/$ds/testid.txt
 	git rev-parse HEAD >> $resdir/$ds/testid.txt
+	git diff HEAD > $T/git-diff 2>&1
+	if test -s $T/git-diff

You don't need test here; you can use the return value of git diff.

Quoted 2 lines

Oddly enough, the "git diff" man page does not say anything about the exit value. At least not that I could find...

Look for the --exit-code option of git diff.

- Josh Triplett

maintainer
#70 lore raw

Re: [PATCH tip/core/rcu 32/45] torture: Better summary diagnostics for build failures

In reply to Paul E. McKenney
Quoted 14 lines · Paul E. McKenney
Quoted 9 lines · On Wed, May 07, 2014 at 03:11:39PM -0700, [email protected] wrote:
Quoted 5 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The reaction of kvm-recheck.sh is obscure at best, and easy to miss completely. This commit therefore prints "BUG: Build failed" in the summary at the end of a run.

This commit also changes a dozen other things about the output that this commit message does not document. :)

Well, I don't know about a dozen, but I did upgrade the commit message to read as follows:

Quoted 6 lines

The reaction of kvm-recheck.sh is obscure at best, and easy to miss completely. This commit therefore prints "BUG: Build failed" in the summary at the end of a run. This commit also adds the line of dashes in cases where performance info is not available, and also avoids printing nonsense diagnostics in cases where some of the normal test output is not available.

What about the change to kvm-test-1-run.sh?

- Josh Triplett

#89 lore raw

Re: [PATCH tip/core/rcu 41/45] torture: Put qemu into the background

In reply to [email protected]
Quoted 7 lines · On Wed, May 07, 2014 at 03:18:58PM -0700, [email protected] wrote:
Quoted 6 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Currently, qemu runs in the foreground, which prevents the script from killing it in case the kernel locks up. This commit therefore places qemu into the background, allowing the script to recover from lockups.

Quoted 5 lines
Quoted 1 line

qemu originally did run in the background before this patch series; please merge this into the patch that introduces the echo and thus breaks that.

Turned out that the conflicts weren't as bad as I had feared, so done!

Thanx, Paul

Quoted 20 lines
Quoted 19 lines
 tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +1 -1
index b1e85b049075..67e89f06e77f 100755
@@ -157,7 +157,7 @@ then
 	echo Build-only run specified, boot/test omitted.
 	exit 0
 fi
-$QEMU $qemu_args -m 512 -kernel $builddir/$BOOT_IMAGE -append "$qemu_append $boot_args"; echo $? > $resdir/qemu-retval &
+( $QEMU $qemu_args -m 512 -kernel $builddir/$BOOT_IMAGE -append "$qemu_append $boot_args"; echo $? > $resdir/qemu-retval ) &
 qemu_pid=$!
 commandcompleted=0
 echo Monitoring qemu job at pid $qemu_pid
Signature · 1 line
1.8.1.5
#104 lore raw

Re: [PATCH tip/core/rcu 01/45] rcutorture: Add forward-progress checking for writer

In reply to Josh Triplett
Quoted 87 lines · Josh Triplett
Quoted 86 lines · Paul E. McKenney
Quoted 68 lines · Josh Triplett
Quoted 67 lines · Paul E. McKenney
Quoted 47 lines · Josh Triplett
Quoted 46 lines · Paul E. McKenney
Quoted 31 lines · Josh Triplett
Quoted 30 lines · Paul E. McKenney
Quoted 9 lines · On Wed, May 07, 2014 at 02:16:49PM -0700, [email protected] wrote:
Quoted 8 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The rcutorture output currently does not distinguish between stalls in the RCU implementation and stalls in the rcu_torture_writer() kthreads. This commit therefore adds some diagnostics to help distinguish between these two conditions, at least for the non-SRCU implementations. (SRCU does not provide evidence of update-side forward progress by design.)

Quoted 8 lines
Quoted 1 line

The concept makes sense, and the writer state annotations seem like a useful debugging mechanism, but having RCU know about RCU torture types seems fundamentally wrong. This mechanism accesses rcu_state, which is already implementation-specific, so why not just only define the function for the RCU implementations that support it, and then have a function pointer in the torture-test structure to report a stall?

Ouch. It is worse than that! When running RCU-bh or RCU-sched, the current code incorrectly returns the statistics for RCU. So I do need some way for rcutorture to tell RCU which flavor it is testing.

One thing I could do would be to pass in a pointer to the call_rcu() function (cur_ops->call from rcutorture's viewpoint), then scan the rcu_state structures looking for the selected flavor (rsp->call from tree.c's viewpoint). In the SRCU and RCU-busted cases, the flavor would not be found, and I could then just set everything to zero.

Quoted 5 lines
Quoted 1 line

Does that seem reasonable, or is there a better way to do this?

That search seems rather too hackish; why not just declare one stats-returning function per RCU flavor, and put the pointer to the corresponding function in the structure for each test type?

The problem is that rcutorture doesn't know anything about the structures, as those are internal to the implementation. All it knows is which functions it is using. I -could- EXPORT_SYMBOL_GPL() the rcu_state structures to modules (they are already non-static), then rename TINY_RCU's rcu_ctrlblk to rcu_state to allow the needed type punning, then do some special-case thing for SRCU, and put a pointer to whatever in rcu_torture_ops, but that was feeling a bit hackish as well.

Quoted 8 lines
Quoted 2 lines

So what did you have in mind to allow rcutorture to communicate the rcuflavor to the underlying RCU implementation?

Rather than EXPORT_SYMBOL_GPLing the rcu_state structures, just EXPORT_SYMBOL_GPL one version of rcutorture_get_gp_data per RCU flavor. (And hide them all behind #ifdef CONFIG_RCU_TORTURE_TEST.) Then add a get_gp_data field to rcu_torture_ops; if NULL, skip the stats. (Or put a no-op version in rcutorture.)

But that would require me to provide these same exports from TINY_RCU, which does not need them.

How about exporting integers identifying the flavors of RCU to rcutorture, which rcutorture can then pass to rcutorture_get_gp_data()? This allows TINY_RCU to provide a trivial static inline function. TREE_RCU and TREE_PREEMPT_RCU can keep an array of pointers to the corresponding rcu_state structure, with NULL pointers for flavors of RCU that don't have any data to provide.

Quoted 6 lines
Quoted 1 line

Would that help?

Either way seems fine: a single function with an extra parameter or a unique function per flavor. But if you're going to provide the RCU-flavor integers, they should be in RCU itself and refer to RCU flavors, rather than being in rcutorture and refering to test types.

Fair enough, will take that approach!

I am thinking in terms of something like the following:

RCU_FLAVOR
RCU_BH_FLAVOR
RCU_SCHED_FLAVOR
SRCU_FLAVOR
OTHER_FLAVOR

Quoted 7 lines
Quoted 4 lines

The "OTHER_FLAVOR" would be what rcutorture uses for the "busted" incorrect-on-purpose flavor of RCU, which is local to rcutorture.

Seem reasonable, or would some other naming scheme be better?

Seems reasonable to me. I'd call the last one "INVALID_RCU_FLAVOR" or similar.

Done!

I ended up with a switch statement rather than an array of pointers, FWIW.

Thanx, Paul

#17 lore raw

Re: [PATCH tip/core/rcu 08/45] torture: Rename RCU_KMAKE_ARG to TORTURE_KMAKE_ARG

In reply to [email protected]
Quoted 7 lines · On Wed, May 07, 2014 at 02:23:20PM -0700, [email protected] wrote:
Quoted 3 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit makes the torture scripts a bit more RCU-independent.

You've also dropped unnecessary "export" calls; please document that in the commit message. With that change:

Good catch, done!

Thanx, Paul

Quoted 56 lines
Quoted 1 line
Quoted 52 lines
---
 tools/testing/selftests/rcutorture/bin/kvm-build.sh | 2 +-
 tools/testing/selftests/rcutorture/bin/kvm.sh       | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-build.sh +1 -1
index d8e68a5e4411..e838c775f709 100755
@@ -60,7 +60,7 @@ then
 	exit 2
 fi
 ncpus=`cpus2use.sh`
-make O=$builddir -j$ncpus $RCU_KMAKE_ARG > $builddir/Make.out 2>&1
+make O=$builddir -j$ncpus $TORTURE_KMAKE_ARG > $builddir/Make.out 2>&1
 retval=$?
 if test $retval -ne 0 || grep "rcu[^/]*": < $builddir/Make.out | egrep -q "Stop|Error|error:|warning:" || egrep -q "Stop|Error|error:" < $builddir/Make.out
 then
tools/testing/selftests/rcutorture/bin/kvm.sh +3 -3
index 59945b7793d9..04ad1f980dfe 100644
@@ -40,7 +40,7 @@ KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
 PATH=${KVM}/bin:$PATH; export PATH
 TORTURE_DEFCONFIG=defconfig
 TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
-RCU_KMAKE_ARG=""; export RCU_KMAKE_ARG
+TORTURE_KMAKE_ARG=""
 TORTURE_SUITE=rcu
 resdir=""
 configs=""
@@ -118,7 +118,7 @@ do
 		;;
 	--kmake-arg)
 		checkarg --kmake-arg "(kernel make arguments)" $# "$2" '.*' '^error$'
-		RCU_KMAKE_ARG="$2"; export RCU_KMAKE_ARG
+		TORTURE_KMAKE_ARG="$2"
 		shift
 		;;
 	--kversion)
@@ -376,7 +376,7 @@ then
 	echo PATH="$PATH; export PATH"
 	echo RCU_BUILDONLY="$RCU_BUILDONLY; export RCU_BUILDONLY"
 	echo TORTURE_INITRD="$TORTURE_INITRD; export TORTURE_INITRD"
-	echo RCU_KMAKE_ARG="$RCU_KMAKE_ARG; export RCU_KMAKE_ARG"
+	echo TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG; export TORTURE_KMAKE_ARG"
 	echo RCU_QEMU_CMD="$RCU_QEMU_CMD; export RCU_QEMU_CMD"
 	echo RCU_QEMU_INTERACTIVE="$RCU_QEMU_INTERACTIVE; export RCU_QEMU_INTERACTIVE"
 	echo RCU_QEMU_MAC="$RCU_QEMU_MAC; export RCU_QEMU_MAC"
Signature · 1 line
1.8.1.5
#21 lore raw

Re: [PATCH tip/core/rcu 10/45] torture: Rename RCU_BUILDONLY to TORTURE_BUILDONLY

In reply to [email protected]
Quoted 7 lines · On Wed, May 07, 2014 at 02:24:03PM -0700, [email protected] wrote:
Quoted 3 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

This commit makes the torture scripts a bit more RCU-independent.

And removes unnecessary exports; please document that. With that change:

Good eyes, fixes!

Thanx, Paul

Quoted 56 lines
Quoted 1 line
Quoted 52 lines
---
 tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 2 +-
 tools/testing/selftests/rcutorture/bin/kvm.sh            | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +1 -1
index e82f4f201c8c..86e6ffe6df45 100755
@@ -152,7 +152,7 @@ boot_args="`configfrag_boot_params "$boot_args" "$config_template"`"
 boot_args="`per_version_boot_params "$boot_args" $builddir/.config $seconds`"
 
 echo $QEMU $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd
-if test -n "$RCU_BUILDONLY"
+if test -n "$TORTURE_BUILDONLY"
 then
 	echo Build-only run specified, boot/test omitted.
 	exit 0
tools/testing/selftests/rcutorture/bin/kvm.sh +6 -3
index 08c90cba79d2..73c586f6bdf6 100644
@@ -81,7 +81,7 @@ do
 		shift
 		;;
 	--buildonly)
-		RCU_BUILDONLY=1; export RCU_BUILDONLY
+		TORTURE_BUILDONLY=1
 		;;
 	--configs)
 		checkarg --configs "(list of config files)" "$#" "$2" '^[^/]*$' '^--'
@@ -374,7 +374,7 @@ then
 	echo KVM="$KVM; export KVM"
 	echo KVPATH="$KVPATH; export KVPATH"
 	echo PATH="$PATH; export PATH"
-	echo RCU_BUILDONLY="$RCU_BUILDONLY; export RCU_BUILDONLY"
+	echo TORTURE_BUILDONLY="$TORTURE_BUILDONLY; export TORTURE_BUILDONLY"
 	echo TORTURE_INITRD="$TORTURE_INITRD; export TORTURE_INITRD"
 	echo TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG; export TORTURE_KMAKE_ARG"
 	echo RCU_QEMU_CMD="$RCU_QEMU_CMD; export RCU_QEMU_CMD"
@@ -402,4 +402,7 @@ echo
 echo
 echo " --- `date` Test summary:"
 echo Results directory: $resdir/$ds
-kvm-recheck.sh $resdir/$ds
+if test -n "$TORTURE_BUILDONLY"
+then
+	kvm-recheck.sh $resdir/$ds
+fi
Signature · 1 line
1.8.1.5
#49 lore raw

Re: [PATCH tip/core/rcu 20/45] torture: Include "Stopping" string to torture_kthread_stopping()

In reply to Josh Triplett
Quoted 52 lines · Josh Triplett
Quoted 51 lines · Paul E. McKenney
Quoted 49 lines · Josh Triplett
Quoted 40 lines · Paul E. McKenney
Quoted 34 lines · On Wed, May 07, 2014 at 02:37:36PM -0700, [email protected] wrote:
Quoted 7 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Currently, torture_kthread_stopping() prints only the name of the kthread that is stopping, which can be unedifying. This commit therefore adds "Stopping" to make things more evident.

Feedback below.

Quoted 8 lines
 kernel/torture.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/torture.c +0 -0
index acc9afc2f26e..f329848c3eee 100644

kernel/torture.c EXPORT_SYMBOL_GPL(torture_must_stop_irq); · line 681

Quoted 9 lines
kernel/torture.c +4 -1
@@ -674,8 +674,11 @@ EXPORT_SYMBOL_GPL(torture_must_stop_irq);
  */
 void torture_kthread_stopping(char *title)
 {
+	char buf[128];
+
+	snprintf(buf, sizeof(buf), "Stopping %s", title);
 	if (verbose)
-		VERBOSE_TOROUT_STRING(title);
+		VERBOSE_TOROUT_STRING(buf);

This seems like a case where the macro has led to poorer code; rather than using sprintf into a temporary buffer, this should just print. Please consider fixing the output macros to allow formats, as the pr_* macros do.

Quoted 4 lines

Also, why do you need "if (verbose)" if the name of the macro has VERBOSE_ in it; shouldn't that mean it checks verbosity itself? (Another good reason not to create a unique verbosity level mechanism, and to use the kernel mechanisms instead.)

Quoted 5 lines

Good catch, removed the redundant "if (verbose)".

My attempts in the past to leverage existing in-kernel verbosity controls has caused problems such as the output appearing or not depending on the distro in question.

That aside, though, what do you think about making the macros accept format strings and arguments, in the style of pr_* and pr_fmt?

Quoted 6 lines
Quoted 2 lines

If I end up needing this in a few more cases, then it would indeed be worth it.

I'd argue that it's worth it already: doing snprintf into a temporary buffer seems ridiculous here, when without these macros you'd just call pr_foo("Stopping %s\n", title);

Sold, I will make this change for 3.17. Or if you would like to send along a patch, that would be quite welcome as well. ;-)

Thanx, Paul

#71 lore raw

Re: [PATCH tip/core/rcu 32/45] torture: Better summary diagnostics for build failures

In reply to Josh Triplett
Quoted 15 lines · Josh Triplett
Quoted 14 lines · Paul E. McKenney
Quoted 9 lines · On Wed, May 07, 2014 at 03:11:39PM -0700, [email protected] wrote:
Quoted 5 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The reaction of kvm-recheck.sh is obscure at best, and easy to miss completely. This commit therefore prints "BUG: Build failed" in the summary at the end of a run.

This commit also changes a dozen other things about the output that this commit message does not document. :)

Well, I don't know about a dozen, but I did upgrade the commit message to read as follows:

Quoted 8 lines
Quoted 6 lines

The reaction of kvm-recheck.sh is obscure at best, and easy to miss completely. This commit therefore prints "BUG: Build failed" in the summary at the end of a run. This commit also adds the line of dashes in cases where performance info is not available, and also avoids printing nonsense diagnostics in cases where some of the normal test output is not available.

What about the change to kvm-test-1-run.sh?

Right you are!

The reaction of kvm-recheck.sh is obscure at best, and easy to miss completely. This commit therefore prints "BUG: Build failed" in the summary at the end of a run. This commit also adds the line of dashes in cases where performance info is not available, and also avoids printing nonsense diagnostics in cases where some of the normal test output is not available. In addition, this commit saves off the .config file even when the build fails.

Thanx, Paul

#72 lore raw

Re: [PATCH tip/core/rcu 32/45] torture: Better summary diagnostics for build failures

Quoted 27 lines · Paul E. McKenney
Quoted 15 lines · Josh Triplett
Quoted 14 lines · Paul E. McKenney
Quoted 9 lines · On Wed, May 07, 2014 at 03:11:39PM -0700, [email protected] wrote:
Quoted 5 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The reaction of kvm-recheck.sh is obscure at best, and easy to miss completely. This commit therefore prints "BUG: Build failed" in the summary at the end of a run.

This commit also changes a dozen other things about the output that this commit message does not document. :)

Well, I don't know about a dozen, but I did upgrade the commit message to read as follows:

Quoted 8 lines
Quoted 6 lines

The reaction of kvm-recheck.sh is obscure at best, and easy to miss completely. This commit therefore prints "BUG: Build failed" in the summary at the end of a run. This commit also adds the line of dashes in cases where performance info is not available, and also avoids printing nonsense diagnostics in cases where some of the normal test output is not available.

What about the change to kvm-test-1-run.sh?

Right you are!

Quoted 7 lines

The reaction of kvm-recheck.sh is obscure at best, and easy to miss completely. This commit therefore prints "BUG: Build failed" in the summary at the end of a run. This commit also adds the line of dashes in cases where performance info is not available, and also avoids printing nonsense diagnostics in cases where some of the normal test output is not available. In addition, this commit saves off the .config file even when the build fails.

Looks good, ship it.

#73 lore raw

Re: [PATCH tip/core/rcu 32/45] torture: Better summary diagnostics for build failures

Quoted 36 lines · On Tue, May 13, 2014 at 01:21:36PM -0700, [email protected] wrote:
Quoted 27 lines · Paul E. McKenney
Quoted 15 lines · Josh Triplett
Quoted 14 lines · Paul E. McKenney
Quoted 9 lines · On Wed, May 07, 2014 at 03:11:39PM -0700, [email protected] wrote:
Quoted 5 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The reaction of kvm-recheck.sh is obscure at best, and easy to miss completely. This commit therefore prints "BUG: Build failed" in the summary at the end of a run.

This commit also changes a dozen other things about the output that this commit message does not document. :)

Well, I don't know about a dozen, but I did upgrade the commit message to read as follows:

Quoted 8 lines
Quoted 6 lines

The reaction of kvm-recheck.sh is obscure at best, and easy to miss completely. This commit therefore prints "BUG: Build failed" in the summary at the end of a run. This commit also adds the line of dashes in cases where performance info is not available, and also avoids printing nonsense diagnostics in cases where some of the normal test output is not available.

What about the change to kvm-test-1-run.sh?

Right you are!

Quoted 7 lines

The reaction of kvm-recheck.sh is obscure at best, and easy to miss completely. This commit therefore prints "BUG: Build failed" in the summary at the end of a run. This commit also adds the line of dashes in cases where performance info is not available, and also avoids printing nonsense diagnostics in cases where some of the normal test output is not available. In addition, this commit saves off the .config file even when the build fails.

Quoted 1 line

Looks good, ship it.

Woo-hoo!!! ;-)

Thanx, Paul

#52 lore raw

Re: [PATCH tip/core/rcu 21/45] torture: Report diagnostics from qemu

In reply to [email protected]
Quoted 28 lines · On Wed, May 07, 2014 at 02:59:11PM -0700, [email protected] wrote:
Quoted 10 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The current script does record qemu diagnostics, but the user has to know where to look for them. This commit therefore puts them into the Warnings file so that kvm-recheck.sh will display them. This change is especially useful if you are in the habit of killing the qemu process when you realize that you messed something up, but then later on wonder why the process terminated early.

A couple of issues below.

tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh do · line 176

Quoted 6 lines
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +2 -0
@@ -172,6 +172,14 @@ do
 		if test $kruntime -lt $seconds
 		then
 			echo Completed in $kruntime vs. $seconds >> $resdir/Warnings 2>&1
+			grep "^(qemu) qemu:" $resdir/kvm-test-1-run.sh.out >> $resdir/Warnings 2>&1
+			killpid="`grep "^(qemu) qemu: terminating on signal [0-9]* from pid" $resdir/kvm-test-1-run.sh.out`"

You already searched for lines like this and put them in Warnings in the previous line, so you don't need to search the entire output. Also, you use grep here and sed below; you could just use sed here to directly obtain the PID:

killpid="$(sed -n "s/^(qemu) qemu: terminating on signal [0-9]* from pid \([0-9]*\).*$/\1/p" $resdir/Warnings)"

Quoted 15 lines

tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh do · line 182

Quoted 6 lines
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +6 -0
+			if test -n "$killpid"
+			then
+				pscmd="`echo $killpid | sed -e 's/^.*from pid/ps -ef | grep/'`"
+				echo $pscmd >> $resdir/Warnings
+				echo $pscmd | sh >> $resdir/Warnings 2>&1
+			fi

Grepping for a PID is a bad idea; it'll turn up anything that contains that PID anywhere on the line, including as a substring. Given the above change to obtain a numeric $killpid, you can instead pass the PID to ps directly:
if test -n "$killpid"
then
ps -fp $killpid >> $resdir/Warnings 2>&1
fi

All good points! What can I say? 30-year-old habits die hard. ;-)

Giving it a spin... Very nice, applied!

Thanx, Paul

#84 lore raw

Re: [PATCH tip/core/rcu 39/45] rcutorture: Note diffs from git commits

In reply to Josh Triplett
Quoted 33 lines · Josh Triplett
Quoted 32 lines · Paul E. McKenney
Quoted 30 lines · On Wed, May 07, 2014 at 03:17:42PM -0700, [email protected] wrote:
Quoted 9 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The current scripting only keeps track of the git SHA-1 of the current HEAD. This can cause confusion in cases where testing ran in a git tree where changes had not yet been checked in. This commit therefore also records the output of "git diff HEAD" to provide the information needed to reconstruct the source tree that was tested.

Nit below.

Quoted 9 lines
---
 tools/testing/selftests/rcutorture/bin/kvm.sh | 5 +++++
 1 file changed, 5 insertions(+)
tools/testing/selftests/rcutorture/bin/kvm.sh +0 -0
index 4eed2a4f42c7..91661845fdec 100644

tools/testing/selftests/rcutorture/bin/kvm.sh if test -d .git · line 281

Quoted 5 lines
tools/testing/selftests/rcutorture/bin/kvm.sh +2 -0
@@ -277,6 +277,11 @@ if test -d .git
 then
 	git status >> $resdir/$ds/testid.txt
 	git rev-parse HEAD >> $resdir/$ds/testid.txt
+	git diff HEAD > $T/git-diff 2>&1
+	if test -s $T/git-diff

You don't need test here; you can use the return value of git diff.

Quoted 4 lines
Quoted 2 lines

Oddly enough, the "git diff" man page does not say anything about the exit value. At least not that I could find...

Look for the --exit-code option of git diff.

I guess I should have searched for "exit" rather than scrolling to the bottom of the man page. Thank you for the tip! ;-)

So:

if ! git diff HEAD > $T/git-diff 2>&1
then
cp $T/git-diff $resdir/$ds
fi

The reason for dropping into /tmp and then copying if there were diffs is that I don't want there to be an empty file if no diffs.

Thanx, Paul

#85 lore raw

Re: [PATCH tip/core/rcu 39/45] rcutorture: Note diffs from git commits

Quoted 37 lines · Paul E. McKenney
Quoted 36 lines · Josh Triplett
Quoted 34 lines · Paul E. McKenney
Quoted 18 lines · On Wed, May 07, 2014 at 03:17:42PM -0700, [email protected] wrote:
Quoted 9 lines · Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

The current scripting only keeps track of the git SHA-1 of the current HEAD. This can cause confusion in cases where testing ran in a git tree where changes had not yet been checked in. This commit therefore also records the output of "git diff HEAD" to provide the information needed to reconstruct the source tree that was tested.

Nit below.

Quoted 4 lines
---
 tools/testing/selftests/rcutorture/bin/kvm.sh | 5 +++++
 1 file changed, 5 insertions(+)
Quoted 12 lines

tools/testing/selftests/rcutorture/bin/kvm.sh if test -d .git · line 281

Quoted 10 lines
tools/testing/selftests/rcutorture/bin/kvm.sh +2 -0
index 4eed2a4f42c7..91661845fdec 100644
@@ -277,6 +277,11 @@ if test -d .git
 then
 	git status >> $resdir/$ds/testid.txt
 	git rev-parse HEAD >> $resdir/$ds/testid.txt
+	git diff HEAD > $T/git-diff 2>&1
+	if test -s $T/git-diff

You don't need test here; you can use the return value of git diff.

Oddly enough, the "git diff" man page does not say anything about the exit value. At least not that I could find...

Quoted 8 lines
Quoted 1 line

Look for the --exit-code option of git diff.

I guess I should have searched for "exit" rather than scrolling to the bottom of the man page. Thank you for the tip! ;-)

So:

if ! git diff HEAD > $T/git-diff 2>&1

Except with the --exit-code included...

Thanx, Paul

Quoted 8 lines

then
cp $T/git-diff $resdir/$ds
fi

The reason for dropping into /tmp and then copying if there were diffs is that I don't want there to be an empty file if no diffs.

Thanx, Paul