blob: f74f00628afed5d1816df428cd80f60442429bbd [file] [log] [blame]
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -07001#!/bin/bash
2#
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.
6#
7# Edit the definitions below to set the locations of the various directories,
8# as well as the test duration.
9#
10# Usage: sh kvm.sh [ options ]
11#
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.
16#
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.
21#
22# You should have received a copy of the GNU General Public License
Paul E. McKenney0e342a82013-12-03 09:54:18 -080023# along with this program; if not, you can access it online at
24# http://www.gnu.org/licenses/gpl-2.0.html.
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070025#
26# Copyright (C) IBM Corporation, 2011
27#
28# Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
29
30scriptname=$0
Paul E. McKenney330a76f2013-09-30 14:49:43 -070031args="$*"
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070032
Paul E. McKenney43e38ab2014-01-15 15:48:41 -080033T=/tmp/kvm.sh.$$
34trap 'rm -rf $T' 0
35mkdir $T
36
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070037dur=30
Paul E. McKenney73931b52013-10-15 10:42:25 -070038KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
Paul E. McKenney32caccb2013-10-28 08:57:29 -070039PATH=${KVM}/bin:$PATH; export PATH
Paul E. McKenney73931b52013-10-15 10:42:25 -070040builddir="${KVM}/b1"
41RCU_INITRD="$KVM/initrd"; export RCU_INITRD
Paul E. McKenney74878fb2013-10-15 11:51:23 -070042RCU_KMAKE_ARG=""; export RCU_KMAKE_ARG
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070043resdir=""
Paul E. McKenney4275be82013-09-29 11:13:46 -070044configs=""
Paul E. McKenney43e38ab2014-01-15 15:48:41 -080045cpus=0
Paul E. McKenney847bfd22013-09-28 18:44:11 -070046ds=`date +%Y.%m.%d-%H:%M:%S`
Paul E. McKenneybb918532013-09-28 20:37:45 -070047kversion=""
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070048
Paul E. McKenney32caccb2013-10-28 08:57:29 -070049. functions.sh
50
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070051usage () {
52 echo "Usage: $scriptname optional arguments:"
Paul E. McKenney7dca9272013-10-14 08:19:39 -070053 echo " --bootargs kernel-boot-arguments"
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070054 echo " --builddir absolute-pathname"
Paul E. McKenney11274812013-10-10 14:52:07 -070055 echo " --buildonly"
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070056 echo " --configs \"config-file list\""
Paul E. McKenney43e38ab2014-01-15 15:48:41 -080057 echo " --cpus N"
Paul E. McKenney847bfd22013-09-28 18:44:11 -070058 echo " --datestamp string"
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070059 echo " --duration minutes"
Paul E. McKenney315c5402013-10-04 13:15:55 -070060 echo " --interactive"
Paul E. McKenney74878fb2013-10-15 11:51:23 -070061 echo " --kmake-arg kernel-make-arguments"
Paul E. McKenneybb918532013-09-28 20:37:45 -070062 echo " --kversion vN.NN"
Paul E. McKenney315c5402013-10-04 13:15:55 -070063 echo " --mac nn:nn:nn:nn:nn:nn"
Paul E. McKenney73931b52013-10-15 10:42:25 -070064 echo " --no-initrd"
Paul E. McKenneye9ce6402013-10-15 09:22:48 -070065 echo " --qemu-args qemu-system-..."
Paul E. McKenney4f8a0312013-09-30 17:17:57 -070066 echo " --qemu-cmd qemu-system-..."
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070067 echo " --results absolute-pathname"
68 echo " --relbuilddir relative-pathname"
69 exit 1
70}
71
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070072while test $# -gt 0
73do
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070074 case "$1" in
Paul E. McKenney7dca9272013-10-14 08:19:39 -070075 --bootargs)
76 checkarg --bootargs "(list of kernel boot arguments)" "$#" "$2" '.*' '^--'
77 RCU_BOOTARGS="$2"
78 shift
79 ;;
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070080 --builddir)
Paul E. McKenneye9ce6402013-10-15 09:22:48 -070081 checkarg --builddir "(absolute pathname)" "$#" "$2" '^/' '^error'
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070082 builddir=$2
83 gotbuilddir=1
84 shift
85 ;;
Paul E. McKenney11274812013-10-10 14:52:07 -070086 --buildonly)
87 RCU_BUILDONLY=1; export RCU_BUILDONLY
88 ;;
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070089 --configs)
90 checkarg --configs "(list of config files)" "$#" "$2" '^[^/]*$' '^--'
91 configs="$2"
92 shift
93 ;;
Paul E. McKenney43e38ab2014-01-15 15:48:41 -080094 --cpus)
95 checkarg --cpus "(number)" "$#" "$2" '^[0-9]*$' '^--'
96 cpus=$2
97 shift
98 ;;
Paul E. McKenney847bfd22013-09-28 18:44:11 -070099 --datestamp)
100 checkarg --datestamp "(relative pathname)" "$#" "$2" '^[^/]*$' '^--'
101 ds=$2
102 shift
103 ;;
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700104 --duration)
Paul E. McKenneye9ce6402013-10-15 09:22:48 -0700105 checkarg --duration "(minutes)" $# "$2" '^[0-9]*$' '^error'
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700106 dur=$2
107 shift
108 ;;
Paul E. McKenney315c5402013-10-04 13:15:55 -0700109 --interactive)
110 RCU_QEMU_INTERACTIVE=1; export RCU_QEMU_INTERACTIVE
111 ;;
Paul E. McKenney74878fb2013-10-15 11:51:23 -0700112 --kmake-arg)
113 checkarg --kmake-arg "(kernel make arguments)" $# "$2" '.*' '^error$'
114 RCU_KMAKE_ARG="$2"; export RCU_KMAKE_ARG
115 shift
116 ;;
Paul E. McKenneybb918532013-09-28 20:37:45 -0700117 --kversion)
Paul E. McKenneye9ce6402013-10-15 09:22:48 -0700118 checkarg --kversion "(kernel version)" $# "$2" '^v[0-9.]*$' '^error'
Paul E. McKenneybb918532013-09-28 20:37:45 -0700119 kversion=$2
120 shift
121 ;;
Paul E. McKenney315c5402013-10-04 13:15:55 -0700122 --mac)
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
125 shift
126 ;;
Paul E. McKenney73931b52013-10-15 10:42:25 -0700127 --no-initrd)
128 RCU_INITRD=""; export RCU_INITRD
129 ;;
Paul E. McKenneye9ce6402013-10-15 09:22:48 -0700130 --qemu-args)
131 checkarg --qemu-args "-qemu args" $# "$2" '^-' '^error'
132 RCU_QEMU_ARG="$2"
133 shift
134 ;;
Paul E. McKenney4f8a0312013-09-30 17:17:57 -0700135 --qemu-cmd)
136 checkarg --qemu-cmd "(qemu-system-...)" $# "$2" 'qemu-system-' '^--'
137 RCU_QEMU_CMD="$2"; export RCU_QEMU_CMD
138 shift
139 ;;
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700140 --relbuilddir)
141 checkarg --relbuilddir "(relative pathname)" "$#" "$2" '^[^/]*$' '^--'
142 relbuilddir=$2
143 gotrelbuilddir=1
144 builddir=${KVM}/${relbuilddir}
145 shift
146 ;;
147 --results)
Paul E. McKenneye9ce6402013-10-15 09:22:48 -0700148 checkarg --results "(absolute pathname)" "$#" "$2" '^/' '^error'
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700149 resdir=$2
150 shift
151 ;;
152 *)
Paul E. McKenney2bcdf4e2013-10-01 10:14:09 -0700153 echo Unknown argument $1
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700154 usage
155 ;;
156 esac
157 shift
158done
159
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700160CONFIGFRAG=${KVM}/configs; export CONFIGFRAG
Paul E. McKenney4275be82013-09-29 11:13:46 -0700161KVPATH=${CONFIGFRAG}/$kversion; export KVPATH
162
163if test -z "$configs"
164then
165 configs="`cat $CONFIGFRAG/$kversion/CFLIST`"
166fi
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700167
168if test -z "$resdir"
169then
170 resdir=$KVM/res
Paul E. McKenney330a76f2013-09-30 14:49:43 -0700171 if ! test -e $resdir
172 then
173 mkdir $resdir || :
174 fi
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700175else
Paul E. McKenney330a76f2013-09-30 14:49:43 -0700176 if ! test -e $resdir
177 then
178 mkdir -p "$resdir" || :
179 fi
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700180fi
Paul E. McKenney847bfd22013-09-28 18:44:11 -0700181mkdir $resdir/$ds
Paul E. McKenney43e38ab2014-01-15 15:48:41 -0800182echo Results directory: $resdir/$ds
Paul E. McKenney330a76f2013-09-30 14:49:43 -0700183touch $resdir/$ds/log
Paul E. McKenney1219c862013-12-19 10:52:55 -0800184echo $scriptname $args
Paul E. McKenney330a76f2013-09-30 14:49:43 -0700185echo $scriptname $args >> $resdir/$ds/log
Paul E. McKenney847bfd22013-09-28 18:44:11 -0700186
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700187pwd > $resdir/$ds/testid.txt
188if test -d .git
189then
190 git status >> $resdir/$ds/testid.txt
191 git rev-parse HEAD >> $resdir/$ds/testid.txt
192fi
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700193
Paul E. McKenney43e38ab2014-01-15 15:48:41 -0800194touch $T/cfgcpu
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700195for CF in $configs
196do
Paul E. McKenney43e38ab2014-01-15 15:48:41 -0800197 if test -f "$CONFIGFRAG/$kversion/$CF"
Paul E. McKenneyf43f8f72013-10-19 06:28:21 -0700198 then
Paul E. McKenney43e38ab2014-01-15 15:48:41 -0800199 echo $CF `configNR_CPUS.sh $CONFIGFRAG/$kversion/$CF` >> $T/cfgcpu
200 else
201 echo "The --configs file $CF does not exist, terminating."
202 exit 1
Paul E. McKenneyf43f8f72013-10-19 06:28:21 -0700203 fi
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700204done
Paul E. McKenney43e38ab2014-01-15 15:48:41 -0800205sort -k2nr $T/cfgcpu > $T/cfgcpu.sort
206
207awk < $T/cfgcpu.sort \
208 -v CONFIGDIR="$CONFIGFRAG/$kversion/" \
209 -v KVM="$KVM" \
210 -v ncpus=$cpus \
211 -v rd=$resdir/$ds/ \
212 -v dur=$dur \
213 -v RCU_QEMU_ARG=$RCU_QEMU_ARG \
214 -v RCU_BOOTARGS=$RCU_BOOTARGS \
215'BEGIN {
216 i = 0;
217}
218
219{
220 cf[i] = $1;
221 cpus[i] = $2;
222 i++;
223}
224
225function dump(first, pastlast)
226{
227 print "echo ----start batch----"
228 jn=1
229 for (j = first; j < pastlast; j++) {
230 builddir=KVM "/b" jn
231 print "echo ", cf[j], cpus[j] ": Starting build."
232 print "rm -f " builddir ".*"
233 print "touch " builddir ".wait"
234 print "mkdir " builddir " || :"
235 if (cfrep[cf[j]] == "") {
236 cfr[j] = cf[j];
237 cfrep[cf[j]] = 1;
238 } else {
239 cfrep[cf[j]]++;
240 cfr[j] = cf[j] "." cfrep[cf[j]];
241 }
242 print "mkdir " rd cfr[j] " || :";
243 print "kvm-test-1-rcu.sh " CONFIGDIR cf[j], builddir, rd cfr[j], dur " \"" RCU_QEMU_ARG "\" \"" RCU_BOOTARGS "\" > " builddir ".out 2>&1 &"
244 print "echo ", cf[j], cpus[j] ": Waiting for build to complete."
245 print "while test -f " builddir ".wait"
246 print "do"
247 print "\tsleep 1"
248 print "done"
249 print "echo ", cf[j], cpus[j] ": Build complete."
250 jn++;
251 }
252 k = first
253 for (j = 1; j < jn; j++) {
254 builddir=KVM "/b" j
255 print "rm -f " builddir ".ready"
256 print "echo ----", cf[k], cpus[k] ": Starting kernel"
257 k++;
258 }
259 print "wait"
260 print "echo ---- All kernel runs complete"
261 k = first
262 for (j = 1; j < jn; j++) {
263 builddir=KVM "/b" j
264 print "echo ----", cf[k], cpus[k] ": Build/run results:"
265 print "cat " builddir ".out"
266 k++;
267 }
268}
269
270END {
271 njobs = i;
272 nc = ncpus;
273 first = 0;
274 for (i = 0; i < njobs; i++) {
275 if (ncpus == 0) {
276 dump(i, i + 1);
277 first = i;
278 } else if (nc < cpus[i] && i != 0) {
279 dump(first, i);
280 first = i;
281 nc = ncpus;
282 }
283 nc -= cpus[i];
284 }
285 if (ncpus != 0)
286 dump(first, i);
287}' > $T/script
288
289sh $T/script
290
Paul E. McKenney782ab4c2013-10-15 12:11:24 -0700291# 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
Paul E. McKenneye1362652013-10-15 12:22:32 -0700292
293echo " --- `date` Test summary:"
294kvm-recheck.sh $resdir/$ds