All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: mingo@kernel.org, laijs@cn.fujitsu.com, dipankar@in.ibm.com,
	akpm@linux-foundation.org, mathieu.desnoyers@efficios.com,
	josh@joshtriplett.org, niv@us.ibm.com, tglx@linutronix.de,
	peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com,
	edumazet@google.com, darren@dvhart.com, fweisbec@gmail.com,
	oleg@redhat.com, sbw@mit.edu,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: [PATCH tip/core/rcu 07/55] rcutorture: Enable concurrent rcutorture runs
Date: Mon, 17 Feb 2014 14:12:11 -0800	[thread overview]
Message-ID: <1392675179-11560-7-git-send-email-paulmck@linux.vnet.ibm.com> (raw)
In-Reply-To: <1392675179-11560-1-git-send-email-paulmck@linux.vnet.ibm.com>

From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>

The rcutorture tests run by default range from using one CPU to using
sixteen of them.  Therefore, rcutorture testing could be sped up
significantly simply by running the kernels in parallel.  Building
them in parallel is not all that helpful: "make -j" is usually a
better bet.  So this commit takes a new "--cpus" argument that
specifies how many CPUs rcutorture is permitted to use for its
parallel runs.  The default of zero does sequential runs as before.

The bin-packing is minimal, and will be grossly suboptimal for
some configurations.  However, powers of two work reasonably well.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 .../testing/selftests/rcutorture/bin/functions.sh  |   1 +
 .../selftests/rcutorture/bin/kvm-recheck.sh        |   4 +-
 .../selftests/rcutorture/bin/kvm-test-1-rcu.sh     |   2 +-
 tools/testing/selftests/rcutorture/bin/kvm.sh      | 125 +++++++++++++++++----
 4 files changed, 108 insertions(+), 24 deletions(-)

diff --git a/tools/testing/selftests/rcutorture/bin/functions.sh b/tools/testing/selftests/rcutorture/bin/functions.sh
index 587561d7c035..9b17e810ddc3 100644
--- a/tools/testing/selftests/rcutorture/bin/functions.sh
+++ b/tools/testing/selftests/rcutorture/bin/functions.sh
@@ -96,6 +96,7 @@ identify_qemu () {
 		echo qemu-system-ppc64
 	else
 		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
 		# argument to top-level script.
diff --git a/tools/testing/selftests/rcutorture/bin/kvm-recheck.sh b/tools/testing/selftests/rcutorture/bin/kvm-recheck.sh
index eb2850935c26..89b5dbac5327 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-recheck.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-recheck.sh
@@ -31,9 +31,9 @@ do
 	dirs=`find $rd -name Make.defconfig.out -print | sort | sed -e 's,/[^/]*$,,' | sort -u`
 	for i in $dirs
 	do
-		if test $firsttime
+		if test -n "$firsttime"
 		then
-			firsttime=0
+			firsttime=""
 			resdir=`echo $i | sed -e 's,/$,,' -e 's,/[^/]*$,,'`
 			head -1 $resdir/log
 		fi
diff --git a/tools/testing/selftests/rcutorture/bin/kvm-test-1-rcu.sh b/tools/testing/selftests/rcutorture/bin/kvm-test-1-rcu.sh
index a06a0a6ce5ac..1b9555b2b0d7 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-rcu.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-rcu.sh
@@ -123,7 +123,7 @@ kstarttime=`awk 'BEGIN { print systime() }' < /dev/null`
 echo ' ---' `date`: Starting kernel
 
 # Determine the appropriate flavor of qemu command.
-QEMU="`identify_qemu $builddir/vmlinux.o`"
+QEMU="`identify_qemu $builddir/vmlinux`"
 
 # Generate -smp qemu argument.
 qemu_args="-nographic $qemu_args"
diff --git a/tools/testing/selftests/rcutorture/bin/kvm.sh b/tools/testing/selftests/rcutorture/bin/kvm.sh
index f2113493bbfc..f74f00628afe 100644
--- a/tools/testing/selftests/rcutorture/bin/kvm.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm.sh
@@ -30,6 +30,10 @@
 scriptname=$0
 args="$*"
 
+T=/tmp/kvm.sh.$$
+trap 'rm -rf $T' 0
+mkdir $T
+
 dur=30
 KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
 PATH=${KVM}/bin:$PATH; export PATH
@@ -38,6 +42,7 @@ RCU_INITRD="$KVM/initrd"; export RCU_INITRD
 RCU_KMAKE_ARG=""; export RCU_KMAKE_ARG
 resdir=""
 configs=""
+cpus=0
 ds=`date +%Y.%m.%d-%H:%M:%S`
 kversion=""
 
@@ -49,6 +54,7 @@ usage () {
 	echo "       --builddir absolute-pathname"
 	echo "       --buildonly"
 	echo "       --configs \"config-file list\""
+	echo "       --cpus N"
 	echo "       --datestamp string"
 	echo "       --duration minutes"
 	echo "       --interactive"
@@ -85,6 +91,11 @@ do
 		configs="$2"
 		shift
 		;;
+	--cpus)
+		checkarg --cpus "(number)" "$#" "$2" '^[0-9]*$' '^--'
+		cpus=$2
+		shift
+		;;
 	--datestamp)
 		checkarg --datestamp "(relative pathname)" "$#" "$2" '^[^/]*$' '^--'
 		ds=$2
