torture.sh 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0+
  3. #
  4. # Run a series of torture tests, intended for overnight or
  5. # longer timeframes, and also for large systems.
  6. #
  7. # Usage: torture.sh [ options ]
  8. #
  9. # Copyright (C) 2020 Facebook, Inc.
  10. #
  11. # Authors: Paul E. McKenney <paulmck@kernel.org>
  12. scriptname=$0
  13. args="$*"
  14. RCUTORTURE="`pwd`/tools/testing/selftests/rcutorture"; export RCUTORTURE
  15. PATH=${RCUTORTURE}/bin:$PATH; export PATH
  16. . functions.sh
  17. TORTURE_ALLOTED_CPUS="`identify_qemu_vcpus`"
  18. MAKE_ALLOTED_CPUS=$((TORTURE_ALLOTED_CPUS*2))
  19. SCALE_ALLOTED_CPUS=$((TORTURE_ALLOTED_CPUS/2))
  20. if test "$SCALE_ALLOTED_CPUS" -lt 1
  21. then
  22. SCALE_ALLOTED_CPUS=1
  23. fi
  24. VERBOSE_BATCH_CPUS=$((TORTURE_ALLOTED_CPUS/16))
  25. if test "$VERBOSE_BATCH_CPUS" -lt 2
  26. then
  27. VERBOSE_BATCH_CPUS=0
  28. fi
  29. # Machine architecture? ("uname -p" is said to be less portable.)1
  30. thisarch="`uname -m`"
  31. if test "${thisarch}" = aarch64
  32. then
  33. ifnotaarch64=no
  34. else
  35. ifnotaarch64=yes
  36. fi
  37. # Configurations/scenarios.
  38. configs_rcutorture=
  39. configs_locktorture=
  40. configs_scftorture=
  41. kcsan_kmake_args=
  42. # Default compression, duration, and apportionment.
  43. compress_concurrency="`identify_qemu_vcpus`"
  44. duration_base=10
  45. duration_rcutorture_frac=7
  46. duration_locktorture_frac=1
  47. duration_scftorture_frac=2
  48. # "yes" or "no" parameters
  49. do_allmodconfig=yes
  50. do_rcutorture=yes
  51. do_locktorture=yes
  52. do_scftorture=yes
  53. do_rcuscale=yes
  54. do_refscale=yes
  55. do_kvfree=yes
  56. do_normal=yes
  57. explicit_normal=no
  58. do_kasan=yes
  59. do_kcsan=no
  60. do_clocksourcewd="${ifnotaarch64}"
  61. do_rt=yes
  62. do_rcutasksflavors="${ifnotaarch64}" # FIXME: Back to "yes" when SMP=n auto-avoided
  63. do_srcu_lockdep=yes
  64. do_rcu_rust=no
  65. # doyesno - Helper function for yes/no arguments
  66. function doyesno () {
  67. if test "$1" = "$2"
  68. then
  69. echo yes
  70. else
  71. echo no
  72. fi
  73. }
  74. usage () {
  75. echo "Usage: $scriptname optional arguments:"
  76. echo " --compress-concurrency concurrency"
  77. echo " --configs-rcutorture \"config-file list w/ repeat factor (3*TINY01)\""
  78. echo " --configs-locktorture \"config-file list w/ repeat factor (10*LOCK01)\""
  79. echo " --configs-scftorture \"config-file list w/ repeat factor (2*CFLIST)\""
  80. echo " --do-all"
  81. echo " --do-allmodconfig / --do-no-allmodconfig / --no-allmodconfig"
  82. echo " --do-clocksourcewd / --do-no-clocksourcewd / --no-clocksourcewd"
  83. echo " --do-kasan / --do-no-kasan / --no-kasan"
  84. echo " --do-kcsan / --do-no-kcsan / --no-kcsan"
  85. echo " --do-kvfree / --do-no-kvfree / --no-kvfree"
  86. echo " --do-locktorture / --do-no-locktorture / --no-locktorture"
  87. echo " --do-none"
  88. echo " --do-normal / --do-no-normal / --no-normal"
  89. echo " --do-rcuscale / --do-no-rcuscale / --no-rcuscale"
  90. echo " --do-rcutasksflavors / --do-no-rcutasksflavors / --no-rcutasksflavors"
  91. echo " --do-rcutorture / --do-no-rcutorture / --no-rcutorture"
  92. echo " --do-refscale / --do-no-refscale / --no-refscale"
  93. echo " --do-rt / --do-no-rt / --no-rt"
  94. echo " --do-rcu-rust / --do-no-rcu-rust / --no-rcu-rust"
  95. echo " --do-scftorture / --do-no-scftorture / --no-scftorture"
  96. echo " --do-srcu-lockdep / --do-no-srcu-lockdep / --no-srcu-lockdep"
  97. echo " --duration [ <minutes> | <hours>h | <days>d ]"
  98. echo " --guest-cpu-limit N"
  99. echo " --kcsan-kmake-arg kernel-make-arguments"
  100. exit 1
  101. }
  102. while test $# -gt 0
  103. do
  104. case "$1" in
  105. --compress-concurrency)
  106. checkarg --compress-concurrency "(concurrency level)" $# "$2" '^[0-9][0-9]*$' '^error'
  107. compress_concurrency=$2
  108. shift
  109. ;;
  110. --config-rcutorture|--configs-rcutorture)
  111. checkarg --configs-rcutorture "(list of config files)" "$#" "$2" '^[^/]\+$' '^--'
  112. configs_rcutorture="$configs_rcutorture $2"
  113. shift
  114. ;;
  115. --config-locktorture|--configs-locktorture)
  116. checkarg --configs-locktorture "(list of config files)" "$#" "$2" '^[^/]\+$' '^--'
  117. configs_locktorture="$configs_locktorture $2"
  118. shift
  119. ;;
  120. --config-scftorture|--configs-scftorture)
  121. checkarg --configs-scftorture "(list of config files)" "$#" "$2" '^[^/]\+$' '^--'
  122. configs_scftorture="$configs_scftorture $2"
  123. shift
  124. ;;
  125. --do-all|--doall)
  126. do_allmodconfig=yes
  127. do_rcutasksflavors="${ifnotaarch64}" # FIXME: Back to "yes" when SMP=n auto-avoided
  128. do_rcutorture=yes
  129. do_locktorture=yes
  130. do_scftorture=yes
  131. do_rcuscale=yes
  132. do_refscale=yes
  133. do_rt=yes
  134. do_kvfree=yes
  135. do_normal=yes
  136. explicit_normal=no
  137. do_kasan=yes
  138. do_kcsan=yes
  139. do_clocksourcewd="${ifnotaarch64}"
  140. do_srcu_lockdep=yes
  141. ;;
  142. --do-allmodconfig|--do-no-allmodconfig|--no-allmodconfig)
  143. do_allmodconfig=`doyesno "$1" --do-allmodconfig`
  144. ;;
  145. --do-clocksourcewd|--do-no-clocksourcewd|--no-clocksourcewd)
  146. do_clocksourcewd=`doyesno "$1" --do-clocksourcewd`
  147. ;;
  148. --do-kasan|--do-no-kasan|--no-kasan)
  149. do_kasan=`doyesno "$1" --do-kasan`
  150. ;;
  151. --do-kcsan|--do-no-kcsan|--no-kcsan)
  152. do_kcsan=`doyesno "$1" --do-kcsan`
  153. ;;
  154. --do-kvfree|--do-no-kvfree|--no-kvfree)
  155. do_kvfree=`doyesno "$1" --do-kvfree`
  156. ;;
  157. --do-locktorture|--do-no-locktorture|--no-locktorture)
  158. do_locktorture=`doyesno "$1" --do-locktorture`
  159. ;;
  160. --do-none|--donone)
  161. do_allmodconfig=no
  162. do_rcutasksflavors=no
  163. do_rcutorture=no
  164. do_locktorture=no
  165. do_scftorture=no
  166. do_rcuscale=no
  167. do_refscale=no
  168. do_rt=no
  169. do_kvfree=no
  170. do_normal=no
  171. explicit_normal=no
  172. do_kasan=no
  173. do_kcsan=no
  174. do_clocksourcewd=no
  175. do_srcu_lockdep=no
  176. ;;
  177. --do-normal|--do-no-normal|--no-normal)
  178. do_normal=`doyesno "$1" --do-normal`
  179. explicit_normal=yes
  180. ;;
  181. --do-rcuscale|--do-no-rcuscale|--no-rcuscale)
  182. do_rcuscale=`doyesno "$1" --do-rcuscale`
  183. ;;
  184. --do-rcutasksflavors|--do-no-rcutasksflavors|--no-rcutasksflavors)
  185. do_rcutasksflavors=`doyesno "$1" --do-rcutasksflavors`
  186. ;;
  187. --do-rcutorture|--do-no-rcutorture|--no-rcutorture)
  188. do_rcutorture=`doyesno "$1" --do-rcutorture`
  189. ;;
  190. --do-refscale|--do-no-refscale|--no-refscale)
  191. do_refscale=`doyesno "$1" --do-refscale`
  192. ;;
  193. --do-rt|--do-no-rt|--no-rt)
  194. do_rt=`doyesno "$1" --do-rt`
  195. ;;
  196. --do-rcu-rust|--do-no-rcu-rust|--no-rcu-rust)
  197. do_rcu_rust=`doyesno "$1" --do-rcu-rust`
  198. ;;
  199. --do-scftorture|--do-no-scftorture|--no-scftorture)
  200. do_scftorture=`doyesno "$1" --do-scftorture`
  201. ;;
  202. --do-srcu-lockdep|--do-no-srcu-lockdep|--no-srcu-lockdep)
  203. do_srcu_lockdep=`doyesno "$1" --do-srcu-lockdep`
  204. ;;
  205. --duration)
  206. checkarg --duration "(minutes)" $# "$2" '^[0-9][0-9]*\(m\|h\|d\|\)$' '^error'
  207. mult=1
  208. if echo "$2" | grep -q 'm$'
  209. then
  210. mult=1
  211. elif echo "$2" | grep -q 'h$'
  212. then
  213. mult=60
  214. elif echo "$2" | grep -q 'd$'
  215. then
  216. mult=1440
  217. fi
  218. ts=`echo $2 | sed -e 's/[smhd]$//'`
  219. duration_base=$(($ts*mult))
  220. shift
  221. ;;
  222. --guest-cpu-limit|--guest-cpu-lim)
  223. checkarg --guest-cpu-limit "(number)" "$#" "$2" '^[0-9]*$' '^--'
  224. if (("$2" <= "$TORTURE_ALLOTED_CPUS" / 2))
  225. then
  226. SCALE_ALLOTED_CPUS="$2"
  227. VERBOSE_BATCH_CPUS="$((SCALE_ALLOTED_CPUS/8))"
  228. if (("$VERBOSE_BATCH_CPUS" < 2))
  229. then
  230. VERBOSE_BATCH_CPUS=0
  231. fi
  232. else
  233. echo "Ignoring value of $2 for --guest-cpu-limit which is greater than (("$TORTURE_ALLOTED_CPUS" / 2))."
  234. fi
  235. shift
  236. ;;
  237. --kcsan-kmake-arg|--kcsan-kmake-args)
  238. checkarg --kcsan-kmake-arg "(kernel make arguments)" $# "$2" '.*' '^error$'
  239. kcsan_kmake_args="`echo "$kcsan_kmake_args $2" | sed -e 's/^ *//' -e 's/ *$//'`"
  240. shift
  241. ;;
  242. *)
  243. echo Unknown argument $1
  244. usage
  245. ;;
  246. esac
  247. shift
  248. done
  249. ds="`date +%Y.%m.%d-%H.%M.%S`-torture"
  250. startdate="`date`"
  251. starttime="`get_starttime`"
  252. T="`mktemp -d ${TMPDIR-/tmp}/torture.sh.XXXXXX`"
  253. trap 'rm -rf $T' 0 2
  254. echo " --- " $scriptname $args | tee -a $T/log
  255. echo " --- Results directory: " $ds | tee -a $T/log
  256. if test "$do_normal" = "no" && test "$do_kasan" = "no" && test "$do_kcsan" = "no"
  257. then
  258. # Match old scripts so that "--do-none --do-rcutorture" does
  259. # normal rcutorture testing, but no KASAN or KCSAN testing.
  260. if test $explicit_normal = yes
  261. then
  262. echo " --- Everything disabled, so explicit --do-normal overridden" | tee -a $T/log
  263. fi
  264. do_normal=yes
  265. fi
  266. # Calculate rcutorture defaults and apportion time
  267. if test -z "$configs_rcutorture"
  268. then
  269. configs_rcutorture=CFLIST
  270. fi
  271. duration_rcutorture=$((duration_base*duration_rcutorture_frac/10))
  272. if test "$duration_rcutorture" -eq 0 && test "$do_locktorture" = "yes"
  273. then
  274. echo " --- Zero time for rcutorture, disabling" | tee -a $T/log
  275. do_rcutorture=no
  276. fi
  277. # Calculate locktorture defaults and apportion time
  278. if test -z "$configs_locktorture"
  279. then
  280. configs_locktorture=CFLIST
  281. fi
  282. duration_locktorture=$((duration_base*duration_locktorture_frac/10))
  283. if test "$duration_locktorture" -eq 0 && test "$do_locktorture" = "yes"
  284. then
  285. echo " --- Zero time for locktorture, disabling" | tee -a $T/log
  286. do_locktorture=no
  287. fi
  288. # Calculate scftorture defaults and apportion time
  289. if test -z "$configs_scftorture"
  290. then
  291. configs_scftorture=CFLIST
  292. fi
  293. duration_scftorture=$((duration_base*duration_scftorture_frac/10))
  294. if test "$duration_scftorture" -eq 0 && test "$do_scftorture" = "yes"
  295. then
  296. echo " --- Zero time for scftorture, disabling" | tee -a $T/log
  297. do_scftorture=no
  298. fi
  299. # CONFIG_EXPERT=y is currently required for arm64 KCSAN runs.
  300. kcsan_expert=
  301. if test "${thisarch}" = aarch64
  302. then
  303. kcsan_expert="CONFIG_EXPERT=y"
  304. fi
  305. touch $T/failures
  306. touch $T/successes
  307. # torture_one - Does a single kvm.sh run.
  308. #
  309. # Usage:
  310. # torture_bootargs="[ kernel boot arguments ]"
  311. # torture_one flavor [ kvm.sh arguments ]
  312. #
  313. # Note that "flavor" is an arbitrary string. Supply --torture if needed.
  314. # Note that quoting is problematic. So on the command line, pass multiple
  315. # values with multiple kvm.sh argument instances.
  316. function torture_one {
  317. local cur_bootargs=
  318. local boottag=
  319. echo " --- $curflavor:" Start `date` | tee -a $T/log
  320. if test -n "$torture_bootargs"
  321. then
  322. boottag="--bootargs"
  323. cur_bootargs="$torture_bootargs"
  324. fi
  325. "$@" $boottag "$cur_bootargs" --datestamp "$ds/results-$curflavor" > $T/$curflavor.out 2>&1
  326. retcode=$?
  327. resdir="`grep '^Results directory: ' $T/$curflavor.out | tail -1 | sed -e 's/^Results directory: //'`"
  328. if test -z "$resdir"
  329. then
  330. cat $T/$curflavor.out | tee -a $T/log
  331. echo retcode=$retcode | tee -a $T/log
  332. else
  333. echo $resdir > $T/last-resdir
  334. fi
  335. if test "$retcode" == 0
  336. then
  337. echo "$curflavor($retcode)" $resdir >> $T/successes
  338. else
  339. echo "$curflavor($retcode)" $resdir >> $T/failures
  340. fi
  341. }
  342. # torture_set - Does a set of tortures with and without KASAN and KCSAN.
  343. #
  344. # Usage:
  345. # torture_bootargs="[ kernel boot arguments ]"
  346. # torture_set flavor [ kvm.sh arguments ]
  347. #
  348. # Note that "flavor" is an arbitrary string that does not affect kvm.sh
  349. # in any way. So also supply --torture if you need something other than
  350. # the default.
  351. function torture_set {
  352. local cur_kcsan_kmake_args=
  353. local kcsan_kmake_tag=
  354. local flavor=$1
  355. shift
  356. if test "$do_normal" = "yes"
  357. then
  358. curflavor=$flavor
  359. torture_one "$@"
  360. if test -e $T/last-resdir
  361. then
  362. mv $T/last-resdir $T/last-resdir-nodebug || :
  363. fi
  364. fi
  365. if test "$do_kasan" = "yes"
  366. then
  367. curflavor=${flavor}-kasan
  368. torture_one "$@" --kasan
  369. if test -e $T/last-resdir
  370. then
  371. mv $T/last-resdir $T/last-resdir-kasan || :
  372. fi
  373. fi
  374. if test "$do_kcsan" = "yes"
  375. then
  376. curflavor=${flavor}-kcsan
  377. if test -n "$kcsan_kmake_args"
  378. then
  379. kcsan_kmake_tag="--kmake-args"
  380. cur_kcsan_kmake_args="$kcsan_kmake_args"
  381. fi
  382. chk_rdr_state=
  383. if test "${flavor}" = rcutorture
  384. then
  385. chk_rdr_state="CONFIG_RCU_TORTURE_TEST_CHK_RDR_STATE=y"
  386. fi
  387. torture_one "$@" --kconfig "CONFIG_DEBUG_LOCK_ALLOC=y CONFIG_PROVE_LOCKING=y ${kcsan_expert} ${chk_rdr_state}" $kcsan_kmake_tag $cur_kcsan_kmake_args --kcsan
  388. if test -e $T/last-resdir
  389. then
  390. mv $T/last-resdir $T/last-resdir-kcsan || :
  391. fi
  392. fi
  393. }
  394. # make allmodconfig
  395. if test "$do_allmodconfig" = "yes"
  396. then
  397. echo " --- allmodconfig:" Start `date` | tee -a $T/log
  398. amcdir="tools/testing/selftests/rcutorture/res/$ds/allmodconfig"
  399. mkdir -p "$amcdir"
  400. mktestid.sh "$amcdir"
  401. echo " --- make clean" | tee $amcdir/log > "$amcdir/Make.out" 2>&1
  402. make -j$MAKE_ALLOTED_CPUS clean >> "$amcdir/Make.out" 2>&1
  403. retcode=$?
  404. buildphase='"make clean"'
  405. if test "$retcode" -eq 0
  406. then
  407. echo " --- make allmodconfig" | tee -a $amcdir/log >> "$amcdir/Make.out" 2>&1
  408. cp .config $amcdir
  409. make -j$MAKE_ALLOTED_CPUS allmodconfig >> "$amcdir/Make.out" 2>&1
  410. retcode=$?
  411. buildphase='"make allmodconfig"'
  412. fi
  413. if test "$retcode" -eq 0
  414. then
  415. echo " --- make " | tee -a $amcdir/log >> "$amcdir/Make.out" 2>&1
  416. make -j$MAKE_ALLOTED_CPUS >> "$amcdir/Make.out" 2>&1
  417. retcode="$?"
  418. echo $retcode > "$amcdir/Make.exitcode"
  419. if grep -E -q "Stop|ERROR|Error|error:|warning:" < "$amcdir/Make.out"
  420. then
  421. retcode=99
  422. fi
  423. buildphase='"make"'
  424. fi
  425. if test "$retcode" -eq 0
  426. then
  427. echo "allmodconfig($retcode)" $amcdir >> $T/successes
  428. echo Success >> $amcdir/log
  429. else
  430. echo "allmodconfig($retcode)" $amcdir >> $T/failures
  431. echo " --- allmodconfig Test summary:" >> $amcdir/log
  432. echo " --- Summary: Exit code $retcode from $buildphase, see Make.out" >> $amcdir/log
  433. fi
  434. fi
  435. # Test building RCU Tasks flavors in isolation, both SMP and !SMP
  436. if test "$do_rcutasksflavors" = "yes"
  437. then
  438. echo " --- rcutasksflavors:" Start `date` | tee -a $T/log
  439. rtfdir="tools/testing/selftests/rcutorture/res/$ds/results-rcutasksflavors"
  440. mkdir -p "$rtfdir"
  441. cat > $T/rcutasksflavors << __EOF__
  442. #CHECK#CONFIG_TASKS_RCU=n
  443. #CHECK#CONFIG_TASKS_RUDE_RCU=n
  444. #CHECK#CONFIG_TASKS_TRACE_RCU=n
  445. __EOF__
  446. for flavor in CONFIG_TASKS_RCU CONFIG_TASKS_RUDE_RCU CONFIG_TASKS_TRACE_RCU
  447. do
  448. forceflavor="`echo $flavor | sed -e 's/^CONFIG/CONFIG_FORCE/'`"
  449. deselectedflavors="`grep -v $flavor $T/rcutasksflavors | tr '\012' ' ' | tr -s ' ' | sed -e 's/ *$//'`"
  450. echo " --- Running RCU Tasks Trace flavor $flavor `date`" >> $rtfdir/log
  451. tools/testing/selftests/rcutorture/bin/kvm.sh --datestamp "$ds/results-rcutasksflavors/$flavor" --buildonly --configs "TINY01 TREE04" --kconfig "CONFIG_RCU_EXPERT=y CONFIG_RCU_SCALE_TEST=y CONFIG_KPROBES=n CONFIG_RCU_TRACE=n CONFIG_TRACING=n CONFIG_BLK_DEV_IO_TRACE=n CONFIG_UPROBE_EVENTS=n $forceflavor=y $deselectedflavors" --trust-make > $T/$flavor.out 2>&1
  452. retcode=$?
  453. if test "$retcode" -ne 0
  454. then
  455. break
  456. fi
  457. done
  458. if test "$retcode" -eq 0
  459. then
  460. echo "rcutasksflavors($retcode)" $rtfdir >> $T/successes
  461. echo Success >> $rtfdir/log
  462. else
  463. echo "rcutasksflavors($retcode)" $rtfdir >> $T/failures
  464. echo " --- rcutasksflavors Test summary:" >> $rtfdir/log
  465. echo " --- Summary: Exit code $retcode from $flavor, see Make.out" >> $rtfdir/log
  466. fi
  467. fi
  468. # --torture rcu
  469. if test "$do_rcutorture" = "yes"
  470. then
  471. torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000"
  472. torture_set "rcutorture" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration "$duration_rcutorture" --configs "$configs_rcutorture" --trust-make
  473. fi
  474. if test "$do_locktorture" = "yes"
  475. then
  476. torture_bootargs="torture.disable_onoff_at_boot"
  477. torture_set "locktorture" tools/testing/selftests/rcutorture/bin/kvm.sh --torture lock --allcpus --duration "$duration_locktorture" --configs "$configs_locktorture" --trust-make
  478. fi
  479. if test "$do_scftorture" = "yes"
  480. then
  481. # Scale memory based on the number of CPUs.
  482. scfmem=$((3+SCALE_ALLOTED_CPUS/16))
  483. torture_bootargs="scftorture.nthreads=$SCALE_ALLOTED_CPUS torture.disable_onoff_at_boot csdlock_debug=1"
  484. torture_set "scftorture" tools/testing/selftests/rcutorture/bin/kvm.sh --torture scf --allcpus --duration "$duration_scftorture" --configs "$configs_scftorture" --kconfig "CONFIG_NR_CPUS=$SCALE_ALLOTED_CPUS" --memory ${scfmem}G --trust-make
  485. fi
  486. if test "$do_rt" = "yes"
  487. then
  488. # In both runs, disable testing of RCU priority boosting because
  489. # -rt doesn't like its interaction with testing of callback
  490. # flooding.
  491. # With all post-boot grace periods forced to normal (default for PREEMPT_RT).
  492. torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 rcutorture.test_boost=0 rcutorture.preempt_duration=0"
  493. torture_set "rcurttorture" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration "$duration_rcutorture" --configs "TREE03" --kconfig "CONFIG_PREEMPT_RT=y CONFIG_EXPERT=y CONFIG_HZ_PERIODIC=n CONFIG_NO_HZ_IDLE=y CONFIG_RCU_NOCB_CPU=y" --trust-make
  494. # With all post-boot grace periods forced to expedited.
  495. torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 rcutorture.test_boost=0 rcupdate.rcu_normal_after_boot=0 rcupdate.rcu_expedited=1 rcutorture.preempt_duration=0"
  496. torture_set "rcurttorture-exp" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration "$duration_rcutorture" --configs "TREE03" --kconfig "CONFIG_PREEMPT_RT=y CONFIG_EXPERT=y CONFIG_HZ_PERIODIC=n CONFIG_NO_HZ_FULL=y CONFIG_RCU_NOCB_CPU=y" --trust-make
  497. fi
  498. if test "$do_rcu_rust" = "yes"
  499. then
  500. echo " --- do-rcu-rust:" Start `date` | tee -a $T/log
  501. rrdir="tools/testing/selftests/rcutorture/res/$ds/results-rcu-rust"
  502. mkdir -p "$rrdir"
  503. mktestid.sh "$rrdir"
  504. echo " --- make LLVM=1 rustavailable " | tee -a $rrdir/log > $rrdir/rustavailable.out
  505. make LLVM=1 rustavailable > $T/rustavailable.out 2>&1
  506. retcode=$?
  507. echo $retcode > $rrdir/rustavailable.exitcode
  508. cat $T/rustavailable.out | tee -a $rrdir/log >> $rrdir/rustavailable.out 2>&1
  509. buildphase=rustavailable
  510. if test "$retcode" -eq 0
  511. then
  512. echo " --- Running 'make mrproper' in order to run kunit." | tee -a $rrdir/log > $rrdir/mrproper.out
  513. make mrproper > $rrdir/mrproper.out 2>&1
  514. retcode=$?
  515. echo $retcode > $rrdir/mrproper.exitcode
  516. buildphase=mrproper
  517. fi
  518. if test "$retcode" -eq 0
  519. then
  520. echo " --- Running rust_doctests_kernel." | tee -a $rrdir/log > $rrdir/rust_doctests_kernel.out
  521. ./tools/testing/kunit/kunit.py run --make_options LLVM=1 --make_options CLIPPY=1 --arch arm64 --kconfig_add CONFIG_SMP=y --kconfig_add CONFIG_WERROR=y --kconfig_add CONFIG_RUST=y rust_doctests_kernel >> $rrdir/rust_doctests_kernel.out 2>&1
  522. # @@@ Remove "--arch arm64" in order to test on native architecture?
  523. # @@@ Analyze $rrdir/rust_doctests_kernel.out contents?
  524. retcode=$?
  525. echo $retcode > $rrdir/rust_doctests_kernel.exitcode
  526. buildphase=rust_doctests_kernel
  527. fi
  528. if test "$retcode" -eq 0
  529. then
  530. echo "rcu-rust($retcode)" $rrdir >> $T/successes
  531. echo Success >> $rrdir/log
  532. else
  533. echo "rcu-rust($retcode)" $rrdir >> $T/failures
  534. echo " --- rcu-rust Test summary:" >> $rrdir/log
  535. echo " --- Summary: Exit code $retcode from $buildphase, see $rrdir/$buildphase.out" >> $rrdir/log
  536. fi
  537. fi
  538. if test "$do_srcu_lockdep" = "yes"
  539. then
  540. echo " --- do-srcu-lockdep:" Start `date` | tee -a $T/log
  541. tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh --datestamp "$ds/results-srcu-lockdep" > $T/srcu_lockdep.sh.out 2>&1
  542. retcode=$?
  543. cp $T/srcu_lockdep.sh.out "tools/testing/selftests/rcutorture/res/$ds/results-srcu-lockdep/log"
  544. if test "$retcode" -eq 0
  545. then
  546. echo "srcu_lockdep($retcode)" "tools/testing/selftests/rcutorture/res/$ds/results-srcu-lockdep" >> $T/successes
  547. echo Success >> "tools/testing/selftests/rcutorture/res/$ds/results-srcu-lockdep/log"
  548. else
  549. echo "srcu_lockdep($retcode)" "tools/testing/selftests/rcutorture/res/$ds/results-srcu-lockdep" >> $T/failures
  550. echo " --- srcu_lockdep Test Summary:" >> "tools/testing/selftests/rcutorture/res/$ds/results-srcu-lockdep/log"
  551. echo " --- Summary: Exit code $retcode from srcu_lockdep.sh, see ds/results-srcu-lockdep" >> "tools/testing/selftests/rcutorture/res/$ds/results-srcu-lockdep/log"
  552. fi
  553. fi
  554. if test "$do_refscale" = yes
  555. then
  556. primlist="`grep '\.name[ ]*=' kernel/rcu/refscale.c | sed -e 's/^[^"]*"//' -e 's/".*$//'`"
  557. else
  558. primlist=
  559. fi
  560. firsttime=1
  561. do_kasan_save="$do_kasan"
  562. do_kcsan_save="$do_kcsan"
  563. for prim in $primlist
  564. do
  565. if test -n "$firsttime"
  566. then
  567. torture_bootargs="refscale.scale_type="$prim" refscale.nreaders=$SCALE_ALLOTED_CPUS refscale.loops=10000 refscale.holdoff=20 torture.disable_onoff_at_boot"
  568. torture_set "refscale-$prim" tools/testing/selftests/rcutorture/bin/kvm.sh --torture refscale --allcpus --duration 5 --kconfig "CONFIG_TASKS_TRACE_RCU=y CONFIG_NR_CPUS=$SCALE_ALLOTED_CPUS" --bootargs "refscale.verbose_batched=$VERBOSE_BATCH_CPUS torture.verbose_sleep_frequency=8 torture.verbose_sleep_duration=$VERBOSE_BATCH_CPUS" --trust-make
  569. mv $T/last-resdir-nodebug $T/first-resdir-nodebug || :
  570. if test -f "$T/last-resdir-kasan"
  571. then
  572. mv $T/last-resdir-kasan $T/first-resdir-kasan || :
  573. fi
  574. if test -f "$T/last-resdir-kcsan"
  575. then
  576. mv $T/last-resdir-kcsan $T/first-resdir-kcsan || :
  577. fi
  578. firsttime=
  579. do_kasan=
  580. do_kcsan=
  581. else
  582. torture_bootargs=
  583. for i in $T/first-resdir-*
  584. do
  585. case "$i" in
  586. *-nodebug)
  587. torture_suffix=
  588. ;;
  589. *-kasan)
  590. torture_suffix="-kasan"
  591. ;;
  592. *-kcsan)
  593. torture_suffix="-kcsan"
  594. ;;
  595. esac
  596. torture_set "refscale-$prim$torture_suffix" tools/testing/selftests/rcutorture/bin/kvm-again.sh "`cat "$i"`" --duration 5 --bootargs "refscale.scale_type=$prim"
  597. done
  598. fi
  599. done
  600. do_kasan="$do_kasan_save"
  601. do_kcsan="$do_kcsan_save"
  602. if test "$do_rcuscale" = yes
  603. then
  604. primlist="`grep '\.name[ ]*=' kernel/rcu/rcuscale.c | sed -e 's/^[^"]*"//' -e 's/".*$//'`"
  605. else
  606. primlist=
  607. fi
  608. firsttime=1
  609. do_kasan_save="$do_kasan"
  610. do_kcsan_save="$do_kcsan"
  611. for prim in $primlist
  612. do
  613. if test -n "$firsttime"
  614. then
  615. torture_bootargs="rcuscale.scale_type="$prim" rcuscale.nwriters=$SCALE_ALLOTED_CPUS rcuscale.holdoff=20 torture.disable_onoff_at_boot"
  616. torture_set "rcuscale-$prim" tools/testing/selftests/rcutorture/bin/kvm.sh --torture rcuscale --allcpus --duration 5 --kconfig "CONFIG_TASKS_TRACE_RCU=y CONFIG_NR_CPUS=$SCALE_ALLOTED_CPUS" --trust-make
  617. mv $T/last-resdir-nodebug $T/first-resdir-nodebug || :
  618. if test -f "$T/last-resdir-kasan"
  619. then
  620. mv $T/last-resdir-kasan $T/first-resdir-kasan || :
  621. fi
  622. if test -f "$T/last-resdir-kcsan"
  623. then
  624. mv $T/last-resdir-kcsan $T/first-resdir-kcsan || :
  625. fi
  626. firsttime=
  627. do_kasan=
  628. do_kcsan=
  629. else
  630. torture_bootargs=
  631. for i in $T/first-resdir-*
  632. do
  633. case "$i" in
  634. *-nodebug)
  635. torture_suffix=
  636. ;;
  637. *-kasan)
  638. torture_suffix="-kasan"
  639. ;;
  640. *-kcsan)
  641. torture_suffix="-kcsan"
  642. ;;
  643. esac
  644. torture_set "rcuscale-$prim$torture_suffix" tools/testing/selftests/rcutorture/bin/kvm-again.sh "`cat "$i"`" --duration 5 --bootargs "rcuscale.scale_type=$prim"
  645. done
  646. fi
  647. done
  648. do_kasan="$do_kasan_save"
  649. do_kcsan="$do_kcsan_save"
  650. if test "$do_kvfree" = "yes"
  651. then
  652. torture_bootargs="rcuscale.kfree_rcu_test=1 rcuscale.kfree_nthreads=16 rcuscale.holdoff=20 rcuscale.kfree_loops=10000 torture.disable_onoff_at_boot"
  653. torture_set "rcuscale-kvfree" tools/testing/selftests/rcutorture/bin/kvm.sh --torture rcuscale --allcpus --duration $duration_rcutorture --kconfig "CONFIG_NR_CPUS=$SCALE_ALLOTED_CPUS" --memory 2G --trust-make
  654. fi
  655. if test "$do_clocksourcewd" = "yes"
  656. then
  657. torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 tsc=watchdog"
  658. torture_set "clocksourcewd-1" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 45s --configs TREE03 --kconfig "CONFIG_TEST_CLOCKSOURCE_WATCHDOG=y" --trust-make
  659. torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 tsc=watchdog"
  660. torture_set "clocksourcewd-2" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 45s --configs TREE03 --kconfig "CONFIG_TEST_CLOCKSOURCE_WATCHDOG=y" --trust-make
  661. # In case our work is already done...
  662. if test "$do_rcutorture" != "yes"
  663. then
  664. torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 tsc=watchdog"
  665. torture_set "clocksourcewd-3" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 45s --configs TREE03 --trust-make
  666. fi
  667. fi
  668. echo " --- " $scriptname $args
  669. echo " --- " Done `date` | tee -a $T/log
  670. ret=0
  671. nsuccesses=0
  672. echo SUCCESSES: | tee -a $T/log
  673. if test -s "$T/successes"
  674. then
  675. cat "$T/successes" | tee -a $T/log
  676. nsuccesses="`wc -l "$T/successes" | awk '{ print $1 }'`"
  677. fi
  678. nfailures=0
  679. echo FAILURES: | tee -a $T/log
  680. if test -s "$T/failures"
  681. then
  682. awk < "$T/failures" -v sq="'" '
  683. {
  684. print "echo " sq $0 sq;
  685. if ($2 != "")
  686. print "sed -e " sq "1,/^ --- .* Test summary:$/d" sq " " $2 "/log | grep Summary: | sed -e " sq "s/^[^S]*/ /" sq;
  687. else
  688. print "echo " sq " " sq "Run failed to produce results directory.";
  689. }' | sh | tee -a $T/log | tee "$T/failuresum"
  690. nfailures="`wc -l "$T/failures" | awk '{ print $1 }'`"
  691. grep "^ Summary: " "$T/failuresum" |
  692. grep -v '^ Summary: Bugs: [0-9]* (all bugs kcsan)$' > "$T/nonkcsan"
  693. if test -s "$T/nonkcsan"
  694. then
  695. nonkcsanbug="yes"
  696. fi
  697. ret=2
  698. fi
  699. if test "$do_kcsan" = "yes" && test -e tools/testing/selftests/rcutorture/res/$ds
  700. then
  701. TORTURE_KCONFIG_KCSAN_ARG=1 tools/testing/selftests/rcutorture/bin/kcsan-collapse.sh tools/testing/selftests/rcutorture/res/$ds > tools/testing/selftests/rcutorture/res/$ds/kcsan.sum
  702. fi
  703. echo Started at $startdate, ended at `date`, duration `get_starttime_duration $starttime`. | tee -a $T/log
  704. echo Summary: Successes: $nsuccesses Failures: $nfailures. | tee -a $T/log
  705. tdir="`cat $T/successes $T/failures | awk 'NF > 1 { print $NF }' | head -1 | sed -e 's,/[^/]\+/*$,,'`"
  706. if test -n "$tdir"
  707. then
  708. find "$tdir" -name 'ConfigFragment.diags' -print > $T/configerrors
  709. find "$tdir" -name 'Make.out.diags' -print > $T/builderrors
  710. fi
  711. if test -s "$T/configerrors"
  712. then
  713. echo " Scenarios with .config errors: `wc -l "$T/configerrors" | awk '{ print $1 }'`"
  714. nonkcsanbug="yes"
  715. fi
  716. if test -s "$T/builderrors"
  717. then
  718. echo " Scenarios with build errors: `wc -l "$T/builderrors" | awk '{ print $1 }'`"
  719. nonkcsanbug="yes"
  720. fi
  721. if test -z "$nonkcsanbug" && test -s "$T/failuresum"
  722. then
  723. echo " All bugs were KCSAN failures."
  724. fi
  725. if test -n "$tdir" && test $compress_concurrency -gt 0
  726. then
  727. # KASAN vmlinux files can approach 1GB in size, so compress them.
  728. echo Looking for K[AC]SAN files to compress: `date` > "$tdir/log-xz" 2>&1
  729. find "$tdir" -type d -name '*-k[ac]san' -print > $T/xz-todo-all
  730. find "$tdir" -type f -name 're-run' -print | sed -e 's,/re-run,,' |
  731. grep -e '-k[ac]san$' > $T/xz-todo-copy
  732. sort $T/xz-todo-all $T/xz-todo-copy | uniq -u > $T/xz-todo
  733. ncompresses=0
  734. batchno=1
  735. if test -s $T/xz-todo
  736. then
  737. for i in `cat $T/xz-todo`
  738. do
  739. find $i -name 'vmlinux*' -print
  740. done | wc -l | awk '{ print $1 }' > $T/xz-todo-count
  741. n2compress="`cat $T/xz-todo-count`"
  742. echo Size before compressing $n2compress files: `du -sh $tdir | awk '{ print $1 }'` `date` 2>&1 | tee -a "$tdir/log-xz" | tee -a $T/log
  743. for i in `cat $T/xz-todo`
  744. do
  745. echo Compressing vmlinux files in ${i}: `date` >> "$tdir/log-xz" 2>&1
  746. for j in $i/*/vmlinux
  747. do
  748. xz "$j" >> "$tdir/log-xz" 2>&1 &
  749. ncompresses=$((ncompresses+1))
  750. if test $ncompresses -ge $compress_concurrency
  751. then
  752. echo Waiting for batch $batchno of $ncompresses compressions `date` | tee -a "$tdir/log-xz" | tee -a $T/log
  753. wait
  754. ncompresses=0
  755. batchno=$((batchno+1))
  756. fi
  757. done
  758. done
  759. if test $ncompresses -gt 0
  760. then
  761. echo Waiting for final batch $batchno of $ncompresses compressions `date` | tee -a "$tdir/log-xz" | tee -a $T/log
  762. fi
  763. wait
  764. if test -s $T/xz-todo-copy
  765. then
  766. # The trick here is that we need corresponding
  767. # vmlinux files from corresponding scenarios.
  768. echo Linking vmlinux.xz files to re-use scenarios `date` | tee -a "$tdir/log-xz" | tee -a $T/log
  769. dirstash="`pwd`"
  770. for i in `cat $T/xz-todo-copy`
  771. do
  772. cd $i
  773. find . -name vmlinux -print > $T/xz-todo-copy-vmlinux
  774. for v in `cat $T/xz-todo-copy-vmlinux`
  775. do
  776. rm -f "$v"
  777. cp -l `cat $i/re-run`/"$i/$v".xz "`dirname "$v"`"
  778. done
  779. cd "$dirstash"
  780. done
  781. fi
  782. echo Size after compressing $n2compress files: `du -sh $tdir | awk '{ print $1 }'` `date` 2>&1 | tee -a "$tdir/log-xz" | tee -a $T/log
  783. echo Total duration `get_starttime_duration $starttime`. | tee -a $T/log
  784. else
  785. echo No compression needed: `date` >> "$tdir/log-xz" 2>&1
  786. fi
  787. fi
  788. if test -n "$tdir"
  789. then
  790. cp $T/log "$tdir"
  791. fi
  792. exit $ret