| .. | .. |
|---|
| 1 | 1 | #!/bin/bash |
|---|
| 2 | +# SPDX-License-Identifier: GPL-2.0+ |
|---|
| 2 | 3 | # |
|---|
| 3 | 4 | # Run a series of tests under KVM. By default, this series is specified |
|---|
| 4 | 5 | # by the relevant CFLIST file, but can be overridden by the --configs |
|---|
| .. | .. |
|---|
| 6 | 7 | # |
|---|
| 7 | 8 | # Usage: kvm.sh [ options ] |
|---|
| 8 | 9 | # |
|---|
| 9 | | -# This program is free software; you can redistribute it and/or modify |
|---|
| 10 | | -# it under the terms of the GNU General Public License as published by |
|---|
| 11 | | -# the Free Software Foundation; either version 2 of the License, or |
|---|
| 12 | | -# (at your option) any later version. |
|---|
| 13 | | -# |
|---|
| 14 | | -# This program is distributed in the hope that it will be useful, |
|---|
| 15 | | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | | -# GNU General Public License for more details. |
|---|
| 18 | | -# |
|---|
| 19 | | -# You should have received a copy of the GNU General Public License |
|---|
| 20 | | -# along with this program; if not, you can access it online at |
|---|
| 21 | | -# http://www.gnu.org/licenses/gpl-2.0.html. |
|---|
| 22 | | -# |
|---|
| 23 | 10 | # Copyright (C) IBM Corporation, 2011 |
|---|
| 24 | 11 | # |
|---|
| 25 | | -# Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com> |
|---|
| 12 | +# Authors: Paul E. McKenney <paulmck@linux.ibm.com> |
|---|
| 26 | 13 | |
|---|
| 27 | 14 | scriptname=$0 |
|---|
| 28 | 15 | args="$*" |
|---|
| .. | .. |
|---|
| 37 | 24 | dryrun="" |
|---|
| 38 | 25 | KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM |
|---|
| 39 | 26 | PATH=${KVM}/bin:$PATH; export PATH |
|---|
| 27 | +. functions.sh |
|---|
| 28 | + |
|---|
| 29 | +TORTURE_ALLOTED_CPUS="`identify_qemu_vcpus`" |
|---|
| 40 | 30 | TORTURE_DEFCONFIG=defconfig |
|---|
| 41 | 31 | TORTURE_BOOT_IMAGE="" |
|---|
| 42 | 32 | TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD |
|---|
| 43 | 33 | TORTURE_KCONFIG_ARG="" |
|---|
| 34 | +TORTURE_KCONFIG_GDB_ARG="" |
|---|
| 35 | +TORTURE_BOOT_GDB_ARG="" |
|---|
| 36 | +TORTURE_QEMU_GDB_ARG="" |
|---|
| 37 | +TORTURE_KCONFIG_KASAN_ARG="" |
|---|
| 38 | +TORTURE_KCONFIG_KCSAN_ARG="" |
|---|
| 44 | 39 | TORTURE_KMAKE_ARG="" |
|---|
| 45 | 40 | TORTURE_QEMU_MEM=512 |
|---|
| 46 | 41 | TORTURE_SHUTDOWN_GRACE=180 |
|---|
| 47 | 42 | TORTURE_SUITE=rcu |
|---|
| 43 | +TORTURE_TRUST_MAKE="" |
|---|
| 48 | 44 | resdir="" |
|---|
| 49 | 45 | configs="" |
|---|
| 50 | 46 | cpus=0 |
|---|
| 51 | | -ds=`date +%Y.%m.%d-%H:%M:%S` |
|---|
| 47 | +ds=`date +%Y.%m.%d-%H.%M.%S` |
|---|
| 52 | 48 | jitter="-1" |
|---|
| 53 | | - |
|---|
| 54 | | -. functions.sh |
|---|
| 55 | 49 | |
|---|
| 56 | 50 | usage () { |
|---|
| 57 | 51 | echo "Usage: $scriptname optional arguments:" |
|---|
| 52 | + echo " --allcpus" |
|---|
| 58 | 53 | echo " --bootargs kernel-boot-arguments" |
|---|
| 59 | 54 | echo " --bootimage relative-path-to-kernel-boot-image" |
|---|
| 60 | 55 | echo " --buildonly" |
|---|
| .. | .. |
|---|
| 64 | 59 | echo " --defconfig string" |
|---|
| 65 | 60 | echo " --dryrun sched|script" |
|---|
| 66 | 61 | echo " --duration minutes" |
|---|
| 62 | + echo " --gdb" |
|---|
| 63 | + echo " --help" |
|---|
| 67 | 64 | echo " --interactive" |
|---|
| 68 | 65 | echo " --jitter N [ maxsleep (us) [ maxspin (us) ] ]" |
|---|
| 69 | 66 | echo " --kconfig Kconfig-options" |
|---|
| 70 | 67 | echo " --kmake-arg kernel-make-arguments" |
|---|
| 71 | 68 | echo " --mac nn:nn:nn:nn:nn:nn" |
|---|
| 72 | | - echo " --memory megabytes | nnnG" |
|---|
| 69 | + echo " --memory megabytes|nnnG" |
|---|
| 73 | 70 | echo " --no-initrd" |
|---|
| 74 | 71 | echo " --qemu-args qemu-arguments" |
|---|
| 75 | 72 | echo " --qemu-cmd qemu-system-..." |
|---|
| 76 | 73 | echo " --results absolute-pathname" |
|---|
| 77 | | - echo " --torture rcu" |
|---|
| 74 | + echo " --torture lock|rcu|rcuscale|refscale|scf" |
|---|
| 75 | + echo " --trust-make" |
|---|
| 78 | 76 | exit 1 |
|---|
| 79 | 77 | } |
|---|
| 80 | 78 | |
|---|
| 81 | 79 | while test $# -gt 0 |
|---|
| 82 | 80 | do |
|---|
| 83 | 81 | case "$1" in |
|---|
| 82 | + --allcpus) |
|---|
| 83 | + cpus=$TORTURE_ALLOTED_CPUS |
|---|
| 84 | + max_cpus=$TORTURE_ALLOTED_CPUS |
|---|
| 85 | + ;; |
|---|
| 84 | 86 | --bootargs|--bootarg) |
|---|
| 85 | 87 | checkarg --bootargs "(list of kernel boot arguments)" "$#" "$2" '.*' '^--' |
|---|
| 86 | 88 | TORTURE_BOOTARGS="$2" |
|---|
| .. | .. |
|---|
| 102 | 104 | --cpus) |
|---|
| 103 | 105 | checkarg --cpus "(number)" "$#" "$2" '^[0-9]*$' '^--' |
|---|
| 104 | 106 | cpus=$2 |
|---|
| 107 | + TORTURE_ALLOTED_CPUS="$2" |
|---|
| 108 | + max_cpus="`identify_qemu_vcpus`" |
|---|
| 109 | + if test "$TORTURE_ALLOTED_CPUS" -gt "$max_cpus" |
|---|
| 110 | + then |
|---|
| 111 | + TORTURE_ALLOTED_CPUS=$max_cpus |
|---|
| 112 | + fi |
|---|
| 105 | 113 | shift |
|---|
| 106 | 114 | ;; |
|---|
| 107 | 115 | --datestamp) |
|---|
| .. | .. |
|---|
| 124 | 132 | dur=$(($2*60)) |
|---|
| 125 | 133 | shift |
|---|
| 126 | 134 | ;; |
|---|
| 135 | + --gdb) |
|---|
| 136 | + TORTURE_KCONFIG_GDB_ARG="CONFIG_DEBUG_INFO=y"; export TORTURE_KCONFIG_GDB_ARG |
|---|
| 137 | + TORTURE_BOOT_GDB_ARG="nokaslr"; export TORTURE_BOOT_GDB_ARG |
|---|
| 138 | + TORTURE_QEMU_GDB_ARG="-s -S"; export TORTURE_QEMU_GDB_ARG |
|---|
| 139 | + ;; |
|---|
| 140 | + --help|-h) |
|---|
| 141 | + usage |
|---|
| 142 | + ;; |
|---|
| 127 | 143 | --interactive) |
|---|
| 128 | 144 | TORTURE_QEMU_INTERACTIVE=1; export TORTURE_QEMU_INTERACTIVE |
|---|
| 129 | 145 | ;; |
|---|
| .. | .. |
|---|
| 136 | 152 | checkarg --kconfig "(Kconfig options)" $# "$2" '^CONFIG_[A-Z0-9_]\+=\([ynm]\|[0-9]\+\)\( CONFIG_[A-Z0-9_]\+=\([ynm]\|[0-9]\+\)\)*$' '^error$' |
|---|
| 137 | 153 | TORTURE_KCONFIG_ARG="$2" |
|---|
| 138 | 154 | shift |
|---|
| 155 | + ;; |
|---|
| 156 | + --kasan) |
|---|
| 157 | + TORTURE_KCONFIG_KASAN_ARG="CONFIG_DEBUG_INFO=y CONFIG_KASAN=y"; export TORTURE_KCONFIG_KASAN_ARG |
|---|
| 158 | + ;; |
|---|
| 159 | + --kcsan) |
|---|
| 160 | + TORTURE_KCONFIG_KCSAN_ARG="CONFIG_DEBUG_INFO=y CONFIG_KCSAN=y CONFIG_KCSAN_ASSUME_PLAIN_WRITES_ATOMIC=n CONFIG_KCSAN_REPORT_VALUE_CHANGE_ONLY=n CONFIG_KCSAN_REPORT_ONCE_IN_MS=100000 CONFIG_KCSAN_VERBOSE=y CONFIG_KCSAN_INTERRUPT_WATCHER=y"; export TORTURE_KCONFIG_KCSAN_ARG |
|---|
| 139 | 161 | ;; |
|---|
| 140 | 162 | --kmake-arg) |
|---|
| 141 | 163 | checkarg --kmake-arg "(kernel make arguments)" $# "$2" '.*' '^error$' |
|---|
| .. | .. |
|---|
| 176 | 198 | shift |
|---|
| 177 | 199 | ;; |
|---|
| 178 | 200 | --torture) |
|---|
| 179 | | - checkarg --torture "(suite name)" "$#" "$2" '^\(lock\|rcu\|rcuperf\)$' '^--' |
|---|
| 201 | + checkarg --torture "(suite name)" "$#" "$2" '^\(lock\|rcu\|rcuscale\|refscale\|scf\)$' '^--' |
|---|
| 180 | 202 | TORTURE_SUITE=$2 |
|---|
| 181 | 203 | shift |
|---|
| 182 | | - if test "$TORTURE_SUITE" = rcuperf |
|---|
| 204 | + if test "$TORTURE_SUITE" = rcuscale || test "$TORTURE_SUITE" = refscale |
|---|
| 183 | 205 | then |
|---|
| 184 | | - # If you really want jitter for rcuperf, specify |
|---|
| 185 | | - # it after specifying rcuperf. (But why?) |
|---|
| 206 | + # If you really want jitter for refscale or |
|---|
| 207 | + # rcuscale, specify it after specifying the rcuscale |
|---|
| 208 | + # or the refscale. (But why jitter in these cases?) |
|---|
| 186 | 209 | jitter=0 |
|---|
| 187 | 210 | fi |
|---|
| 211 | + ;; |
|---|
| 212 | + --trust-make) |
|---|
| 213 | + TORTURE_TRUST_MAKE="y" |
|---|
| 188 | 214 | ;; |
|---|
| 189 | 215 | *) |
|---|
| 190 | 216 | echo Unknown argument $1 |
|---|
| .. | .. |
|---|
| 194 | 220 | shift |
|---|
| 195 | 221 | done |
|---|
| 196 | 222 | |
|---|
| 223 | +if test -z "$TORTURE_INITRD" || tools/testing/selftests/rcutorture/bin/mkinitrd.sh |
|---|
| 224 | +then |
|---|
| 225 | + : |
|---|
| 226 | +else |
|---|
| 227 | + echo No initrd and unable to create one, aborting test >&2 |
|---|
| 228 | + exit 1 |
|---|
| 229 | +fi |
|---|
| 230 | + |
|---|
| 197 | 231 | CONFIGFRAG=${KVM}/configs/${TORTURE_SUITE}; export CONFIGFRAG |
|---|
| 198 | 232 | |
|---|
| 233 | +defaultconfigs="`tr '\012' ' ' < $CONFIGFRAG/CFLIST`" |
|---|
| 199 | 234 | if test -z "$configs" |
|---|
| 200 | 235 | then |
|---|
| 201 | | - configs="`cat $CONFIGFRAG/CFLIST`" |
|---|
| 236 | + configs=$defaultconfigs |
|---|
| 202 | 237 | fi |
|---|
| 203 | 238 | |
|---|
| 204 | 239 | if test -z "$resdir" |
|---|
| .. | .. |
|---|
| 207 | 242 | fi |
|---|
| 208 | 243 | |
|---|
| 209 | 244 | # Create a file of test-name/#cpus pairs, sorted by decreasing #cpus. |
|---|
| 210 | | -touch $T/cfgcpu |
|---|
| 245 | +configs_derep= |
|---|
| 211 | 246 | for CF in $configs |
|---|
| 212 | 247 | do |
|---|
| 213 | 248 | case $CF in |
|---|
| .. | .. |
|---|
| 220 | 255 | CF1=$CF |
|---|
| 221 | 256 | ;; |
|---|
| 222 | 257 | esac |
|---|
| 258 | + for ((cur_rep=0;cur_rep<$config_reps;cur_rep++)) |
|---|
| 259 | + do |
|---|
| 260 | + configs_derep="$configs_derep $CF1" |
|---|
| 261 | + done |
|---|
| 262 | +done |
|---|
| 263 | +touch $T/cfgcpu |
|---|
| 264 | +configs_derep="`echo $configs_derep | sed -e "s/\<CFLIST\>/$defaultconfigs/g"`" |
|---|
| 265 | +if test -n "$TORTURE_KCONFIG_GDB_ARG" |
|---|
| 266 | +then |
|---|
| 267 | + if test "`echo $configs_derep | wc -w`" -gt 1 |
|---|
| 268 | + then |
|---|
| 269 | + echo "The --config list is: $configs_derep." |
|---|
| 270 | + echo "Only one --config permitted with --gdb, terminating." |
|---|
| 271 | + exit 1 |
|---|
| 272 | + fi |
|---|
| 273 | +fi |
|---|
| 274 | +for CF1 in $configs_derep |
|---|
| 275 | +do |
|---|
| 223 | 276 | if test -f "$CONFIGFRAG/$CF1" |
|---|
| 224 | 277 | then |
|---|
| 225 | 278 | cpu_count=`configNR_CPUS.sh $CONFIGFRAG/$CF1` |
|---|
| 226 | 279 | cpu_count=`configfrag_boot_cpus "$TORTURE_BOOTARGS" "$CONFIGFRAG/$CF1" "$cpu_count"` |
|---|
| 227 | 280 | cpu_count=`configfrag_boot_maxcpus "$TORTURE_BOOTARGS" "$CONFIGFRAG/$CF1" "$cpu_count"` |
|---|
| 228 | | - for ((cur_rep=0;cur_rep<$config_reps;cur_rep++)) |
|---|
| 229 | | - do |
|---|
| 230 | | - echo $CF1 $cpu_count >> $T/cfgcpu |
|---|
| 231 | | - done |
|---|
| 281 | + echo $CF1 $cpu_count >> $T/cfgcpu |
|---|
| 232 | 282 | else |
|---|
| 233 | 283 | echo "The --configs file $CF1 does not exist, terminating." |
|---|
| 234 | 284 | exit 1 |
|---|
| .. | .. |
|---|
| 290 | 340 | CONFIGFRAG="$CONFIGFRAG"; export CONFIGFRAG |
|---|
| 291 | 341 | KVM="$KVM"; export KVM |
|---|
| 292 | 342 | PATH="$PATH"; export PATH |
|---|
| 343 | +TORTURE_ALLOTED_CPUS="$TORTURE_ALLOTED_CPUS"; export TORTURE_ALLOTED_CPUS |
|---|
| 293 | 344 | TORTURE_BOOT_IMAGE="$TORTURE_BOOT_IMAGE"; export TORTURE_BOOT_IMAGE |
|---|
| 294 | 345 | TORTURE_BUILDONLY="$TORTURE_BUILDONLY"; export TORTURE_BUILDONLY |
|---|
| 295 | 346 | TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG |
|---|
| 296 | 347 | TORTURE_INITRD="$TORTURE_INITRD"; export TORTURE_INITRD |
|---|
| 297 | 348 | TORTURE_KCONFIG_ARG="$TORTURE_KCONFIG_ARG"; export TORTURE_KCONFIG_ARG |
|---|
| 349 | +TORTURE_KCONFIG_GDB_ARG="$TORTURE_KCONFIG_GDB_ARG"; export TORTURE_KCONFIG_GDB_ARG |
|---|
| 350 | +TORTURE_BOOT_GDB_ARG="$TORTURE_BOOT_GDB_ARG"; export TORTURE_BOOT_GDB_ARG |
|---|
| 351 | +TORTURE_QEMU_GDB_ARG="$TORTURE_QEMU_GDB_ARG"; export TORTURE_QEMU_GDB_ARG |
|---|
| 352 | +TORTURE_KCONFIG_KASAN_ARG="$TORTURE_KCONFIG_KASAN_ARG"; export TORTURE_KCONFIG_KASAN_ARG |
|---|
| 353 | +TORTURE_KCONFIG_KCSAN_ARG="$TORTURE_KCONFIG_KCSAN_ARG"; export TORTURE_KCONFIG_KCSAN_ARG |
|---|
| 298 | 354 | TORTURE_KMAKE_ARG="$TORTURE_KMAKE_ARG"; export TORTURE_KMAKE_ARG |
|---|
| 299 | 355 | TORTURE_QEMU_CMD="$TORTURE_QEMU_CMD"; export TORTURE_QEMU_CMD |
|---|
| 300 | 356 | TORTURE_QEMU_INTERACTIVE="$TORTURE_QEMU_INTERACTIVE"; export TORTURE_QEMU_INTERACTIVE |
|---|
| .. | .. |
|---|
| 302 | 358 | TORTURE_QEMU_MEM="$TORTURE_QEMU_MEM"; export TORTURE_QEMU_MEM |
|---|
| 303 | 359 | TORTURE_SHUTDOWN_GRACE="$TORTURE_SHUTDOWN_GRACE"; export TORTURE_SHUTDOWN_GRACE |
|---|
| 304 | 360 | TORTURE_SUITE="$TORTURE_SUITE"; export TORTURE_SUITE |
|---|
| 361 | +TORTURE_TRUST_MAKE="$TORTURE_TRUST_MAKE"; export TORTURE_TRUST_MAKE |
|---|
| 305 | 362 | if ! test -e $resdir |
|---|
| 306 | 363 | then |
|---|
| 307 | 364 | mkdir -p "$resdir" || : |
|---|
| 308 | 365 | fi |
|---|
| 309 | 366 | mkdir $resdir/$ds |
|---|
| 367 | +TORTURE_RESDIR="$resdir/$ds"; export TORTURE_RESDIR |
|---|
| 368 | +TORTURE_STOPFILE="$resdir/$ds/STOP"; export TORTURE_STOPFILE |
|---|
| 310 | 369 | echo Results directory: $resdir/$ds |
|---|
| 311 | 370 | echo $scriptname $args |
|---|
| 312 | 371 | touch $resdir/$ds/log |
|---|
| .. | .. |
|---|
| 347 | 406 | print "needqemurun=" |
|---|
| 348 | 407 | jn=1 |
|---|
| 349 | 408 | for (j = first; j < pastlast; j++) { |
|---|
| 350 | | - builddir=KVM "/b1" |
|---|
| 409 | + builddir=KVM "/b" j - first + 1 |
|---|
| 351 | 410 | cpusr[jn] = cpus[j]; |
|---|
| 352 | 411 | if (cfrep[cf[j]] == "") { |
|---|
| 353 | 412 | cfr[jn] = cf[j]; |
|---|
| .. | .. |
|---|
| 363 | 422 | print "echo ", cfr[jn], cpusr[jn] ovf ": Starting build. `date` | tee -a " rd "log"; |
|---|
| 364 | 423 | print "rm -f " builddir ".*"; |
|---|
| 365 | 424 | print "touch " builddir ".wait"; |
|---|
| 366 | | - print "mkdir " builddir " > /dev/null 2>&1 || :"; |
|---|
| 367 | 425 | print "mkdir " rd cfr[jn] " || :"; |
|---|
| 368 | 426 | print "kvm-test-1-run.sh " CONFIGDIR cf[j], builddir, rd cfr[jn], dur " \"" TORTURE_QEMU_ARG "\" \"" TORTURE_BOOTARGS "\" > " rd cfr[jn] "/kvm-test-1-run.sh.out 2>&1 &" |
|---|
| 369 | 427 | print "echo ", cfr[jn], cpusr[jn] ovf ": Waiting for build to complete. `date` | tee -a " rd "log"; |
|---|
| .. | .. |
|---|
| 449 | 507 | echo |
|---|
| 450 | 508 | echo " --- `date` Test summary:" |
|---|
| 451 | 509 | echo Results directory: $resdir/$ds |
|---|
| 510 | +kcsan-collapse.sh $resdir/$ds |
|---|
| 452 | 511 | kvm-recheck.sh $resdir/$ds |
|---|
| 453 | 512 | ___EOF___ |
|---|
| 454 | 513 | |
|---|
| .. | .. |
|---|
| 469 | 528 | fi |
|---|
| 470 | 529 | |
|---|
| 471 | 530 | # 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 |
|---|
| 531 | +# Function-graph tracing: ftrace=function_graph ftrace_graph_filter=sched_setaffinity,migration_cpu_stop |
|---|
| 532 | +# Also --kconfig "CONFIG_FUNCTION_TRACER=y CONFIG_FUNCTION_GRAPH_TRACER=y" |
|---|
| 533 | +# Control buffer size: --bootargs trace_buf_size=3k |
|---|
| 534 | +# Get trace-buffer dumps on all oopses: --bootargs ftrace_dump_on_oops |
|---|
| 535 | +# Ditto, but dump only the oopsing CPU: --bootargs ftrace_dump_on_oops=orig_cpu |
|---|
| 536 | +# Heavy-handed way to also dump on warnings: --bootargs panic_on_warn |
|---|