@@ -168,6 +179,7 @@ else
 	fi
 fi
 mkdir $resdir/$ds
+echo Results directory: $resdir/$ds
 touch $resdir/$ds/log
 echo $scriptname $args
 echo $scriptname $args >> $resdir/$ds/log
@@ -178,33 +190,104 @@ then
 	git status >> $resdir/$ds/testid.txt
 	git rev-parse HEAD >> $resdir/$ds/testid.txt
 fi
-builddir=$KVM/b1
-if ! test -e $builddir
-then
-	mkdir $builddir || :
-fi
 
+touch $T/cfgcpu
 for CF in $configs
 do
-	# Running TREE01 multiple times creates TREE01, TREE01.2, TREE01.3, ...
-	rd=$resdir/$ds/$CF
-	if test -d "${rd}"
+	if test -f "$CONFIGFRAG/$kversion/$CF"
 	then
-		n="`ls -d "${rd}"* | grep '\.[0-9]\+$' |
-			sed -e 's/^.*\.\([0-9]\+\)/\1/' |
-			sort -k1n | tail -1`"
-		if test -z "$n"
-		then
-			rd="${rd}.2"
-		else
-			n="`expr $n + 1`"
-			rd="${rd}.${n}"
-		fi
+		echo $CF `configNR_CPUS.sh $CONFIGFRAG/$kversion/$CF` >> $T/cfgcpu
+	else
+		echo "The --configs file $CF does not exist, terminating."
+		exit 1
 	fi
-	mkdir "${rd}"
-	echo Results directory: $rd
-	kvm-test-1-rcu.sh $CONFIGFRAG/$kversion/$CF $builddir $rd $dur "$RCU_QEMU_ARG" "$RCU_BOOTARGS"
 done
+sort -k2nr $T/cfgcpu > $T/cfgcpu.sort
+
+awk < $T/cfgcpu.sort \
+	-v CONFIGDIR="$CONFIGFRAG/$kversion/" \
+	-v KVM="$KVM" \
+	-v ncpus=$cpus \
+	-v rd=$resdir/$ds/ \
+	-v dur=$dur \
+	-v RCU_QEMU_ARG=$RCU_QEMU_ARG \
+	-v RCU_BOOTARGS=$RCU_BOOTARGS \
+'BEGIN {
+	i = 0;
+}
+
+{
+	cf[i] = $1;
+	cpus[i] = $2;
+	i++;
+}
+
+function dump(first, pastlast)
+{
+	print "echo ----start batch----"
+	jn=1
+	for (j = first; j < pastlast; j++) {
+		builddir=KVM "/b" jn
+		print "echo ", cf[j], cpus[j] ": Starting build."
+		print "rm -f " builddir ".*"
+		print "touch " builddir ".wait"
+		print "mkdir " builddir " || :"
+		if (cfrep[cf[j]] == "") {
+			cfr[j] = cf[j];
+			cfrep[cf[j]] = 1;
+		} else {
+			cfrep[cf[j]]++;
+			cfr[j] = cf[j] "." cfrep[cf[j]];
+		}
+		print "mkdir " rd cfr[j] " || :";
+		print "kvm-test-1-rcu.sh " CONFIGDIR cf[j], builddir, rd cfr[j], dur " \"" RCU_QEMU_ARG "\" \"" RCU_BOOTARGS "\" > " builddir ".out 2>&1 &"
+		print "echo ", cf[j], cpus[j] ": Waiting for build to complete."
+		print "while test -f " builddir ".wait"
+		print "do"
+		print "\tsleep 1"
+		print "done"
+		print "echo ", cf[j], cpus[j] ": Build complete."
+		jn++;
+	}
+	k = first
+	for (j = 1; j < jn; j++) {
+		builddir=KVM "/b" j
+		print "rm -f " builddir ".ready"
+		print "echo ----", cf[k], cpus[k] ": Starting kernel"
+		k++;
+	}
+	print "wait"
+	print "echo ---- All kernel runs complete"
+	k = first
+	for (j = 1; j < jn; j++) {
+		builddir=KVM "/b" j
+		print "echo ----", cf[k], cpus[k] ": Build/run results:"
+		print "cat " builddir ".out"
+		k++;
+	}
+}
+
+END {
+	njobs = i;
+	nc = ncpus;
+	first = 0;
+	for (i = 0; i < njobs; i++) {
+		if (ncpus == 0) {
+			dump(i, i + 1);
+			first = i;
+		} else if (nc < cpus[i] && i != 0) {
+			dump(first, i);
+			first = i;
+			nc = ncpus;
+		}
+		nc -= cpus[i];
+	}
+	if (ncpus != 0)
+		dump(first, i);
+}' > $T/script
+
+sh $T/script
+
 # 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 " --- `date` Test summary:"
-- 
1.8.1.5


  parent reply	other threads:[~2014-02-17 22:23 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-17 22:12 [PATCH tip/core/rcu 0/55] Torture-test changes for 3.15 Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 01/55] rcutorture: Print grace-period performance statistics Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 02/55] rcutorture: Print script and arguments to standard output Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 03/55] rcutorture: Move common boot flags to kvm-test-1-rcu.sh Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 04/55] rcutorture: Allow kvm-test-1-rcu.sh to pause after build Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 05/55] rcutorture: Move common qemu flags to kvm-test-1.sh Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 06/55] rcutorture: Reduce SRCU-N number of CPUs Paul E. McKenney
2014-02-17 22:12   ` Paul E. McKenney [this message]
2014-02-17 22:12   ` [PATCH tip/core/rcu 08/55] rcutorture: Fix results-directory error message Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 09/55] rcutorture: Add dryrun capability Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 10/55] rcutorture: Handle multiple runs of the same test Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 11/55] rcutorture: Do better bin packing Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 12/55] rcutorture: Add comments, especially on " Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 13/55] rcutorture: Flag tests requiring more CPUs than are available Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 14/55] rcutorture: Print results directory when dumping results Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 15/55] rcutorture: Abstract rcu_torture_random() Paul E. McKenney
2014-02-18  0:11     ` Josh Triplett
2014-02-18  0:22       ` Paul E. McKenney
2014-02-18  0:27         ` Josh Triplett
2014-02-18 21:33           ` Paul E. McKenney
2014-02-19  2:52           ` George Spelvin
2014-02-17 22:12   ` [PATCH tip/core/rcu 16/55] rcutorture: Don't create results directory for dryruns Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 17/55] rcutorture: Abstract torture_param() Paul E. McKenney
2014-02-18  0:23     ` Josh Triplett
2014-02-18 21:31       ` Paul E. McKenney
2014-02-18 23:53         ` josh
2014-02-23 16:48           ` Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 18/55] rcutorture: Rename PRINTK to TOROUT Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 19/55] rcutorture: Abstract TOROUT_STRING() and friends Paul E. McKenney
2014-02-18  0:26     ` Josh Triplett
2014-02-18  0:58       ` Paul E. McKenney
2014-02-18  1:23         ` Josh Triplett
2014-02-18  1:43           ` Paul E. McKenney
2014-02-18  3:36             ` Josh Triplett
2014-02-17 22:12   ` [PATCH tip/core/rcu 20/55] rcutorture: Abstract torture_shutdown_absorb() Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 21/55] rcutorture: Export torture_type and verbose module parameters Paul E. McKenney
2014-02-18  0:29     ` Josh Triplett
2014-02-18  1:01       ` Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 22/55] rcutorture: Abstract torture_shuffle() Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 23/55] rcutorture: Abstract torture_onoff() Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 24/55] rcutorture: Abstract torture-test initialization Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 25/55] rcutorture: Abstract torture-test cleanup Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 26/55] rcutorture: Print dates when doing parallel rcutorture runs Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 27/55] rcutorture: Abstract torture_shutdown_notify() Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 28/55] rcutorture: Privatize fullstop Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 29/55] rcutorture: Add diagnostic for unscheduled system shutdown Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 30/55] rcutorture: Abstract stutter_wait() Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 31/55] rcutorture: Apply ACCESS_ONCE() to racy fullstop accesses Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 32/55] rcutorture: Abstract torture_shutdown() Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 33/55] rcutorture: Clean up rcu_torture_init() error checking Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 34/55] rcutorture: Announce task creation Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 35/55] rcutorture: Fix rcutorture shutdown races Paul E. McKenney
2014-02-18  0:32     ` Josh Triplett
2014-02-18 21:35       ` Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 36/55] rcutorture: Fix missing-return bug in rcu_torture_barrier_init() Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 37/55] rcutorture: Abstract torture_create_kthread() Paul E. McKenney
2014-02-18  0:34     ` Josh Triplett
2014-02-18 21:36       ` Paul E. McKenney
2014-02-19  0:02         ` josh
2014-02-17 22:12   ` [PATCH tip/core/rcu 38/55] rcutorture: Abstract torture_stop_kthread() Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 39/55] rcutorture: Stop generic kthreads in torture_cleanup() Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 40/55] rcutorture: Remove redundant module-alias directives Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 41/55] rcutorture: Abstract kvm-recheck.sh Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 42/55] locktorture: Add a lock-torture kernel module Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 43/55] rcutorture: Add an rcu_busted to test the test Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 44/55] rcutorture: Create config files for scripted test-the-test testing Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 45/55] rcutorture: Create CFcommon file for common Kconfig parameters Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 46/55] rcutorture: Remove RCU dependencies from ver_functions.sh API Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 47/55] rcutorture: Rename kvm-test-1-rcu.sh Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 48/55] rcutorture: Introduce "rcu" directory level underneath configs Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 49/55] locktorture: Add vestigial locktorture configuration Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 50/55] rcutorture: Gracefully handle NULL cleanup hooks Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 51/55] locktorture: Add kvm-recheck.sh plug-in for locktorture Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 52/55] rcutorture: Rename TREE_RCU-Kconfig.txt Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 53/55] rcutorture: Place kvm-test-1-run.sh output into res directory Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 54/55] rcutorture: Add a lock_busted to test the test Paul E. McKenney
2014-02-17 22:12   ` [PATCH tip/core/rcu 55/55] rcutorture: Save kvm.sh output to log Paul E. McKenney
2014-02-18  0:41 ` [PATCH tip/core/rcu 0/55] Torture-test changes for 3.15 Josh Triplett
2014-02-18  0:48   ` Josh Triplett
2014-02-18  1:18     ` Paul E. McKenney
2014-02-18  1:18   ` Paul E. McKenney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1392675179-11560-7-git-send-email-paulmck@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=darren@dvhart.com \
    --cc=dhowells@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=edumazet@google.com \
    --cc=fweisbec@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@kernel.org \
    --cc=niv@us.ibm.com \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sbw@mit.edu \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.