brintos

brintos / linux-shallow public Read only

0
0
Text · 23.2 KiB · 0447c4a Raw
712 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.0+3#4# Run a series of torture tests, intended for overnight or5# 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 13scriptname=$014args="$*"15 16RCUTORTURE="`pwd`/tools/testing/selftests/rcutorture"; export RCUTORTURE17PATH=${RCUTORTURE}/bin:$PATH; export PATH18. functions.sh19 20TORTURE_ALLOTED_CPUS="`identify_qemu_vcpus`"21MAKE_ALLOTED_CPUS=$((TORTURE_ALLOTED_CPUS*2))22SCALE_ALLOTED_CPUS=$((TORTURE_ALLOTED_CPUS/2))23if test "$SCALE_ALLOTED_CPUS" -lt 124then25	SCALE_ALLOTED_CPUS=126fi27VERBOSE_BATCH_CPUS=$((TORTURE_ALLOTED_CPUS/16))28if test "$VERBOSE_BATCH_CPUS" -lt 229then30	VERBOSE_BATCH_CPUS=031fi32 33# Configurations/scenarios.34configs_rcutorture=35configs_locktorture=36configs_scftorture=37kcsan_kmake_args=38 39# Default compression, duration, and apportionment.40compress_concurrency="`identify_qemu_vcpus`"41duration_base=1042duration_rcutorture_frac=743duration_locktorture_frac=144duration_scftorture_frac=245 46# "yes" or "no" parameters47do_allmodconfig=yes48do_rcutorture=yes49do_locktorture=yes50do_scftorture=yes51do_rcuscale=yes52do_refscale=yes53do_kvfree=yes54do_kasan=yes55do_kcsan=no56do_clocksourcewd=yes57do_rt=yes58do_rcutasksflavors=yes59do_srcu_lockdep=yes60 61# doyesno - Helper function for yes/no arguments62function doyesno () {63	if test "$1" = "$2"64	then65		echo yes66	else67		echo no68	fi69}70 71usage () {72	echo "Usage: $scriptname optional arguments:"73	echo "       --compress-concurrency concurrency"74	echo "       --configs-rcutorture \"config-file list w/ repeat factor (3*TINY01)\""75	echo "       --configs-locktorture \"config-file list w/ repeat factor (10*LOCK01)\""76	echo "       --configs-scftorture \"config-file list w/ repeat factor (2*CFLIST)\""77	echo "       --do-all"78	echo "       --do-allmodconfig / --do-no-allmodconfig / --no-allmodconfig"79	echo "       --do-clocksourcewd / --do-no-clocksourcewd / --no-clocksourcewd"80	echo "       --do-kasan / --do-no-kasan / --no-kasan"81	echo "       --do-kcsan / --do-no-kcsan / --no-kcsan"82	echo "       --do-kvfree / --do-no-kvfree / --no-kvfree"83	echo "       --do-locktorture / --do-no-locktorture / --no-locktorture"84	echo "       --do-none"85	echo "       --do-rcuscale / --do-no-rcuscale / --no-rcuscale"86	echo "       --do-rcutasksflavors / --do-no-rcutasksflavors / --no-rcutasksflavors"87	echo "       --do-rcutorture / --do-no-rcutorture / --no-rcutorture"88	echo "       --do-refscale / --do-no-refscale / --no-refscale"89	echo "       --do-rt / --do-no-rt / --no-rt"90	echo "       --do-scftorture / --do-no-scftorture / --no-scftorture"91	echo "       --do-srcu-lockdep / --do-no-srcu-lockdep / --no-srcu-lockdep"92	echo "       --duration [ <minutes> | <hours>h | <days>d ]"93	echo "       --guest-cpu-limit N"94	echo "       --kcsan-kmake-arg kernel-make-arguments"95	exit 196}97 98while test $# -gt 099do100	case "$1" in101	--compress-concurrency)102		checkarg --compress-concurrency "(concurrency level)" $# "$2" '^[0-9][0-9]*$' '^error'103		compress_concurrency=$2104		shift105		;;106	--config-rcutorture|--configs-rcutorture)107		checkarg --configs-rcutorture "(list of config files)" "$#" "$2" '^[^/]\+$' '^--'108		configs_rcutorture="$configs_rcutorture $2"109		shift110		;;111	--config-locktorture|--configs-locktorture)112		checkarg --configs-locktorture "(list of config files)" "$#" "$2" '^[^/]\+$' '^--'113		configs_locktorture="$configs_locktorture $2"114		shift115		;;116	--config-scftorture|--configs-scftorture)117		checkarg --configs-scftorture "(list of config files)" "$#" "$2" '^[^/]\+$' '^--'118		configs_scftorture="$configs_scftorture $2"119		shift120		;;121	--do-all|--doall)122		do_allmodconfig=yes123		do_rcutasksflavor=yes124		do_rcutorture=yes125		do_locktorture=yes126		do_scftorture=yes127		do_rcuscale=yes128		do_refscale=yes129		do_rt=yes130		do_kvfree=yes131		do_kasan=yes132		do_kcsan=yes133		do_clocksourcewd=yes134		do_srcu_lockdep=yes135		;;136	--do-allmodconfig|--do-no-allmodconfig|--no-allmodconfig)137		do_allmodconfig=`doyesno "$1" --do-allmodconfig`138		;;139	--do-clocksourcewd|--do-no-clocksourcewd|--no-clocksourcewd)140		do_clocksourcewd=`doyesno "$1" --do-clocksourcewd`141		;;142	--do-kasan|--do-no-kasan|--no-kasan)143		do_kasan=`doyesno "$1" --do-kasan`144		;;145	--do-kcsan|--do-no-kcsan|--no-kcsan)146		do_kcsan=`doyesno "$1" --do-kcsan`147		;;148	--do-kvfree|--do-no-kvfree|--no-kvfree)149		do_kvfree=`doyesno "$1" --do-kvfree`150		;;151	--do-locktorture|--do-no-locktorture|--no-locktorture)152		do_locktorture=`doyesno "$1" --do-locktorture`153		;;154	--do-none|--donone)155		do_allmodconfig=no156		do_rcutasksflavors=no157		do_rcutorture=no158		do_locktorture=no159		do_scftorture=no160		do_rcuscale=no161		do_refscale=no162		do_rt=no163		do_kvfree=no164		do_kasan=no165		do_kcsan=no166		do_clocksourcewd=no167		do_srcu_lockdep=no168		;;169	--do-rcuscale|--do-no-rcuscale|--no-rcuscale)170		do_rcuscale=`doyesno "$1" --do-rcuscale`171		;;172	--do-rcutasksflavors|--do-no-rcutasksflavors|--no-rcutasksflavors)173		do_rcutasksflavors=`doyesno "$1" --do-rcutasksflavors`174		;;175	--do-rcutorture|--do-no-rcutorture|--no-rcutorture)176		do_rcutorture=`doyesno "$1" --do-rcutorture`177		;;178	--do-refscale|--do-no-refscale|--no-refscale)179		do_refscale=`doyesno "$1" --do-refscale`180		;;181	--do-rt|--do-no-rt|--no-rt)182		do_rt=`doyesno "$1" --do-rt`183		;;184	--do-scftorture|--do-no-scftorture|--no-scftorture)185		do_scftorture=`doyesno "$1" --do-scftorture`186		;;187	--do-srcu-lockdep|--do-no-srcu-lockdep|--no-srcu-lockdep)188		do_srcu_lockdep=`doyesno "$1" --do-srcu-lockdep`189		;;190	--duration)191		checkarg --duration "(minutes)" $# "$2" '^[0-9][0-9]*\(m\|h\|d\|\)$' '^error'192		mult=1193		if echo "$2" | grep -q 'm$'194		then195			mult=1196		elif echo "$2" | grep -q 'h$'197		then198			mult=60199		elif echo "$2" | grep -q 'd$'200		then201			mult=1440202		fi203		ts=`echo $2 | sed -e 's/[smhd]$//'`204		duration_base=$(($ts*mult))205		shift206		;;207	--guest-cpu-limit|--guest-cpu-lim)208		checkarg --guest-cpu-limit "(number)" "$#" "$2" '^[0-9]*$' '^--'209		if (("$2" <= "$TORTURE_ALLOTED_CPUS" / 2))210		then211			SCALE_ALLOTED_CPUS="$2"212			VERBOSE_BATCH_CPUS="$((SCALE_ALLOTED_CPUS/8))"213			if (("$VERBOSE_BATCH_CPUS" < 2))214			then215				VERBOSE_BATCH_CPUS=0216			fi217		else218			echo "Ignoring value of $2 for --guest-cpu-limit which is greater than (("$TORTURE_ALLOTED_CPUS" / 2))."219		fi220		shift221		;;222	--kcsan-kmake-arg|--kcsan-kmake-args)223		checkarg --kcsan-kmake-arg "(kernel make arguments)" $# "$2" '.*' '^error$'224		kcsan_kmake_args="`echo "$kcsan_kmake_args $2" | sed -e 's/^ *//' -e 's/ *$//'`"225		shift226		;;227	*)228		echo Unknown argument $1229		usage230		;;231	esac232	shift233done234 235ds="`date +%Y.%m.%d-%H.%M.%S`-torture"236startdate="`date`"237starttime="`get_starttime`"238 239T="`mktemp -d ${TMPDIR-/tmp}/torture.sh.XXXXXX`"240trap 'rm -rf $T' 0 2241 242echo " --- " $scriptname $args | tee -a $T/log243echo " --- Results directory: " $ds | tee -a $T/log244 245# Calculate rcutorture defaults and apportion time246if test -z "$configs_rcutorture"247then248	configs_rcutorture=CFLIST249fi250duration_rcutorture=$((duration_base*duration_rcutorture_frac/10))251if test "$duration_rcutorture" -eq 0252then253	echo " --- Zero time for rcutorture, disabling" | tee -a $T/log254	do_rcutorture=no255fi256 257# Calculate locktorture defaults and apportion time258if test -z "$configs_locktorture"259then260	configs_locktorture=CFLIST261fi262duration_locktorture=$((duration_base*duration_locktorture_frac/10))263if test "$duration_locktorture" -eq 0264then265	echo " --- Zero time for locktorture, disabling" | tee -a $T/log266	do_locktorture=no267fi268 269# Calculate scftorture defaults and apportion time270if test -z "$configs_scftorture"271then272	configs_scftorture=CFLIST273fi274duration_scftorture=$((duration_base*duration_scftorture_frac/10))275if test "$duration_scftorture" -eq 0276then277	echo " --- Zero time for scftorture, disabling" | tee -a $T/log278	do_scftorture=no279fi280 281touch $T/failures282touch $T/successes283 284# torture_one - Does a single kvm.sh run.285#286# Usage:287#	torture_bootargs="[ kernel boot arguments ]"288#	torture_one flavor [ kvm.sh arguments ]289#290# Note that "flavor" is an arbitrary string.  Supply --torture if needed.291# Note that quoting is problematic.  So on the command line, pass multiple292# values with multiple kvm.sh argument instances.293function torture_one {294	local cur_bootargs=295	local boottag=296 297	echo " --- $curflavor:" Start `date` | tee -a $T/log298	if test -n "$torture_bootargs"299	then300		boottag="--bootargs"301		cur_bootargs="$torture_bootargs"302	fi303	"$@" $boottag "$cur_bootargs" --datestamp "$ds/results-$curflavor" > $T/$curflavor.out 2>&1304	retcode=$?305	resdir="`grep '^Results directory: ' $T/$curflavor.out | tail -1 | sed -e 's/^Results directory: //'`"306	if test -z "$resdir"307	then308		cat $T/$curflavor.out | tee -a $T/log309		echo retcode=$retcode | tee -a $T/log310	else311		echo $resdir > $T/last-resdir312	fi313	if test "$retcode" == 0314	then315		echo "$curflavor($retcode)" $resdir >> $T/successes316	else317		echo "$curflavor($retcode)" $resdir >> $T/failures318	fi319}320 321# torture_set - Does a set of tortures with and without KASAN and KCSAN.322#323# Usage:324#	torture_bootargs="[ kernel boot arguments ]"325#	torture_set flavor [ kvm.sh arguments ]326#327# Note that "flavor" is an arbitrary string that does not affect kvm.sh328# in any way.  So also supply --torture if you need something other than329# the default.330function torture_set {331	local cur_kcsan_kmake_args=332	local kcsan_kmake_tag=333	local flavor=$1334	shift335	curflavor=$flavor336	torture_one "$@"337	mv $T/last-resdir $T/last-resdir-nodebug || :338	if test "$do_kasan" = "yes"339	then340		curflavor=${flavor}-kasan341		torture_one "$@" --kasan342		mv $T/last-resdir $T/last-resdir-kasan || :343	fi344	if test "$do_kcsan" = "yes"345	then346		curflavor=${flavor}-kcsan347		if test -n "$kcsan_kmake_args"348		then349			kcsan_kmake_tag="--kmake-args"350			cur_kcsan_kmake_args="$kcsan_kmake_args"351		fi352		torture_one "$@" --kconfig "CONFIG_DEBUG_LOCK_ALLOC=y CONFIG_PROVE_LOCKING=y" $kcsan_kmake_tag $cur_kcsan_kmake_args --kcsan353		mv $T/last-resdir $T/last-resdir-kcsan || :354	fi355}356 357# make allmodconfig358if test "$do_allmodconfig" = "yes"359then360	echo " --- allmodconfig:" Start `date` | tee -a $T/log361	amcdir="tools/testing/selftests/rcutorture/res/$ds/allmodconfig"362	mkdir -p "$amcdir"363	echo " --- make clean" | tee $amcdir/log > "$amcdir/Make.out" 2>&1364	make -j$MAKE_ALLOTED_CPUS clean >> "$amcdir/Make.out" 2>&1365	retcode=$?366	buildphase='"make clean"'367	if test "$retcode" -eq 0368	then369		echo " --- make allmodconfig" | tee -a $amcdir/log >> "$amcdir/Make.out" 2>&1370		cp .config $amcdir371		make -j$MAKE_ALLOTED_CPUS allmodconfig >> "$amcdir/Make.out" 2>&1372		retcode=$?373		buildphase='"make allmodconfig"'374	fi375	if test "$retcode" -eq 0376	then377		echo " --- make " | tee -a $amcdir/log >> "$amcdir/Make.out" 2>&1378		make -j$MAKE_ALLOTED_CPUS >> "$amcdir/Make.out" 2>&1379		retcode="$?"380		echo $retcode > "$amcdir/Make.exitcode"381		buildphase='"make"'382	fi383	if test "$retcode" -eq 0384	then385		echo "allmodconfig($retcode)" $amcdir >> $T/successes386		echo Success >> $amcdir/log387	else388		echo "allmodconfig($retcode)" $amcdir >> $T/failures389		echo " --- allmodconfig Test summary:" >> $amcdir/log390		echo " --- Summary: Exit code $retcode from $buildphase, see Make.out" >> $amcdir/log391	fi392fi393 394# Test building RCU Tasks flavors in isolation, both SMP and !SMP395if test "$do_rcutasksflavors" = "yes"396then397	echo " --- rcutasksflavors:" Start `date` | tee -a $T/log398	rtfdir="tools/testing/selftests/rcutorture/res/$ds/results-rcutasksflavors"399	mkdir -p "$rtfdir"400	cat > $T/rcutasksflavors << __EOF__401#CHECK#CONFIG_TASKS_RCU=n402#CHECK#CONFIG_TASKS_RUDE_RCU=n403#CHECK#CONFIG_TASKS_TRACE_RCU=n404__EOF__405	for flavor in CONFIG_TASKS_RCU CONFIG_TASKS_RUDE_RCU CONFIG_TASKS_TRACE_RCU406	do407		forceflavor="`echo $flavor | sed -e 's/^CONFIG/CONFIG_FORCE/'`"408		deselectedflavors="`grep -v $flavor $T/rcutasksflavors | tr '\012' ' ' | tr -s ' ' | sed -e 's/ *$//'`"409		echo " --- Running RCU Tasks Trace flavor $flavor `date`" >> $rtfdir/log410		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>&1411		retcode=$?412		if test "$retcode" -ne 0413		then414			break415		fi416	done417	if test "$retcode" -eq 0418	then419		echo "rcutasksflavors($retcode)" $rtfdir >> $T/successes420		echo Success >> $rtfdir/log421	else422		echo "rcutasksflavors($retcode)" $rtfdir >> $T/failures423		echo " --- rcutasksflavors Test summary:" >> $rtfdir/log424		echo " --- Summary: Exit code $retcode from $flavor, see Make.out" >> $rtfdir/log425	fi426fi427 428# --torture rcu429if test "$do_rcutorture" = "yes"430then431	torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000"432	torture_set "rcutorture" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration "$duration_rcutorture" --configs "$configs_rcutorture" --trust-make433fi434 435if test "$do_locktorture" = "yes"436then437	torture_bootargs="torture.disable_onoff_at_boot"438	torture_set "locktorture" tools/testing/selftests/rcutorture/bin/kvm.sh --torture lock --allcpus --duration "$duration_locktorture" --configs "$configs_locktorture" --trust-make439fi440 441if test "$do_scftorture" = "yes"442then443	# Scale memory based on the number of CPUs.444	scfmem=$((3+SCALE_ALLOTED_CPUS/16))445	torture_bootargs="scftorture.nthreads=$SCALE_ALLOTED_CPUS torture.disable_onoff_at_boot csdlock_debug=1"446	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-make447fi448 449if test "$do_rt" = "yes"450then451	# With all post-boot grace periods forced to normal.452	torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 rcupdate.rcu_normal=1"453	torture_set "rcurttorture" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration "$duration_rcutorture" --configs "TREE03" --trust-make454 455	# With all post-boot grace periods forced to expedited.456	torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 rcupdate.rcu_expedited=1"457	torture_set "rcurttorture-exp" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration "$duration_rcutorture" --configs "TREE03" --trust-make458fi459 460if test "$do_srcu_lockdep" = "yes"461then462	echo " --- do-srcu-lockdep:" Start `date` | tee -a $T/log463	tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh --datestamp "$ds/results-srcu-lockdep" > $T/srcu_lockdep.sh.out 2>&1464	retcode=$?465	cp $T/srcu_lockdep.sh.out "tools/testing/selftests/rcutorture/res/$ds/results-srcu-lockdep/log"466	if test "$retcode" -eq 0467	then468		echo "srcu_lockdep($retcode)" "tools/testing/selftests/rcutorture/res/$ds/results-srcu-lockdep" >> $T/successes469		echo Success >> "tools/testing/selftests/rcutorture/res/$ds/results-srcu-lockdep/log"470	else471		echo "srcu_lockdep($retcode)" "tools/testing/selftests/rcutorture/res/$ds/results-srcu-lockdep" >> $T/failures472		echo " --- srcu_lockdep Test Summary:" >> "tools/testing/selftests/rcutorture/res/$ds/results-srcu-lockdep/log"473		echo " --- Summary: Exit code $retcode from srcu_lockdep.sh, see ds/results-srcu-lockdep" >> "tools/testing/selftests/rcutorture/res/$ds/results-srcu-lockdep/log"474	fi475fi476 477if test "$do_refscale" = yes478then479	primlist="`grep '\.name[ 	]*=' kernel/rcu/refscale.c | sed -e 's/^[^"]*"//' -e 's/".*$//'`"480else481	primlist=482fi483firsttime=1484do_kasan_save="$do_kasan"485do_kcsan_save="$do_kcsan"486for prim in $primlist487do488	if test -n "$firsttime"489	then490		torture_bootargs="refscale.scale_type="$prim" refscale.nreaders=$SCALE_ALLOTED_CPUS refscale.loops=10000 refscale.holdoff=20 torture.disable_onoff_at_boot"491		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-make492		mv $T/last-resdir-nodebug $T/first-resdir-nodebug || :493		if test -f "$T/last-resdir-kasan"494		then495			mv $T/last-resdir-kasan $T/first-resdir-kasan || :496		fi497		if test -f "$T/last-resdir-kcsan"498		then499			mv $T/last-resdir-kcsan $T/first-resdir-kcsan || :500		fi501		firsttime=502		do_kasan=503		do_kcsan=504	else505		torture_bootargs=506		for i in $T/first-resdir-*507		do508			case "$i" in509			*-nodebug)510				torture_suffix=511				;;512			*-kasan)513				torture_suffix="-kasan"514				;;515			*-kcsan)516				torture_suffix="-kcsan"517				;;518			esac519			torture_set "refscale-$prim$torture_suffix" tools/testing/selftests/rcutorture/bin/kvm-again.sh "`cat "$i"`" --duration 5 --bootargs "refscale.scale_type=$prim"520		done521	fi522done523do_kasan="$do_kasan_save"524do_kcsan="$do_kcsan_save"525 526if test "$do_rcuscale" = yes527then528	primlist="`grep '\.name[ 	]*=' kernel/rcu/rcuscale.c | sed -e 's/^[^"]*"//' -e 's/".*$//'`"529else530	primlist=531fi532firsttime=1533do_kasan_save="$do_kasan"534do_kcsan_save="$do_kcsan"535for prim in $primlist536do537	if test -n "$firsttime"538	then539		torture_bootargs="rcuscale.scale_type="$prim" rcuscale.nwriters=$SCALE_ALLOTED_CPUS rcuscale.holdoff=20 torture.disable_onoff_at_boot"540		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-make541		mv $T/last-resdir-nodebug $T/first-resdir-nodebug || :542		if test -f "$T/last-resdir-kasan"543		then544			mv $T/last-resdir-kasan $T/first-resdir-kasan || :545		fi546		if test -f "$T/last-resdir-kcsan"547		then548			mv $T/last-resdir-kcsan $T/first-resdir-kcsan || :549		fi550		firsttime=551		do_kasan=552		do_kcsan=553	else554		torture_bootargs=555		for i in $T/first-resdir-*556		do557			case "$i" in558			*-nodebug)559				torture_suffix=560				;;561			*-kasan)562				torture_suffix="-kasan"563				;;564			*-kcsan)565				torture_suffix="-kcsan"566				;;567			esac568			torture_set "rcuscale-$prim$torture_suffix" tools/testing/selftests/rcutorture/bin/kvm-again.sh "`cat "$i"`" --duration 5 --bootargs "rcuscale.scale_type=$prim"569		done570	fi571done572do_kasan="$do_kasan_save"573do_kcsan="$do_kcsan_save"574 575if test "$do_kvfree" = "yes"576then577	torture_bootargs="rcuscale.kfree_rcu_test=1 rcuscale.kfree_nthreads=16 rcuscale.holdoff=20 rcuscale.kfree_loops=10000 torture.disable_onoff_at_boot"578	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-make579fi580 581if test "$do_clocksourcewd" = "yes"582then583	torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 tsc=watchdog"584	torture_set "clocksourcewd-1" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 45s --configs TREE03 --kconfig "CONFIG_TEST_CLOCKSOURCE_WATCHDOG=y" --trust-make585 586	torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 tsc=watchdog"587	torture_set "clocksourcewd-2" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 45s --configs TREE03 --kconfig "CONFIG_TEST_CLOCKSOURCE_WATCHDOG=y" --trust-make588 589	# In case our work is already done...590	if test "$do_rcutorture" != "yes"591	then592		torture_bootargs="rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot rcupdate.rcu_task_stall_timeout=30000 tsc=watchdog"593		torture_set "clocksourcewd-3" tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 45s --configs TREE03 --trust-make594	fi595fi596 597echo " --- " $scriptname $args598echo " --- " Done `date` | tee -a $T/log599ret=0600nsuccesses=0601echo SUCCESSES: | tee -a $T/log602if test -s "$T/successes"603then604	cat "$T/successes" | tee -a $T/log605	nsuccesses="`wc -l "$T/successes" | awk '{ print $1 }'`"606fi607nfailures=0608echo FAILURES: | tee -a $T/log609if test -s "$T/failures"610then611	awk < "$T/failures" -v sq="'" '{ print "echo " sq $0 sq; print "sed -e " sq "1,/^ --- .* Test summary:$/d" sq " " $2 "/log | grep Summary: | sed -e " sq "s/^[^S]*/  /" sq; }' | sh | tee -a $T/log | tee "$T/failuresum"612	nfailures="`wc -l "$T/failures" | awk '{ print $1 }'`"613	grep "^  Summary: " "$T/failuresum" |614		grep -v '^  Summary: Bugs: [0-9]* (all bugs kcsan)$' > "$T/nonkcsan"615	if test -s "$T/nonkcsan"616	then617		nonkcsanbug="yes"618	fi619	ret=2620fi621if test "$do_kcsan" = "yes"622then623	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.sum624fi625echo Started at $startdate, ended at `date`, duration `get_starttime_duration $starttime`. | tee -a $T/log626echo Summary: Successes: $nsuccesses Failures: $nfailures. | tee -a $T/log627tdir="`cat $T/successes $T/failures | head -1 | awk '{ print $NF }' | sed -e 's,/[^/]\+/*$,,'`"628find "$tdir" -name 'ConfigFragment.diags' -print > $T/configerrors629find "$tdir" -name 'Make.out.diags' -print > $T/builderrors630if test -s "$T/configerrors"631then632	echo "  Scenarios with .config errors: `wc -l "$T/configerrors" | awk '{ print $1 }'`"633	nonkcsanbug="yes"634fi635if test -s "$T/builderrors"636then637	echo "  Scenarios with build errors: `wc -l "$T/builderrors" | awk '{ print $1 }'`"638	nonkcsanbug="yes"639fi640if test -z "$nonkcsanbug" && test -s "$T/failuresum"641then642	echo "  All bugs were KCSAN failures."643fi644if test -n "$tdir" && test $compress_concurrency -gt 0645then646	# KASAN vmlinux files can approach 1GB in size, so compress them.647	echo Looking for K[AC]SAN files to compress: `date` > "$tdir/log-xz" 2>&1648	find "$tdir" -type d -name '*-k[ac]san' -print > $T/xz-todo-all649	find "$tdir" -type f -name 're-run' -print | sed -e 's,/re-run,,' |650		grep -e '-k[ac]san$' > $T/xz-todo-copy651	sort $T/xz-todo-all $T/xz-todo-copy | uniq -u > $T/xz-todo652	ncompresses=0653	batchno=1654	if test -s $T/xz-todo655	then656		for i in `cat $T/xz-todo`657		do658			find $i -name 'vmlinux*' -print659		done | wc -l | awk '{ print $1 }' > $T/xz-todo-count660		n2compress="`cat $T/xz-todo-count`"661		echo Size before compressing $n2compress files: `du -sh $tdir | awk '{ print $1 }'` `date` 2>&1 | tee -a "$tdir/log-xz" | tee -a $T/log662		for i in `cat $T/xz-todo`663		do664			echo Compressing vmlinux files in ${i}: `date` >> "$tdir/log-xz" 2>&1665			for j in $i/*/vmlinux666			do667				xz "$j" >> "$tdir/log-xz" 2>&1 &668				ncompresses=$((ncompresses+1))669				if test $ncompresses -ge $compress_concurrency670				then671					echo Waiting for batch $batchno of $ncompresses compressions `date` | tee -a "$tdir/log-xz" | tee -a $T/log672					wait673					ncompresses=0674					batchno=$((batchno+1))675				fi676			done677		done678		if test $ncompresses -gt 0679		then680			echo Waiting for final batch $batchno of $ncompresses compressions `date` | tee -a "$tdir/log-xz" | tee -a $T/log681		fi682		wait683		if test -s $T/xz-todo-copy684		then685			# The trick here is that we need corresponding686			# vmlinux files from corresponding scenarios.687			echo Linking vmlinux.xz files to re-use scenarios `date` | tee -a "$tdir/log-xz" | tee -a $T/log688			dirstash="`pwd`"689			for i in `cat $T/xz-todo-copy`690			do691				cd $i692				find . -name vmlinux -print > $T/xz-todo-copy-vmlinux693				for v in `cat $T/xz-todo-copy-vmlinux`694				do695					rm -f "$v"696					cp -l `cat $i/re-run`/"$i/$v".xz "`dirname "$v"`"697				done698				cd "$dirstash"699			done700		fi701		echo Size after compressing $n2compress files: `du -sh $tdir | awk '{ print $1 }'` `date` 2>&1 | tee -a "$tdir/log-xz" | tee -a $T/log702		echo Total duration `get_starttime_duration $starttime`. | tee -a $T/log703	else704		echo No compression needed: `date` >> "$tdir/log-xz" 2>&1705	fi706fi707if test -n "$tdir"708then709	cp $T/log "$tdir"710fi711exit $ret712