Skip to contentSkip to conversation

Torture-test changes for 4.8

PATCH New Paul E. McKenney 1 participant 15 messages Jun 15, 2016

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

cover Torture-test changes for 4.8

Hello!

This series contains torture-test updates for RCU:

1. Simplify code, eliminate RCU_PERF_TEST_RUNNABLE.

2. Remove CONFIG_RCU_TORTURE_TEST_RUNNABLE, simplify code.

3. Forgive lengthy trace dumps and preemption, so that the hung-kernel
detection avoids killing off needed diagnostics.

4. Break online and offline functions out of torture_onoff().

5. Add starvation events to error summary.

6. Stop onoff task if there is only one cpu, courtesy of Boqun Feng.

7. Create initrd using dracut, courtesy of Boqun Feng.

8. Use vmlinux as the fallback kernel image, courtesy of Boqun Feng.

9. Make -soundhw a x86 specific option, courtesy of Boqun Feng.

10. Don't specify the cpu type of QEMU on PPC, courtesy of Boqun Feng.

11. Drop "-soundhw pcspkr" from x86 boot arguments.

12. Don't treat gp_exp mis-setting as a WARN, courtesy of Boqun Feng.

13. Inflict OS jitter on torture-test runs by default.

14. Fix error return code in rcu_perf_init(), courtesy of Wei Yongjun.

Thanx, Paul

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

 include/linux/torture.h                                  |    4 
 kernel/rcu/rcuperf.c                                     |   25 +-
 kernel/rcu/rcutorture.c                                  |    7 
 kernel/rcu/tree_plugin.h                                 |    2 
 kernel/torture.c                                         |  176 +++++++++------
 lib/Kconfig.debug                                        |   33 --
 tools/testing/selftests/rcutorture/bin/functions.sh      |   14 -
 tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh |   34 ++
 tools/testing/selftests/rcutorture/bin/kvm.sh            |    2 
 tools/testing/selftests/rcutorture/bin/parse-console.sh  |    7 
 tools/testing/selftests/rcutorture/doc/initrd.txt        |   22 +
 11 files changed, 193 insertions(+), 133 deletions(-)
#1 lore raw

PATCH 1/14 torture: Simplify code, eliminate RCU_PERF_TEST_RUNNABLE

This commit applies the infamous IS_ENABLED() macro to eliminate a #ifdef. It also eliminates the RCU_PERF_TEST_RUNNABLE Kconfig option in favor of the already-existing rcuperf.perf_runnable kernel boot parameter.

---
 kernel/rcu/rcuperf.c |  7 +------
 lib/Kconfig.debug    | 16 ----------------
 2 files changed, 1 insertion(+), 22 deletions(-)
kernel/rcu/rcuperf.c +1 -6
index 3cee0d8393ed..afd174e901c3 100644
@@ -96,12 +96,7 @@ static int rcu_perf_writer_state;
 #define MAX_MEAS 10000
 #define MIN_MEAS 100
 
-#if defined(MODULE) || defined(CONFIG_RCU_PERF_TEST_RUNNABLE)
-#define RCUPERF_RUNNABLE_INIT 1
-#else
-#define RCUPERF_RUNNABLE_INIT 0
-#endif
-static int perf_runnable = RCUPERF_RUNNABLE_INIT;
+static int perf_runnable = IS_ENABLED(MODULE);
 module_param(perf_runnable, int, 0444);
 MODULE_PARM_DESC(perf_runnable, "Start rcuperf at boot");
 
lib/Kconfig.debug +0 -16
index b9cfdbfae9aa..cf6ddcd8f70c 100644
@@ -1307,22 +1307,6 @@ config RCU_PERF_TEST
 	  Say M if you want the RCU performance tests to build as a module.
 	  Say N if you are unsure.
 
