aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/rcutorture/bin
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2013-10-04 16:15:55 -0400
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2013-12-03 13:11:15 -0500
commit315c540d46f8f11fe2a84e627d9473e90441ae96 (patch)
tree24544028c66196efce7dcd113a51549c04585fc5 /tools/testing/selftests/rcutorture/bin
parent2bcdf4e31ae4e215b1e61831d9defa3632cb7bd3 (diff)
rcutorture: Refactor to enable non-x86 architectures
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>
Diffstat (limited to 'tools/testing/selftests/rcutorture/bin')
-rw-r--r--tools/testing/selftests/rcutorture/bin/functions.sh78
-rwxr-xr-xtools/testing/selftests/rcutorture/bin/kvm-test-1-rcu.sh27
-rw-r--r--tools/testing/selftests/rcutorture/bin/kvm.sh10
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 () {
78 exit 1 78 exit 1
79 fi 79 fi
80} 80}
81
82# identify_qemu_append qemu-cmd
83#
84# Output arguments for the qemu "-append" string based on CPU type
85# and the RCU_QEMU_INTERACTIVE environment variable.
86identify_qemu_append () {
87 case "$1" in
88 qemu-system-x86_64|qemu-system-i386)
89 echo noapic selinux=0 initcall_debug debug
90 ;;
91 esac
92 if test -n "$RCU_QEMU_INTERACTIVE"
93 then
94 echo root=/dev/sda
95 else
96 echo console=ttyS0
97 fi
98}
99
100# identify_qemu_args qemu-cmd serial-file
101#
102# Output arguments for qemu arguments based on the RCU_QEMU_MAC
103# and RCU_QEMU_INTERACTIVE environment variables.
104identify_qemu_args () {
105 case "$1" in
106 qemu-system-x86_64|qemu-system-i386)
107 ;;
108 qemu-system-ppc64)
109 echo -enable-kvm -M pseries -cpu POWER7 -nodefaults
110 echo -device spapr-vscsi
111 if test -n "$RCU_QEMU_INTERACTIVE" -a -n "$RCU_QEMU_MAC"
112 then
113 echo -device spapr-vlan,netdev=net0,mac=$RCU_QEMU_MAC
114 echo -netdev bridge,br=br0,id=net0
115 elif test -n "$RCU_QEMU_INTERACTIVE"
116 then
117 echo -net nic -net user
118 fi
119 ;;
120 esac
121 if test -n "$RCU_QEMU_INTERACTIVE"
122 then
123 echo -monitor stdio -serial pty -S
124 else
125 echo -serial file:$2
126 fi
127}
128
129# identify_qemu_vcpus
130#
131# Returns the number of virtual CPUs available to the aggregate of the
132# guest OSes.
133identify_qemu_vcpus () {
134 lscpu | grep '^CPU(s):' | sed -e 's/CPU(s)://'
135}
136
137# specify_qemu_cpus qemu-cmd qemu-args #cpus
138#
139# Appends a string containing "-smp XXX" to qemu-args, unless the incoming
140# qemu-args already contains "-smp".
141specify_qemu_cpus () {
142 local nt;
143
144 if echo $2 | grep -q -e -smp
145 then
146 echo $2
147 else
148 case "$1" in
149 qemu-system-x86_64|qemu-system-i386)
150 echo $2 -smp $3
151 ;;
152 qemu-system-ppc64)
153 nt="`lscpu | grep '^NUMA node0' | sed -e 's/^[^,]*,\([0-9]*\),.*$/\1/'`"
154 echo $2 -smp cores=`expr \( $3 + $nt - 1 \) / $nt`,threads=$nt
155 ;;
156 esac
157 fi
158}
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`"
115 115
116# Generate -smp qemu argument. 116# Generate -smp qemu argument.
117cpu_count=`configNR_CPUS.sh $config_template` 117cpu_count=`configNR_CPUS.sh $config_template`
118ncpus=`grep '^processor' /proc/cpuinfo | wc -l` 118vcpus=`identify_qemu_vcpus`
119if test $cpu_count -gt $ncpus 119if test $cpu_count -gt $vcpus
120then 120then
121 echo CPU count limited from $cpu_count to $ncpus 121 echo CPU count limited from $cpu_count to $vcpus
122 touch $resdir/Warnings 122 touch $resdir/Warnings
123 echo CPU count limited from $cpu_count to $ncpus >> $resdir/Warnings 123 echo CPU count limited from $cpu_count to $vcpus >> $resdir/Warnings
124 cpu_count=$ncpus 124 cpu_count=$vcpus
125fi
126if echo $qemu_args | grep -q -e -smp
127then
128 echo CPU count specified by caller
129else
130 qemu_args="$qemu_args -smp $cpu_count"
131fi 125fi
126qemu_args="`specify_qemu_cpus "$QEMU" "$qemu_args" "$cpu_count"`"
127
128# Generate architecture-specific and interaction-specific qemu arguments
129qemu_args="$qemu_args `identify_qemu_args "$QEMU" "$builddir/console.log"`"
130
131# Generate qemu -append arguments
132qemu_append="`identify_qemu_append "$QEMU"`"
132 133
133# Generate CPU-hotplug boot parameters 134# Generate CPU-hotplug boot parameters
134boot_args="`rcutorture_param_onoff "$boot_args" $builddir/.config`" 135boot_args="`rcutorture_param_onoff "$boot_args" $builddir/.config`"
@@ -137,8 +138,8 @@ boot_args="`rcutorture_param_n_barrier_cbs "$boot_args"`"
137# Pull in Kconfig-fragment boot parameters 138# Pull in Kconfig-fragment boot parameters
138boot_args="`configfrag_boot_params "$boot_args" "$config_template"`" 139boot_args="`configfrag_boot_params "$boot_args" "$config_template"`"
139 140
140echo $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 141echo $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
141$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" & 142$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" &
142qemu_pid=$! 143qemu_pid=$!
143commandcompleted=0 144commandcompleted=0
144echo Monitoring qemu job at pid $qemu_pid 145echo 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 () {
44 echo " --configs \"config-file list\"" 44 echo " --configs \"config-file list\""
45 echo " --datestamp string" 45 echo " --datestamp string"
46 echo " --duration minutes" 46 echo " --duration minutes"
47 echo " --interactive"
47 echo " --kversion vN.NN" 48 echo " --kversion vN.NN"
49 echo " --mac nn:nn:nn:nn:nn:nn"
48 echo " --qemu-cmd qemu-system-..." 50 echo " --qemu-cmd qemu-system-..."
49 echo " --results absolute-pathname" 51 echo " --results absolute-pathname"
50 echo " --relbuilddir relative-pathname" 52 echo " --relbuilddir relative-pathname"
@@ -96,11 +98,19 @@ do
96 dur=$2 98 dur=$2
97 shift 99 shift
98 ;; 100 ;;
101 --interactive)
102 RCU_QEMU_INTERACTIVE=1; export RCU_QEMU_INTERACTIVE
103 ;;
99 --kversion) 104 --kversion)
100 checkarg --kversion "(kernel version)" $# "$2" '^v[0-9.]*$' error 105 checkarg --kversion "(kernel version)" $# "$2" '^v[0-9.]*$' error
101 kversion=$2 106 kversion=$2
102 shift 107 shift
103 ;; 108 ;;
109 --mac)
110 checkarg --mac "(MAC address)" $# "$2" '^\([0-9a-fA-F]\{2\}:\)\{5\}[0-9a-fA-F]\{2\}$' error
111 RCU_QEMU_MAC=$2; export RCU_QEMU_MAC
112 shift
113 ;;
104 --qemu-cmd) 114 --qemu-cmd)
105 checkarg --qemu-cmd "(qemu-system-...)" $# "$2" 'qemu-system-' '^--' 115 checkarg --qemu-cmd "(qemu-system-...)" $# "$2" 'qemu-system-' '^--'
106 RCU_QEMU_CMD="$2"; export RCU_QEMU_CMD 116 RCU_QEMU_CMD="$2"; export RCU_QEMU_CMD