linux-kernel.vger.kernel.org archive mirror
 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,
	sbw@mit.edu, "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Greg KH <gregkh@linuxfoundation.org>
Subject: [PATCH tip/core/rcu 15/28] rcutorture: Refactor to enable non-x86 architectures
Date: Fri, 15 Nov 2013 16:35:28 -0800	[thread overview]
Message-ID: <1384562141-32446-15-git-send-email-paulmck@linux.vnet.ibm.com> (raw)
In-Reply-To: <1384562141-32446-1-git-send-email-paulmck@linux.vnet.ibm.com>

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

This commit expands the checks for what architecture is running to generate
additional qemu-system- commands, then uses the resulting qemu-system-
command name to choose different qemu arguments as needed for different
architectures.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
---
 .../testing/selftests/rcutorture/bin/functions.sh  | 78 ++++++++++++++++++++++
 .../selftests/rcutorture/bin/kvm-test-1-rcu.sh     | 27 ++++----
 tools/testing/selftests/rcutorture/bin/kvm.sh      | 10 +++
 3 files changed, 102 insertions(+), 13 deletions(-)

diff --git a/tools/testing/selftests/rcutorture/bin/functions.sh b/tools/testing/selftests/rcutorture/bin/functions.sh
index c974414ef7a5..d0d19ebd2a94 100644
--- a/tools/testing/selftests/rcutorture/bin/functions.sh
+++ b/tools/testing/selftests/rcutorture/bin/functions.sh
@@ -78,3 +78,81 @@ identify_qemu () {
 		exit 1
 	fi
 }
+
+# identify_qemu_append qemu-cmd
+#
+# Output arguments for the qemu "-append" string based on CPU type
+# and the RCU_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"
+	then
+		echo root=/dev/sda
+	else
+		echo console=ttyS0
+	fi
+}
+
+# identify_qemu_args qemu-cmd serial-file
+#
+# Output arguments for qemu arguments based on the RCU_QEMU_MAC
+# and RCU_QEMU_INTERACTIVE environment variables.
+identify_qemu_args () {
+	case "$1" in
+	qemu-system-x86_64|qemu-system-i386)
+		;;
+	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"
+		then
+			echo -device spapr-vlan,netdev=net0,mac=$RCU_QEMU_MAC
+			echo -netdev bridge,br=br0,id=net0
+		elif test -n "$RCU_QEMU_INTERACTIVE"
+		then
+			echo -net nic -net user
+		fi
+		;;
+	esac
+	if test -n "$RCU_QEMU_INTERACTIVE"
+	then
+		echo -monitor stdio -serial pty -S
+	else
+		echo -serial file:$2
+	fi
+}
+
+# identify_qemu_vcpus
+#
+# Returns the number of virtual CPUs available to the aggregate of the
+# guest OSes.
+identify_qemu_vcpus () {
+	lscpu | grep '^CPU(s):' | sed -e 's/CPU(s)://'
+}
+
+# specify_qemu_cpus qemu-cmd qemu-args #cpus
+#
+# Appends a string containing "-smp XXX" to qemu-args, unless the incoming
+# qemu-args already contains "-smp".
+specify_qemu_cpus () {
+	local nt;
+
+	if echo $2 | grep -q -e -smp
+	then
+		echo $2
+	else
+		case "$1" in
+		qemu-system-x86_64|qemu-system-i386)
+			echo $2 -smp $3
+			;;
+		qemu-system-ppc64)
+			nt="`lscpu | grep '^NUMA node0' | sed -e 's/^[^,]*,\([0-9]*\),.*$/\1/'`"
+			echo $2 -smp cores=`expr \( $3 + $nt - 1 \) / $nt`,threads=$nt
+			;;
+		esac
+	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 5e2e79b5eaba..9fd546ccb075 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-rcu.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-rcu.sh
@@ -115,20 +115,21 @@ QEMU="`identify_qemu $builddir/vmlinux.o`"
 
 # Generate -smp qemu argument.
 cpu_count=`configNR_CPUS.sh $config_template`
-ncpus=`grep '^processor' /proc/cpuinfo | wc -l`
-if test $cpu_count -gt $ncpus
+vcpus=`identify_qemu_vcpus`
+if test $cpu_count -gt $vcpus
 then
-	echo CPU count limited from $cpu_count to $ncpus
+	echo CPU count limited from $cpu_count to $vcpus
 	touch $resdir/Warnings
-	echo CPU count limited from $cpu_count to $ncpus >> $resdir/Warnings
-	cpu_count=$ncpus
-fi
-if echo $qemu_args | grep -q -e -smp
-then
-	echo CPU count specified by caller
-else
-	qemu_args="$qemu_args -smp $cpu_count"
+	echo CPU count limited from $cpu_count to $vcpus >> $resdir/Warnings
+	cpu_count=$vcpus
 fi
+qemu_args="`specify_qemu_cpus "$QEMU" "$qemu_args" "$cpu_count"`"
+
+# Generate architecture-specific and interaction-specific qemu arguments
+qemu_args="$qemu_args `identify_qemu_args "$QEMU" "$builddir/console.log"`"
+
+# Generate qemu -append arguments
+qemu_append="`identify_qemu_append "$QEMU"`"
 
 # Generate CPU-hotplug boot parameters
 boot_args="`rcutorture_param_onoff "$boot_args" $builddir/.config`"
