3 # Run a series of 14 tests under KVM. These are not particularly
4 # well-selected or well-tuned, but are the current set. Run from the
5 # top level of the source tree.
7 # Edit the definitions below to set the locations of the various directories,
8 # as well as the test duration.
10 # Usage: sh kvm.sh [ options ]
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, you can access it online at
24 # http://www.gnu.org/licenses/gpl-2.0.html.
26 # Copyright (C) IBM Corporation, 2011
28 # Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
39 KVM
="`pwd`/tools/testing/selftests/rcutorture"; export KVM
40 PATH
=${KVM}/bin
:$PATH; export PATH
41 RCU_INITRD
="$KVM/initrd"; export RCU_INITRD
42 RCU_KMAKE_ARG
=""; export RCU_KMAKE_ARG
47 ds
=`date +%Y.%m.%d-%H:%M:%S`
53 echo "Usage: $scriptname optional arguments:"
54 echo " --bootargs kernel-boot-arguments"
56 echo " --configs \"config-file list\""
58 echo " --datestamp string"
59 echo " --dryrun sched|script"
60 echo " --duration minutes"
62 echo " --kmake-arg kernel-make-arguments"
63 echo " --kversion vN.NN"
64 echo " --mac nn:nn:nn:nn:nn:nn"
66 echo " --qemu-args qemu-system-..."
67 echo " --qemu-cmd qemu-system-..."
68 echo " --results absolute-pathname"
77 checkarg
--bootargs "(list of kernel boot arguments)" "$#" "$2" '.*' '^--'
82 RCU_BUILDONLY
=1; export RCU_BUILDONLY
85 checkarg
--configs "(list of config files)" "$#" "$2" '^[^/]*$' '^--'
90 checkarg
--cpus "(number)" "$#" "$2" '^[0-9]*$' '^--'
95 checkarg
--datestamp "(relative pathname)" "$#" "$2" '^[^/]*$' '^--'
100 checkarg
--dryrun "sched|script" $# "$2" 'sched\|script' '^--'
105 checkarg
--duration "(minutes)" $# "$2" '^[0-9]*$' '^error'
110 RCU_QEMU_INTERACTIVE
=1; export RCU_QEMU_INTERACTIVE
113 checkarg
--kmake-arg "(kernel make arguments)" $# "$2" '.*' '^error$'
114 RCU_KMAKE_ARG
="$2"; export RCU_KMAKE_ARG
118 checkarg
--kversion "(kernel version)" $# "$2" '^v[0-9.]*$' '^error'
123 checkarg
--mac "(MAC address)" $# "$2" '^\([0-9a-fA-F]\{2\}:\)\{5\}[0-9a-fA-F]\{2\}$' error
124 RCU_QEMU_MAC
=$2; export RCU_QEMU_MAC
128 RCU_INITRD
=""; export RCU_INITRD
131 checkarg
--qemu-args "-qemu args" $# "$2" '^-' '^error'
136 checkarg
--qemu-cmd "(qemu-system-...)" $# "$2" 'qemu-system-' '^--'
137 RCU_QEMU_CMD
="$2"; export RCU_QEMU_CMD
141 checkarg
--results "(absolute pathname)" "$#" "$2" '^/' '^error'
146 checkarg
--torture "(suite name)" "$#" "$2" '^\(lock\|rcu\)$' '^--'
151 echo Unknown argument
$1
158 CONFIGFRAG
=${KVM}/configs
/${TORTURE_SUITE}; export CONFIGFRAG
159 KVPATH
=${CONFIGFRAG}/$kversion; export KVPATH
161 if test -z "$configs"
163 configs
="`cat $CONFIGFRAG/$kversion/CFLIST`"
171 if test "$dryrun" = ""
175 mkdir
-p "$resdir" ||
:
179 # Be noisy only if running the script.
180 echo Results directory
: $resdir/$ds
181 echo $scriptname $args
183 touch $resdir/$ds/log
184 echo $scriptname $args >> $resdir/$ds/log
185 echo ${TORTURE_SUITE} > $resdir/$ds/TORTURE_SUITE
187 pwd > $resdir/$ds/testid.txt
190 git status
>> $resdir/$ds/testid.txt
191 git rev-parse HEAD
>> $resdir/$ds/testid.txt
195 # Create a file of test-name/#cpus pairs, sorted by decreasing #cpus.
199 if test -f "$CONFIGFRAG/$kversion/$CF"
201 echo $CF `configNR_CPUS.sh $CONFIGFRAG/$kversion/$CF` >> $T/cfgcpu
203 echo "The --configs file $CF does not exist, terminating."
207 sort -k2nr $T/cfgcpu
> $T/cfgcpu.
sort
209 # Use a greedy bin-packing algorithm, sorting the list accordingly.
210 awk < $T/cfgcpu.
sort > $T/cfgcpu.pack
-v ncpus
=$cpus '
216 # Read file of tests and corresponding required numbers of CPUs.
227 # Each pass through the following loop creates on test batch
228 # that can be executed concurrently given ncpus. Note that a
229 # given test that requires more than the available CPUs will run in
230 # their own batch. Such tests just have to make do with what
232 while (nc != ncpus) {
236 # Each pass through the following loop considers one
237 # test for inclusion in the current batch.
238 for (i = 0; i < njobs; i++) {
240 continue; # Already part of a batch.
241 if (nc >= cpus[i] || nc == ncpus) {
243 # This test fits into the current batch.
247 break; # Too-big test in its own batch.
252 # Dump out the tests in batch order.
253 for (b = 1; b <= batch; b++)
254 for (i = 0; i < njobs; i++)
256 print cf[i], cpus[i];
259 # Generate a script to execute the tests in appropriate batches.
260 cat << ___EOF___ > $T/script
261 TORTURE_SUITE="$TORTURE_SUITE"; export TORTURE_SUITE
263 awk < $T/cfgcpu.pack \
264 -v CONFIGDIR
="$CONFIGFRAG/$kversion/" \
269 -v RCU_QEMU_ARG
=$RCU_QEMU_ARG \
270 -v RCU_BOOTARGS
=$RCU_BOOTARGS \
281 # Dump out the scripting required to run one test batch.
282 function dump(first, pastlast)
284 print "echo ----Start batch: `date`";
285 print "echo ----Start batch: `date` >> " rd "/log";
287 for (j = first; j < pastlast; j++) {
290 if (cfrep[cf[j]] == "") {
295 cfr[jn] = cf[j] "." cfrep[cf[j]];
297 if (cpusr[jn] > ncpus && ncpus != 0)
301 print "echo ", cfr[jn], cpusr[jn] ovf ": Starting build. `date`";
302 print "echo ", cfr[jn], cpusr[jn] ovf ": Starting build. `date` >> " rd "/log";
303 print "rm -f " builddir ".*";
304 print "touch " builddir ".wait";
305 print "mkdir " builddir " > /dev/null 2>&1 || :";
306 print "mkdir " rd cfr[jn] " || :";
307 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 &"
308 print "echo ", cfr[jn], cpusr[jn] ovf ": Waiting for build to complete. `date`";
309 print "echo ", cfr[jn], cpusr[jn] ovf ": Waiting for build to complete. `date` >> " rd "/log";
310 print "while test -f " builddir ".wait"
314 print "echo ", cfr[jn], cpusr[jn] ovf ": Build complete. `date`";
315 print "echo ", cfr[jn], cpusr[jn] ovf ": Build complete. `date` >> " rd "/log";
318 for (j = 1; j < jn; j++) {
320 print "rm -f " builddir ".ready"
321 print "echo ----", cfr[j], cpusr[j] ovf ": Starting kernel. `date`";
322 print "echo ----", cfr[j], cpusr[j] ovf ": Starting kernel. `date` >> " rd "/log";
325 print "echo ---- All kernel runs complete. `date`";
326 print "echo ---- All kernel runs complete. `date` >> " rd "/log";
327 for (j = 1; j < jn; j++) {
329 print "echo ----", cfr[j], cpusr[j] ovf ": Build/run results:";
330 print "echo ----", cfr[j], cpusr[j] ovf ": Build/run results: >> " rd "/log";
331 print "cat " rd cfr[j] "/kvm-test-1-run.sh.out";
332 print "cat " rd cfr[j] "/kvm-test-1-run.sh.out >> " rd "/log";
341 # Each pass through the following loop considers one test.
342 for (i = 0; i < njobs; i++) {
344 # Sequential test specified, each test its own batch.
347 } else if (nc < cpus[i] && i != 0) {
348 # Out of CPUs, dump out a batch.
353 # Account for the CPUs needed by the current test.
356 # Dump the last batch.
361 if test "$dryrun" = script
363 # Dump out the script, but define the environment variables that
364 # it needs to run standalone.
365 echo CONFIGFRAG
="$CONFIGFRAG; export CONFIGFRAG"
366 echo KVM
="$KVM; export KVM"
367 echo KVPATH
="$KVPATH; export KVPATH"
368 echo PATH
="$PATH; export PATH"
369 echo RCU_BUILDONLY
="$RCU_BUILDONLY; export RCU_BUILDONLY"
370 echo RCU_INITRD
="$RCU_INITRD; export RCU_INITRD"
371 echo RCU_KMAKE_ARG
="$RCU_KMAKE_ARG; export RCU_KMAKE_ARG"
372 echo RCU_QEMU_CMD
="$RCU_QEMU_CMD; export RCU_QEMU_CMD"
373 echo RCU_QEMU_INTERACTIVE
="$RCU_QEMU_INTERACTIVE; export RCU_QEMU_INTERACTIVE"
374 echo RCU_QEMU_MAC
="$RCU_QEMU_MAC; export RCU_QEMU_MAC"
375 echo "mkdir -p "$resdir" || :"
376 echo "mkdir $resdir/$ds"
379 elif test "$dryrun" = sched
381 # Extract the test run schedule from the script.
382 egrep 'start batch|Starting build\.' $T/script |
383 sed -e 's/:.*$//' -e 's/^echo //'
386 # Not a dryru, so run the script.
390 # 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
394 echo " --- `date` Test summary:"
395 echo Results directory
: $resdir/$ds
396 kvm-recheck.sh
$resdir/$ds
This page took 0.040695 seconds and 6 git commands to generate.