aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/rcutorture/bin/kvm.sh
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2014-01-15 18:48:41 -0500
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2014-02-18 15:26:20 -0500
commit43e38ab3d518352932951bacb99705a3bee9477c (patch)
treea5d7ac3aa58a3e189a8f7c3b4d185d32457389e7 /tools/testing/selftests/rcutorture/bin/kvm.sh
parent061862386e8062046cc980e1be1fc4779159411e (diff)
rcutorture: Enable concurrent rcutorture runs
The rcutorture tests run by default range from using one CPU to using sixteen of them. Therefore, rcutorture testing could be sped up significantly simply by running the kernels in parallel. Building them in parallel is not all that helpful: "make -j" is usually a better bet. So this commit takes a new "--cpus" argument that specifies how many CPUs rcutorture is permitted to use for its parallel runs. The default of zero does sequential runs as before. The bin-packing is minimal, and will be grossly suboptimal for some configurations. However, powers of two work reasonably well. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Diffstat (limited to 'tools/testing/selftests/rcutorture/bin/kvm.sh')
-rw-r--r--tools/testing/selftests/rcutorture/bin/kvm.sh125
1 files changed, 104 insertions, 21 deletions
diff --git a/tools/testing/selftests/rcutorture/bin/kvm.sh b/tools/testing/selftests/rcutorture/bin/kvm.sh
index f2113493bbfc..f74f00628afe 100644
--- a/tools/testing/selftests/rcutorture/bin/kvm.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm.sh
@@ -30,6 +30,10 @@
30scriptname=$0 30scriptname=$0
31args="$*" 31args="$*"
32 32
33T=/tmp/kvm.sh.$$
34trap 'rm -rf $T' 0
35mkdir $T
36
33dur=30 37dur=30
34KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM 38KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
35PATH=${KVM}/bin:$PATH; export PATH 39PATH=${KVM}/bin:$PATH; export PATH
@@ -38,6 +42,7 @@ RCU_INITRD="$KVM/initrd"; export RCU_INITRD
38RCU_KMAKE_ARG=""; export RCU_KMAKE_ARG 42RCU_KMAKE_ARG=""; export RCU_KMAKE_ARG
39resdir="" 43resdir=""
40configs="" 44configs=""
45cpus=0
41ds=`date +%Y.%m.%d-%H:%M:%S` 46ds=`date +%Y.%m.%d-%H:%M:%S`
42kversion="" 47kversion=""
43 48
@@ -49,6 +54,7 @@ usage () {
49 echo " --builddir absolute-pathname" 54 echo " --builddir absolute-pathname"
50 echo " --buildonly" 55 echo " --buildonly"
51 echo " --configs \"config-file list\"" 56 echo " --configs \"config-file list\""
57 echo " --cpus N"
52 echo " --datestamp string" 58 echo " --datestamp string"
53 echo " --duration minutes" 59 echo " --duration minutes"
54 echo " --interactive" 60 echo " --interactive"
@@ -85,6 +91,11 @@ do
85 configs="$2" 91 configs="$2"
86 shift 92 shift
87 ;; 93 ;;
94 --cpus)
95 checkarg --cpus "(number)" "$#" "$2" '^[0-9]*$' '^--'
96 cpus=$2
97 shift
98 ;;
88 --datestamp) 99 --datestamp)
89 checkarg --datestamp "(relative pathname)" "$#" "$2" '^[^/]*$' '^--' 100 checkarg --datestamp "(relative pathname)" "$#" "$2" '^[^/]*$' '^--'
90 ds=$2 101 ds=$2
@@ -168,6 +179,7 @@ else
168 fi 179 fi
169fi 180fi
170mkdir $resdir/$ds 181mkdir $resdir/$ds
182echo Results directory: $resdir/$ds
171touch $resdir/$ds/log 183touch $resdir/$ds/log
172echo $scriptname $args 184echo $scriptname $args
173echo $scriptname $args >> $resdir/$ds/log 185echo $scriptname $args >> $resdir/$ds/log
@@ -178,33 +190,104 @@ then
178 git status >> $resdir/$ds/testid.txt 190 git status >> $resdir/$ds/testid.txt
179 git rev-parse HEAD >> $resdir/$ds/testid.txt 191 git rev-parse HEAD >> $resdir/$ds/testid.txt
180fi 192fi
181builddir=$KVM/b1
182if ! test -e $builddir
183then
184 mkdir $builddir || :
185fi
186 193
194touch $T/cfgcpu
187for CF in $configs 195for CF in $configs
188do 196do
189 # Running TREE01 multiple times creates TREE01, TREE01.2, TREE01.3, ... 197 if test -f "$CONFIGFRAG/$kversion/$CF"
190 rd=$resdir/$ds/$CF
191 if test -d "${rd}"
192 then 198 then
193 n="`ls -d "${rd}"* | grep '\.[0-9]\+$' | 199 echo $CF `configNR_CPUS.sh $CONFIGFRAG/$kversion/$CF` >> $T/cfgcpu
194 sed -e 's/^.*\.\([0-9]\+\)/\1/' | 200 else
195 sort -k1n | tail -1`" 201 echo "The --configs file $CF does not exist, terminating."
196 if test -z "$n" 202 exit 1
197 then
198 rd="${rd}.2"
199 else
200 n="`expr $n + 1`"
201 rd="${rd}.${n}"
202 fi
203 fi 203 fi
204 mkdir "${rd}"
205 echo Results directory: $rd
206 kvm-test-1-rcu.sh $CONFIGFRAG/$kversion/$CF $builddir $rd $dur "$RCU_QEMU_ARG" "$RCU_BOOTARGS"
207done 204done
205sort -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
208# 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 291# 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
209 292
210echo " --- `date` Test summary:" 293echo " --- `date` Test summary:"