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
42 RCU_INITRD
="$KVM/initrd"; export RCU_INITRD
43 RCU_KMAKE_ARG
=""; export RCU_KMAKE_ARG
48 ds
=`date +%Y.%m.%d-%H:%M:%S`
54 echo "Usage: $scriptname optional arguments:"
55 echo " --bootargs kernel-boot-arguments"
56 echo " --builddir absolute-pathname"
58 echo " --configs \"config-file list\""
60 echo " --datestamp string"
61 echo " --dryrun sched|script"
62 echo " --duration minutes"
64 echo " --kmake-arg kernel-make-arguments"
65 echo " --kversion vN.NN"
66 echo " --mac nn:nn:nn:nn:nn:nn"
68 echo " --qemu-args qemu-system-..."
69 echo " --qemu-cmd qemu-system-..."
70 echo " --relbuilddir relative-pathname"
71 echo " --results absolute-pathname"
80 checkarg
--bootargs "(list of kernel boot arguments)" "$#" "$2" '.*' '^--'
85 checkarg
--builddir "(absolute pathname)" "$#" "$2" '^/' '^error'
91 RCU_BUILDONLY
=1; export RCU_BUILDONLY
94 checkarg
--configs "(list of config files)" "$#" "$2" '^[^/]*$' '^--'
99 checkarg
--cpus "(number)" "$#" "$2" '^[0-9]*$' '^--'
104 checkarg
--datestamp "(relative pathname)" "$#" "$2" '^[^/]*$' '^--'
109 checkarg
--dryrun "sched|script" $# "$2" 'sched\|script' '^--'
114 checkarg
--duration "(minutes)" $# "$2" '^[0-9]*$' '^error'
119 RCU_QEMU_INTERACTIVE
=1; export RCU_QEMU_INTERACTIVE
122 checkarg
--kmake-arg "(kernel make arguments)" $# "$2" '.*' '^error$'
123 RCU_KMAKE_ARG
="$2"; export RCU_KMAKE_ARG
127 checkarg
--kversion "(kernel version)" $# "$2" '^v[0-9.]*$' '^error'
132 checkarg
--mac "(MAC address)" $# "$2" '^\([0-9a-fA-F]\{2\}:\)\{5\}[0-9a-fA-F]\{2\}$' error
133 RCU_QEMU_MAC
=$2; export RCU_QEMU_MAC
137 RCU_INITRD
=""; export RCU_INITRD
140 checkarg
--qemu-args "-qemu args" $# "$2" '^-' '^error'
145 checkarg
--qemu-cmd "(qemu-system-...)" $# "$2" 'qemu-system-' '^--'
146 RCU_QEMU_CMD
="$2"; export RCU_QEMU_CMD
150 checkarg
--relbuilddir "(relative pathname)" "$#" "$2" '^[^/]*$' '^--'
153 builddir
=${KVM}/${relbuilddir}
157 checkarg
--results "(absolute pathname)" "$#" "$2" '^/' '^error'
162 checkarg
--torture "(suite name)" "$#" "$2" '^\(lock\|rcu\)$' '^--'
167 echo Unknown argument
$1
174 CONFIGFRAG
=${KVM}/configs
/${TORTURE_SUITE}; export CONFIGFRAG
175 KVPATH
=${CONFIGFRAG}/$kversion; export KVPATH
177 if test -z "$configs"
179 configs
="`cat $CONFIGFRAG/$kversion/CFLIST`"
187 if test "$dryrun" = ""
191 mkdir
-p "$resdir" ||
:
195 # Be noisy only if running the script.
196 echo Results directory
: $resdir/$ds
197 echo $scriptname $args
199 touch $resdir/$ds/log
200 echo $scriptname $args >> $resdir/$ds/log
201 echo ${TORTURE_SUITE} > $resdir/$ds/TORTURE_SUITE
203 pwd > $resdir/$ds/testid.txt
206 git status
>> $resdir/$ds/testid.txt
207 git rev-parse HEAD
>> $resdir/$ds/testid.txt
211 # Create a file of test-name/#cpus pairs, sorted by decreasing #cpus.
215 if test -f "$CONFIGFRAG/$kversion/$CF"
217 echo $CF `configNR_CPUS.sh $CONFIGFRAG/$kversion/$CF` >> $T/cfgcpu
219 echo "The --configs file $CF does not exist, terminating."
223 sort -k2nr $T/cfgcpu
> $T/cfgcpu.
sort
225 # Use a greedy bin-packing algorithm, sorting the list accordingly.
226 awk < $T/cfgcpu.
sort > $T/cfgcpu.pack
-v ncpus
=$cpus '
232 # Read file of tests and corresponding required numbers of CPUs.
243 # Each pass through the following loop creates on test batch
244 # that can be executed concurrently given ncpus. Note that a
245 # given test that requires more than the available CPUs will run in
246 # their own batch. Such tests just have to make do with what
248 while (nc != ncpus) {
252 # Each pass through the following loop considers one
253 # test for inclusion in the current batch.
254 for (i = 0; i < njobs; i++) {
256 continue; # Already part of a batch.
257 if (nc >= cpus[i] || nc == ncpus) {
259 # This test fits into the current batch.
263 break; # Too-big test in its own batch.
268 # Dump out the tests in batch order.
269 for (b = 1; b <= batch; b++)
270 for (i = 0; i < njobs; i++)
272 print cf[i], cpus[i];
275 # Generate a script to execute the tests in appropriate batches.
276 cat << ___EOF___ > $T/script
277 TORTURE_SUITE="$TORTURE_SUITE"; export TORTURE_SUITE
279 awk < $T/cfgcpu.pack \
280 -v CONFIGDIR
="$CONFIGFRAG/$kversion/" \
285 -v RCU_QEMU_ARG
=$RCU_QEMU_ARG \
286 -v RCU_BOOTARGS
=$RCU_BOOTARGS \
297 # Dump out the scripting required to run one test batch.
298 function dump(first, pastlast)
300 print "echo ----Start batch: `date`";
301 print "echo ----Start batch: `date` >> " rd "/log";
303 for (j = first; j < pastlast; j++) {
306 if (cfrep[cf[j]] == "") {
311 cfr[jn] = cf[j] "." cfrep[cf[j]];
313 if (cpusr[jn] > ncpus && ncpus != 0)
317 print "echo ", cfr[jn], cpusr[jn] ovf ": Starting build. `date`";
318 print "echo ", cfr[jn], cpusr[jn] ovf ": Starting build. `date` >> " rd "/log";
319 print "rm -f " builddir ".*";
320 print "touch " builddir ".wait";
321 print "mkdir " builddir " > /dev/null 2>&1 || :";
322 print "mkdir " rd cfr[jn] " || :";
323 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 &"
324 print "echo ", cfr[jn], cpusr[jn] ovf ": Waiting for build to complete. `date`";
325 print "echo ", cfr[jn], cpusr[jn] ovf ": Waiting for build to complete. `date` >> " rd "/log";
326 print "while test -f " builddir ".wait"
330 print "echo ", cfr[jn], cpusr[jn] ovf ": Build complete. `date`";
331 print "echo ", cfr[jn], cpusr[jn] ovf ": Build complete. `date` >> " rd "/log";
334 for (j = 1; j < jn; j++) {
336 print "rm -f " builddir ".ready"
337 print "echo ----", cfr[j], cpusr[j] ovf ": Starting kernel. `date`";
338 print "echo ----", cfr[j], cpusr[j] ovf ": Starting kernel. `date` >> " rd "/log";
341 print "echo ---- All kernel runs complete. `date`";
342 print "echo ---- All kernel runs complete. `date` >> " rd "/log";
343 for (j = 1; j < jn; j++) {
345 print "echo ----", cfr[j], cpusr[j] ovf ": Build/run results:";
346 print "echo ----", cfr[j], cpusr[j] ovf ": Build/run results: >> " rd "/log";
347 print "cat " rd cfr[j] "/kvm-test-1-run.sh.out";
348 print "cat " rd cfr[j] "/kvm-test-1-run.sh.out >> " rd "/log";
357 # Each pass through the following loop considers one test.
358 for (i = 0; i < njobs; i++) {
360 # Sequential test specified, each test its own batch.
363 } else if (nc < cpus[i] && i != 0) {
364 # Out of CPUs, dump out a batch.
369 # Account for the CPUs needed by the current test.
372 # Dump the last batch.
377 if test "$dryrun" = script
379 # Dump out the script, but define the environment variables that
380 # it needs to run standalone.
381 echo CONFIGFRAG
="$CONFIGFRAG; export CONFIGFRAG"
382 echo KVM
="$KVM; export KVM"
383 echo KVPATH
="$KVPATH; export KVPATH"
384 echo PATH
="$PATH; export PATH"
385 echo RCU_BUILDONLY
="$RCU_BUILDONLY; export RCU_BUILDONLY"
386 echo RCU_INITRD
="$RCU_INITRD; export RCU_INITRD"
387 echo RCU_KMAKE_ARG
="$RCU_KMAKE_ARG; export RCU_KMAKE_ARG"
388 echo RCU_QEMU_CMD
="$RCU_QEMU_CMD; export RCU_QEMU_CMD"
389 echo RCU_QEMU_INTERACTIVE
="$RCU_QEMU_INTERACTIVE; export RCU_QEMU_INTERACTIVE"
390 echo RCU_QEMU_MAC
="$RCU_QEMU_MAC; export RCU_QEMU_MAC"
391 echo "mkdir -p "$resdir" || :"
392 echo "mkdir $resdir/$ds"
395 elif test "$dryrun" = sched
397 # Extract the test run schedule from the script.
398 egrep 'start batch|Starting build\.' $T/script |
399 sed -e 's/:.*$//' -e 's/^echo //'
402 # Not a dryru, so run the script.
406 # 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
410 echo " --- `date` Test summary:"
411 echo Results directory
: $resdir/$ds
412 kvm-recheck.sh
$resdir/$ds
This page took 0.060175 seconds and 6 git commands to generate.