-config RCU_PERF_TEST_RUNNABLE
-	bool "performance tests for RCU runnable by default"
-	depends on RCU_PERF_TEST = y
-	default n
-	help
-	  This option provides a way to build the RCU performance tests
-	  directly into the kernel without them starting up at boot time.
-	  You can use /sys/module to manually override this setting.
-	  This /proc file is available only when the RCU performance
-	  tests have been built into the kernel.
-
-	  Say Y here if you want the RCU performance tests to start during
-	  boot (you probably don't).
-	  Say N here if you want the RCU performance tests to start only
-	  after being manually enabled via /sys/module.
-
 config RCU_TORTURE_TEST
 	tristate "torture tests for RCU"
 	depends on DEBUG_KERNEL
Signature · 1 line
2.5.2
#2 lore raw

PATCH 2/14 torture: Remove CONFIG_RCU_TORTURE_TEST_RUNNABLE, simplify code

In reply to Paul E. McKenney

This commit removes CONFIG_RCU_TORTURE_TEST_RUNNABLE in favor of the already-existing rcutorture.torture_runnable kernel boot parameter. It also converts an #ifdef into IS_ENABLED(), saving a few lines of code.

---
 kernel/rcu/rcutorture.c  |  7 +------
 kernel/rcu/tree_plugin.h |  2 --
 lib/Kconfig.debug        | 17 -----------------
 3 files changed, 1 insertion(+), 25 deletions(-)
kernel/rcu/rcutorture.c +1 -6
index 084a28a732eb..01cb57ff106f 100644
@@ -182,12 +182,7 @@ static const char *rcu_torture_writer_state_getname(void)
 	return rcu_torture_writer_state_names[i];
 }
 
-#if defined(MODULE) || defined(CONFIG_RCU_TORTURE_TEST_RUNNABLE)
-#define RCUTORTURE_RUNNABLE_INIT 1
-#else
-#define RCUTORTURE_RUNNABLE_INIT 0
-#endif
-static int torture_runnable = RCUTORTURE_RUNNABLE_INIT;
+static int torture_runnable = IS_ENABLED(MODULE);
 module_param(torture_runnable, int, 0444);
 MODULE_PARM_DESC(torture_runnable, "Start rcutorture at boot");
 
kernel/rcu/tree_plugin.h +0 -2
index ff1cd4e1188d..5b2d723e6568 100644
@@ -79,8 +79,6 @@ static void __init rcu_bootup_announce_oddness(void)
 		pr_info("\tRCU dyntick-idle grace-period acceleration is enabled.\n");
 	if (IS_ENABLED(CONFIG_PROVE_RCU))
 		pr_info("\tRCU lockdep checking is enabled.\n");
-	if (IS_ENABLED(CONFIG_RCU_TORTURE_TEST_RUNNABLE))
-		pr_info("\tRCU torture testing starts during boot.\n");
 	if (RCU_NUM_LVLS >= 4)
 		pr_info("\tFour(or more)-level hierarchy is enabled.\n");
 	if (RCU_FANOUT_LEAF != 16)
lib/Kconfig.debug +0 -17
index cf6ddcd8f70c..805b7048a1bd 100644
@@ -1324,23 +1324,6 @@ config RCU_TORTURE_TEST
 	  Say M if you want the RCU torture tests to build as a module.
 	  Say N if you are unsure.
 
