2 # SPDX-License-Identifier: GPL-2.0+
4 # Carry out a kvm-based run for the specified batch of scenarios, which
5 # might have been built by --build-only kvm.sh run.
7 # Usage: kvm-test-1-run-batch.sh SCENARIO [ SCENARIO ... ]
9 # Each SCENARIO is the name of a directory in the current directory
10 # containing a ready-to-run qemu-cmd file.
12 # Copyright (C) 2021 Facebook, Inc.
14 # Authors: Paul E. McKenney <paulmck@kernel.org>
16 T=${TMPDIR-/tmp}/kvm-test-1-run-batch.sh.$$
20 echo ---- Running batch $*
25 if ! echo $i | grep -q '^[^/.a-z]\+\(\.[0-9]\+\)\?$'
27 echo Bad scenario name: \"$i\" 1>&2
32 echo Scenario name not a directory: \"$i\" 1>&2
35 if ! test -f "$i/qemu-cmd"
37 echo Scenario lacks a command file: \"$i/qemu-cmd\" 1>&2
42 runfiles="$runfiles $i/build.run"
45 # Extract settings from the qemu-cmd file.
46 grep '^#' $1/qemu-cmd | sed -e 's/^# //' > $T/qemu-cmd-settings
47 . $T/qemu-cmd-settings
49 # Start up jitter, start each scenario, wait, end jitter.
50 echo ---- System running test: `uname -a`
51 echo ---- Starting kernels. `date` | tee -a log
53 kvm-assign-cpus.sh /sys/devices/system/node > $T/cpuarray.awk
56 echo ---- System running test: `uname -a` > $i/kvm-test-1-run-qemu.sh.out
57 echo > $i/kvm-test-1-run-qemu.sh.out
58 export TORTURE_AFFINITY=
59 kvm-get-cpus-script.sh $T/cpuarray.awk $T/cpubatches.awk $T/cpustate
60 cat << ' ___EOF___' >> $T/cpubatches.awk
64 print "echo No CPU-affinity information, so no taskset command.";
65 } else if (cpu_count !~ /^[0-9][0-9]*$/) {
66 print "echo " scenario ": Bogus number of CPUs (old qemu-cmd?), so no taskset command.";
68 affinitylist = nextcpus(cpu_count);
69 if (!(affinitylist ~ /^[0-9,-][0-9,-]*$/))
70 print "echo " scenario ": Bogus CPU-affinity information, so no taskset command.";
71 else if (!dumpcpustate())
72 print "echo " scenario ": Could not dump state, so no taskset command.";
74 print "export TORTURE_AFFINITY=" affinitylist;
78 cpu_count="`grep '# TORTURE_CPU_COUNT=' $i/qemu-cmd | sed -e 's/^.*=//'`"
79 affinity_export="`awk -f $T/cpubatches.awk -v cpu_count="$cpu_count" -v scenario=$i < /dev/null`"
81 kvm-test-1-run-qemu.sh $i >> $i/kvm-test-1-run-qemu.sh.out 2>&1 &
85 while ls $i > /dev/null 2>&1
90 echo ---- All kernel runs complete. `date` | tee -a log