@@ -137,8 +138,8 @@ boot_args="`rcutorture_param_n_barrier_cbs "$boot_args"`"
 # Pull in Kconfig-fragment boot parameters
 boot_args="`configfrag_boot_params "$boot_args" "$config_template"`"
 
-echo $QEMU -serial file:$builddir/console.log $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append \"noapic selinux=0 console=ttyS0 initcall_debug debug rcutorture.stat_interval=15 rcutorture.shutdown_secs=$seconds rcutorture.rcutorture_runnable=1 $boot_args\" > $resdir/qemu-cmd
-$QEMU -name rcu-test -serial file:$builddir/console.log $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append "noapic selinux=0 console=ttyS0 initcall_debug debug rcutorture.stat_interval=15 rcutorture.shutdown_secs=$seconds rcutorture.rcutorture_runnable=1 $boot_args" &
+echo $QEMU $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append \"$qemu_append rcutorture.stat_interval=15 rcutorture.shutdown_secs=$seconds rcutorture.rcutorture_runnable=1 $boot_args\" > $resdir/qemu-cmd
+$QEMU $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append "$qemu_append rcutorture.stat_interval=15 rcutorture.shutdown_secs=$seconds rcutorture.rcutorture_runnable=1 $boot_args" &
 qemu_pid=$!
 commandcompleted=0
 echo Monitoring qemu job at pid $qemu_pid
diff --git a/tools/testing/selftests/rcutorture/bin/kvm.sh b/tools/testing/selftests/rcutorture/bin/kvm.sh
index 2af549491f23..979c34134634 100644
--- a/tools/testing/selftests/rcutorture/bin/kvm.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm.sh
@@ -44,7 +44,9 @@ usage () {
 	echo "       --configs \"config-file list\""
 	echo "       --datestamp string"
 	echo "       --duration minutes"
+	echo "       --interactive"
 	echo "       --kversion vN.NN"
+	echo "       --mac nn:nn:nn:nn:nn:nn"
 	echo "       --qemu-cmd qemu-system-..."
 	echo "       --results absolute-pathname"
 	echo "       --relbuilddir relative-pathname"
@@ -96,11 +98,19 @@ do
 		dur=$2
 		shift
 		;;
+	--interactive)
+		RCU_QEMU_INTERACTIVE=1; export RCU_QEMU_INTERACTIVE
+		;;
 	--kversion)
 		checkarg --kversion "(kernel version)" $# "$2" '^v[0-9.]*$' error
 		kversion=$2
 		shift
 		;;
+	--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
+		shift
+		;;
 	--qemu-cmd)
 		checkarg --qemu-cmd "(qemu-system-...)" $# "$2" 'qemu-system-' '^--'
 		RCU_QEMU_CMD="$2"; export RCU_QEMU_CMD
-- 
1.8.1.5


  parent reply	other threads:[~2013-11-16  0:40 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-16  0:35 [PATCH tip/core/rcu 0/28] RCU torture scripting for 3.14 Paul E. McKenney
2013-11-16  0:35 ` [PATCH tip/core/rcu 01/28] rcutorture: Add KVM-based test framework Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 02/28] rcutorture: Add datestamp argument to kvm.sh Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 03/28] rcutorture: Add kernel-version argument Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 04/28] rcutorture: Add per-version default Kconfig fragments and module parameters Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 05/28] rcutorture: Add per-Kconfig fragment boot parameters Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 06/28] rcutorture: Add v3.12 version, which adds sysidle testing Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 07/28] rcutorture: Add SRCU Kconfig-fragment files Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 08/28] rcutorture: Refactor TREE_RCU test cases Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 09/28] rcutorture: Refactor TINY_RCU " Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 10/28] rcutorture: Make test output less chatty Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 11/28] rcutorture: Eliminate duplicate .config-check code Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 12/28] rcutorture: Abstract qemu-flavor identification Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 13/28] rcutorture: Remove decorative qemu argument Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 14/28] rcutorture: Eliminate --rcu-kvm argument Paul E. McKenney
2013-11-16  0:35   ` Paul E. McKenney [this message]
2013-11-16  0:35   ` [PATCH tip/core/rcu 16/28] rcutorture: Allow Kconfig-related boot parameters to override Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 17/28] rcutorture: Eliminate configdir argument from kvm-recheck.sh script Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 18/28] rcutorture: Add --buildonly dry-run capability Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 19/28] rcutorture: Add --bootargs argument to specify additional boot arguments Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 20/28] rcutorture: Add --qemu-args argument to kvm.sh Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 21/28] rcutorture: Add --no-initrd " Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 22/28] rcutorture: Add --kmake-arg " Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 23/28] rcutorture: Add tracing-enabled version of TREE08 Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 24/28] rcutorture: Update comment in kvm.sh listing typical RCU trace events Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 25/28] rcutorture: Test summary at end of run with less chattiness Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 26/28] rcutorture: Record results from repeated runs of the same test scenario Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 27/28] rcutorture: Flag errors and warnings with color coding Paul E. McKenney
2013-11-16  0:35   ` [PATCH tip/core/rcu 28/28] rcutorture: Move checkarg to functions.sh Paul E. McKenney
2013-11-16  1:05   ` [PATCH tip/core/rcu 01/28] rcutorture: Add KVM-based test framework Greg KH
2013-11-16  1:21     ` Paul E. McKenney
2013-11-16  1:47       ` Steven Rostedt
2013-11-16  2:01         ` Greg KH
2013-11-16  3:56           ` Paul E. McKenney
2013-11-21  0:25         ` Josh Triplett

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=1384562141-32446-15-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=gregkh@linuxfoundation.org \
    --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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).