-config RCU_TORTURE_TEST_RUNNABLE
-	bool "torture tests for RCU runnable by default"
-	depends on RCU_TORTURE_TEST = y
-	default n
-	help
-	  This option provides a way to build the RCU torture tests
-	  directly into the kernel without them starting up at boot
-	  time.  You can use /proc/sys/kernel/rcutorture_runnable
-	  to manually override this setting.  This /proc file is
-	  available only when the RCU torture tests have been built
-	  into the kernel.
-
-	  Say Y here if you want the RCU torture tests to start during
-	  boot (you probably don't).
-	  Say N here if you want the RCU torture tests to start only
-	  after being manually enabled via /proc.
-
 config RCU_TORTURE_TEST_SLOW_PREINIT
 	bool "Slow down RCU grace-period pre-initialization to expose races"
 	depends on RCU_TORTURE_TEST
Signature · 1 line
2.5.2
#3 lore raw

PATCH 3/14 torture: Forgive lengthy trace dumps and preemption

In reply to Paul E. McKenney

This commit avoids killing qemu if a trace dump is making progress or if console log output is continuing and the console log timestamp does not exceed the total plus grace period.

---
 .../selftests/rcutorture/bin/kvm-test-1-run.sh      | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +19 -2
index 4109f306d855..9b17c5252a2e 100755
@@ -229,6 +229,7 @@ fi
 if test $commandcompleted -eq 0 -a -n "$qemu_pid"
 then
 	echo Grace period for qemu job at pid $qemu_pid
+	oldline="`tail $resdir/console.log`"
 	while :
 	do
 		kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null`
@@ -238,13 +239,29 @@ then
 		else
 			break
 		fi
-		if test $kruntime -ge $((seconds + $TORTURE_SHUTDOWN_GRACE))
+		must_continue=no
+		newline="`tail $resdir/console.log`"
+		if test "$newline" != "$oldline" && echo $newline | grep -q ' [0-9]\+us : '
+		then
+			must_continue=yes
+		fi
+		last_ts="`tail $resdir/console.log | grep '^\[ *[0-9]\+\.[0-9]\+]' | tail -1 | sed -e 's/^\[ *//' -e 's/\..*$//'`"
+		if test -z "last_ts"
+		then
+			last_ts=0
+		fi
+		if test "$newline" != "$oldline" -a "$last_ts" -lt $((seconds + $TORTURE_SHUTDOWN_GRACE))
+		then
+			must_continue=yes
+		fi
+		if test $must_continue = no -a $kruntime -ge $((seconds + $TORTURE_SHUTDOWN_GRACE))
 		then
 			echo "!!! PID $qemu_pid hung at $kruntime vs. $seconds seconds" >> $resdir/Warnings 2>&1
 			kill -KILL $qemu_pid
 			break
 		fi
-		sleep 1
+		oldline=$newline
+		sleep 10
 	done
 elif test -z "$qemu_pid"
 then
Signature · 1 line
2.5.2
#4 lore raw

PATCH 4/14 torture: Break online and offline functions out of torture_onoff()

In reply to Paul E. McKenney

This commit breaks torture_online() and torture_offline() out of torture_onoff() in preparation for allowing waketorture finer-grained control of its CPU-hotplug workload.

---
 include/linux/torture.h |   4 ++
 kernel/torture.c        | 168 ++++++++++++++++++++++++++++++------------------
 2 files changed, 108 insertions(+), 64 deletions(-)
include/linux/torture.h +4 -0
index 7759fc3c622d..6685a73736a2 100644
@@ -50,6 +50,10 @@
 	do { if (verbose) pr_alert("%s" TORTURE_FLAG "!!! %s\n", torture_type, s); } while (0)
 
 /* Definitions for online/offline exerciser. */
+bool torture_offline(int cpu, long *n_onl_attempts, long *n_onl_successes,
+		     unsigned long *sum_offl, int *min_onl, int *max_onl);
+bool torture_online(int cpu, long *n_onl_attempts, long *n_onl_successes,
+		    unsigned long *sum_onl, int *min_onl, int *max_onl);
 int torture_onoff_init(long ooholdoff, long oointerval);
 void torture_onoff_stats(void);
 bool torture_onoff_failures(void);
kernel/torture.c +104 -64

188 lines not on this page · raw message

Signature · 1 line
2.5.2
#5 lore raw

PATCH 5/14 torture: Add starvation events to error summary

In reply to Paul E. McKenney

This commit adds a string of the form "Starves: 10" to the summary line for error conditions found in the console output.

---
 tools/testing/selftests/rcutorture/bin/parse-console.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/parse-console.sh +6 -1
index 5eb49b7f864c..08aa7d50ae0e 100755
@@ -33,7 +33,7 @@ if grep -Pq '\x00' < $file
 then
 	print_warning Console output contains nul bytes, old qemu still running?
 fi
-egrep 'Badness|WARNING:|Warn|BUG|===========|Call Trace:|Oops:|detected stalls on CPUs/tasks:|self-detected stall on CPU|Stall ended before state dump start|\?\?\? Writer stall state' < $file | grep -v 'ODEBUG: ' | grep -v 'Warning: unable to open an initial console' > $1.diags
+egrep 'Badness|WARNING:|Warn|BUG|===========|Call Trace:|Oops:|detected stalls on CPUs/tasks:|self-detected stall on CPU|Stall ended before state dump start|\?\?\? Writer stall state|rcu_.*kthread starved for' < $file | grep -v 'ODEBUG: ' | grep -v 'Warning: unable to open an initial console' > $1.diags
 if test -s $1.diags
 then
 	print_warning Assertion failure in $file $title
@@ -69,6 +69,11 @@ then
 	then
 		summary="$summary  Stalls: $n_stalls"
 	fi
+	n_starves=`grep -c 'rcu_.*kthread starved for' $1`
+	if test "$n_starves" -ne 0
+	then
+		summary="$summary  Starves: $n_starves"
+	fi
 	print_warning Summary: $summary
 else
 	rm $1.diags
Signature · 1 line
2.5.2
#6 lore raw

PATCH 6/14 torture: Stop onoff task if there is only one cpu

In reply to Paul E. McKenney

From: Boqun Feng <[email protected]>

If the whole system has only one cpu, that cpu won't be able to be offlined, so there is no need onoff task is stil running.

---
 kernel/torture.c | 8 ++++++++
 1 file changed, 8 insertions(+)
kernel/torture.c +8 -0
index fb39a06bbef5..75961b3decfe 100644
@@ -194,6 +194,12 @@ torture_onoff(void *arg)
 	for_each_online_cpu(cpu)
 		maxcpu = cpu;
 	WARN_ON(maxcpu < 0);
+
+	if (maxcpu == 0) {
+		VERBOSE_TOROUT_STRING("Only one CPU, so CPU-hotplug testing is disabled");
+		goto stop;
+	}
+
 	if (onoff_holdoff > 0) {
 		VERBOSE_TOROUT_STRING("torture_onoff begin holdoff");
 		schedule_timeout_interruptible(onoff_holdoff);
@@ -209,6 +215,8 @@ torture_onoff(void *arg)
 				       &sum_online, &min_online, &max_online);
 		schedule_timeout_interruptible(onoff_interval);
 	}
+
+stop:
 	torture_kthread_stopping("torture_onoff");
 	return 0;
 }
Signature · 1 line
2.5.2
#7 lore raw

PATCH 7/14 rcutorture/doc: Create initrd using dracut

In reply to Paul E. McKenney

From: Boqun Feng <[email protected]>

Using dracut is another way to get an initramfs for KVM-based RCU torture tests, which is more flexible than using the host's initramfs image, because modules and binaries may be added or removed via dracut command options. So add an example in the document, in case that there are some situations where host's initramfs couldn't be used.

---
 tools/testing/selftests/rcutorture/doc/initrd.txt | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
tools/testing/selftests/rcutorture/doc/initrd.txt +22 -0
index 4170e714f044..833f826d6ec2 100644
@@ -13,6 +13,22 @@ cd initrd
 cpio -id < /tmp/initrd.img.zcat
 ------------------------------------------------------------------------
 
+Another way to create an initramfs image is using "dracut"[1], which is
+available on many distros, however the initramfs dracut generates is a cpio
+archive with another cpio archive in it, so an extra step is needed to create
+the initrd directory hierarchy.
+
+Here are the commands to create a initrd directory for rcutorture using
+dracut:
+
+------------------------------------------------------------------------
+dracut --no-hostonly --no-hostonly-cmdline --module "base bash shutdown" /tmp/initramfs.img
+cd tools/testing/selftests/rcutorture
+mkdir initrd
+cd initrd
+/usr/lib/dracut/skipcpio /tmp/initramfs.img | zcat | cpio -id < /tmp/initramfs.img
+------------------------------------------------------------------------
+
 Interestingly enough, if you are running rcutorture, you don't really
 need userspace in many cases.  Running without userspace has the
 advantage of allowing you to test your kernel independently of the
@@ -89,3 +105,9 @@ while :
 do
 	sleep 10
 done
+------------------------------------------------------------------------
+
+References:
+[1]: https://dracut.wiki.kernel.org/index.php/Main_Page
+[2]: http://blog.elastocloud.org/2015/06/rapid-linux-kernel-devtest-with-qemu.html
+[3]: https://www.centos.org/forums/viewtopic.php?t=51621
Signature · 1 line
2.5.2
#8 lore raw

PATCH 8/14 rcutorture: Use vmlinux as the fallback kernel image

In reply to Paul E. McKenney

From: Boqun Feng <[email protected]>

The vmlinux image is available for all the architectures, and suitable for running a KVM guest by QEMU, besides, we used to copy the vmlinux to $resdir anyway. Therefore it makes sense to use it as the fallback kernel image for rcutorture KVM tests.

This patch makes identify_boot_image() return vmlinux if ${TORTURE_BOOT_IMAGE} is not set on non-x86 architectures, also fixes several places that hard-code "bzImage" as $KERNEL.

This also fixes a problem that PPC doesn't have a bzImage file as build results.

---
 tools/testing/selftests/rcutorture/bin/functions.sh      | 10 ++++------
 tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh |  5 +++--
 2 files changed, 7 insertions(+), 8 deletions(-)
tools/testing/selftests/rcutorture/bin/functions.sh +4 -6
index b325470c01b3..616180153208 100644
@@ -99,8 +99,9 @@ configfrag_hotplug_cpu () {
 # 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.
+# arch/<arch>/boot/bzImage or vmlinux if bzImage is not a target for the
+# architecture, unless overridden with the TORTURE_BOOT_IMAGE environment
+# variable.
 identify_boot_image () {
 	if test -n "$TORTURE_BOOT_IMAGE"
 	then
@@ -110,11 +111,8 @@ identify_boot_image () {
 		qemu-system-x86_64|qemu-system-i386)
 			echo arch/x86/boot/bzImage
 			;;
-		qemu-system-ppc64)
-			echo arch/powerpc/boot/bzImage
-			;;
 		*)
-			echo ""
+			echo vmlinux
 			;;
 		esac
 	fi
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +3 -2
index 9b17c5252a2e..8dc5e4639fb4 100755
@@ -96,7 +96,8 @@ if test "$base_resdir" != "$resdir" -a -f $base_resdir/bzImage -a -f $base_resdi
 then
 	# Rerunning previous test, so use that test's kernel.
 	QEMU="`identify_qemu $base_resdir/vmlinux`"
-	KERNEL=$base_resdir/bzImage
+	BOOT_IMAGE="`identify_boot_image $QEMU`"
+	KERNEL=$base_resdir/${BOOT_IMAGE##*/} # use the last component of ${BOOT_IMAGE}
 	ln -s $base_resdir/Make*.out $resdir  # for kvm-recheck.sh
 	ln -s $base_resdir/.config $resdir  # for kvm-recheck.sh
 elif kvm-build.sh $config_template $builddir $T
@@ -110,7 +111,7 @@ then
 	if test -n "$BOOT_IMAGE"
 	then
 		cp $builddir/$BOOT_IMAGE $resdir
-		KERNEL=$resdir/bzImage
+		KERNEL=$resdir/${BOOT_IMAGE##*/}
 	else
 		echo No identifiable boot image, not running KVM, see $resdir.
 		echo Do the torture scripts know about your architecture?
Signature · 1 line
2.5.2
#9 lore raw

PATCH 9/14 rcutorture: Make -soundhw a x86 specific option

In reply to Paul E. McKenney

From: Boqun Feng <[email protected]>

The option "-soundhw pcspk" gives me a error on PPC as follow:

qemu-system-ppc64: ISA bus not available for pcspk

This means this option doesn't work on ppc by default. So simply make this an x86-specific option via identify_qemu_args().

---
 tools/testing/selftests/rcutorture/bin/functions.sh      | 1 +
 tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 8 ++++----
 2 files changed, 5 insertions(+), 4 deletions(-)
tools/testing/selftests/rcutorture/bin/functions.sh +1 -0
index 616180153208..77fdb46cc65a 100644
@@ -171,6 +171,7 @@ identify_qemu_append () {
 identify_qemu_args () {
 	case "$1" in
 	qemu-system-x86_64|qemu-system-i386)
+		echo -soundhw pcspk
 		;;
 	qemu-system-ppc64)
 		echo -enable-kvm -M pseries -cpu POWER7 -nodefaults
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +4 -4
index 8dc5e4639fb4..ea6e373edc27 100755
@@ -8,9 +8,9 @@
 #
 # Usage: kvm-test-1-run.sh config builddir resdir seconds qemu-args boot_args
 #
-# qemu-args defaults to "-enable-kvm -soundhw pcspk -nographic", along with
-#			arguments specifying the number of CPUs and other
-#			options generated from the underlying CPU architecture.
+# qemu-args defaults to "-enable-kvm -nographic", along with arguments
+#			specifying the number of CPUs and other options
+#			generated from the underlying CPU architecture.
 # boot_args defaults to value returned by the per_version_boot_params
 #			shell function.
 #
@@ -148,7 +148,7 @@ then
 fi
 
 # Generate -smp qemu argument.
-qemu_args="-enable-kvm -soundhw pcspk -nographic $qemu_args"
+qemu_args="-enable-kvm -nographic $qemu_args"
 cpu_count=`configNR_CPUS.sh $config_template`
 cpu_count=`configfrag_boot_cpus "$boot_args" "$config_template" "$cpu_count"`
 vcpus=`identify_qemu_vcpus`
Signature · 1 line
2.5.2
#10 lore raw

PATCH 10/14 rcutorture: Don't specify the cpu type of QEMU on PPC

In reply to Paul E. McKenney

From: Boqun Feng <[email protected]>

Do not restrict the cpu type to POWER7 for QEMU as we have POWER8 now.

---
 tools/testing/selftests/rcutorture/bin/functions.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/functions.sh +1 -1
index 77fdb46cc65a..56ac202859eb 100644
@@ -174,7 +174,7 @@ identify_qemu_args () {
 		echo -soundhw pcspk
 		;;
 	qemu-system-ppc64)
-		echo -enable-kvm -M pseries -cpu POWER7 -nodefaults
+		echo -enable-kvm -M pseries -nodefaults
 		echo -device spapr-vscsi
 		if test -n "$TORTURE_QEMU_INTERACTIVE" -a -n "$TORTURE_QEMU_MAC"
 		then
Signature · 1 line
2.5.2
#11 lore raw

PATCH 11/14 rcutorture: Drop "-soundhw pcspkr" from x86 boot arguments

In reply to Paul E. McKenney

Because recent testing shows that "-soundhw pcspkr" is no longer required in the kernel boot arguments, this commit drops this qemu argument.

---
 tools/testing/selftests/rcutorture/bin/functions.sh | 1 -
 1 file changed, 1 deletion(-)
tools/testing/selftests/rcutorture/bin/functions.sh +0 -1
index 56ac202859eb..1426a9b97494 100644
@@ -171,7 +171,6 @@ identify_qemu_append () {
 identify_qemu_args () {
 	case "$1" in
 	qemu-system-x86_64|qemu-system-i386)
-		echo -soundhw pcspk
 		;;
 	qemu-system-ppc64)
 		echo -enable-kvm -M pseries -nodefaults
Signature · 1 line
2.5.2
#12 lore raw

PATCH 12/14 rcuperf: Don't treat gp_exp mis-setting as a WARN

In reply to Paul E. McKenney

From: Boqun Feng <[email protected]>

0day found a boot warning triggered in rcu_perf_writer() on !SMP kernel:

	WARN_ON(rcu_gp_is_normal() && gp_exp);

, the root cause of which is trying to measure expedited grace periods(by setting gp_exp to true by default) when all the grace periods are normal(TINY RCU only has normal grace periods).

However, such a mis-setting would only result in failing to measure the performance for a specific kind of grace periods, therefore using a WARN_ON to check this is a little overkilling. We could handle this inside rcuperf module via some error messages to tell users about the mis-settings.

Therefore this patch removes the WARN_ON in rcu_perf_writer() and handles those checkings in rcu_perf_init() with plain if() code.

Moreover, this patch changes the default value of gp_exp to 1) align with rcutorture tests and 2) make the default setting work for all RCU implementations by default.

---
 kernel/rcu/rcuperf.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
kernel/rcu/rcuperf.c +11 -3
index afd174e901c3..7b2dbdffd791 100644
@@ -58,7 +58,7 @@ MODULE_AUTHOR("Paul E. McKenney <[email protected]>");
 #define VERBOSE_PERFOUT_ERRSTRING(s) \
 	do { if (verbose) pr_alert("%s" PERF_FLAG "!!! %s\n", perf_type, s); } while (0)
 
-torture_param(bool, gp_exp, true, "Use expedited GP wait primitives");
+torture_param(bool, gp_exp, false, "Use expedited GP wait primitives");
 torture_param(int, holdoff, 10, "Holdoff time before test start (s)");
 torture_param(int, nreaders, -1, "Number of RCU reader threads");
 torture_param(int, nwriters, -1, "Number of RCU updater threads");
@@ -358,8 +358,6 @@ rcu_perf_writer(void *arg)
 	u64 *wdpp = writer_durations[me];
 
 	VERBOSE_PERFOUT_STRING("rcu_perf_writer task started");
-	WARN_ON(rcu_gp_is_expedited() && !rcu_gp_is_normal() && !gp_exp);
-	WARN_ON(rcu_gp_is_normal() && gp_exp);
 	WARN_ON(!wdpp);
 	set_cpus_allowed_ptr(current, cpumask_of(me % nr_cpu_ids));
 	sp.sched_priority = 1;
@@ -626,6 +624,16 @@ rcu_perf_init(void)
 		firsterr = -ENOMEM;
 		goto unwind;
 	}
+	if (rcu_gp_is_expedited() && !rcu_gp_is_normal() && !gp_exp) {
+		VERBOSE_PERFOUT_ERRSTRING("All grace periods expedited, no normal ones to measure!");
+		firsterr = -EINVAL;
+		goto unwind;
+	}
+	if (rcu_gp_is_normal() && gp_exp) {
+		VERBOSE_PERFOUT_ERRSTRING("All grace periods normal, no expedited ones to measure!");
+		firsterr = -EINVAL;
+		goto unwind;
+	}
 	for (i = 0; i < nrealwriters; i++) {
 		writer_durations[i] =
 			kcalloc(MAX_MEAS, sizeof(*writer_durations[i]),
Signature · 1 line
2.5.2
#13 lore raw

PATCH 13/14 torture: Inflict default jitter

In reply to Paul E. McKenney

This commit enables jitter by default. It may be manually disabled by passing "--jitter 0" to kvm.sh.

---
 tools/testing/selftests/rcutorture/bin/kvm.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/kvm.sh +1 -1
index 0d598145873e..0aed965f0062 100755
@@ -48,7 +48,7 @@ resdir=""
 configs=""
 cpus=0
 ds=`date +%Y.%m.%d-%H:%M:%S`
-jitter=0
+jitter="-1"
 
 . functions.sh
 
Signature · 1 line
2.5.2
#14 lore raw

PATCH 14/14 rcutorture: Fix error return code in rcu_perf_init()

In reply to Paul E. McKenney

From: Wei Yongjun <[email protected]>

Fix to return a negative error code -ENOMEM from kcalloc() error handling case instead of 0, as done elsewhere in this function.

---
 kernel/rcu/rcuperf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/rcu/rcuperf.c +3 -1
index 7b2dbdffd791..d38ab08a3fe7 100644
@@ -638,8 +638,10 @@ rcu_perf_init(void)
 		writer_durations[i] =
 			kcalloc(MAX_MEAS, sizeof(*writer_durations[i]),
 				GFP_KERNEL);
-		if (!writer_durations[i])
+		if (!writer_durations[i]) {
+			firsterr = -ENOMEM;
 			goto unwind;
+		}
 		firsterr = torture_create_kthread(rcu_perf_writer, (void *)i,
 						  writer_tasks[i]);
 		if (firsterr)
Signature · 1 line
2.5.2