Commit b22eb7ce authored by Paul E. McKenney's avatar Paul E. McKenney
Browse files

torture: Hoist calls to lscpu to higher-level kvm.sh script



On some kernels, concurrent calls to the lscpu command result in severe
slowdowns.  For example, on v4.16, a single lscpu invocation takes about
two milliseconds, four concurrent invocations more than two seconds,
and 16 concurrent invocations more than 20 seconds.  Given that the only
goal is to learn the number of CPUs, invoking lscpu but once suffices.
This commit therefore invokes lscpu early in kvm.sh execution, setting
the initial value of the TORTURE_ALLOTED_CPUS environment variable.

Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
parent 25b4da74
Loading
Loading
Loading
Loading
+3 −4
Original line number Original line Diff line number Diff line
@@ -133,11 +133,10 @@ fi
qemu_args="-enable-kvm -nographic $qemu_args"
qemu_args="-enable-kvm -nographic $qemu_args"
cpu_count=`configNR_CPUS.sh $resdir/ConfigFragment`
cpu_count=`configNR_CPUS.sh $resdir/ConfigFragment`
cpu_count=`configfrag_boot_cpus "$boot_args" "$config_template" "$cpu_count"`
cpu_count=`configfrag_boot_cpus "$boot_args" "$config_template" "$cpu_count"`
vcpus=`identify_qemu_vcpus`
if test "$cpu_count" -gt "$TORTURE_ALLOTED_CPUS"
if test $cpu_count -gt $vcpus
then
then
	echo CPU count limited from $cpu_count to $vcpus | tee -a $resdir/Warnings
	echo CPU count limited from $cpu_count to $TORTURE_ALLOTED_CPUS | tee -a $resdir/Warnings
	cpu_count=$vcpus
	cpu_count=$TORTURE_ALLOTED_CPUS
fi
fi
qemu_args="`specify_qemu_cpus "$QEMU" "$qemu_args" "$cpu_count"`"
qemu_args="`specify_qemu_cpus "$QEMU" "$qemu_args" "$cpu_count"`"


+8 −3
Original line number Original line Diff line number Diff line
@@ -24,7 +24,9 @@ dur=$((30*60))
dryrun=""
dryrun=""
KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
PATH=${KVM}/bin:$PATH; export PATH
PATH=${KVM}/bin:$PATH; export PATH
TORTURE_ALLOTED_CPUS=""
. functions.sh

TORTURE_ALLOTED_CPUS="`identify_qemu_vcpus`"
TORTURE_DEFCONFIG=defconfig
TORTURE_DEFCONFIG=defconfig
TORTURE_BOOT_IMAGE=""
TORTURE_BOOT_IMAGE=""
TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
@@ -40,8 +42,6 @@ cpus=0
ds=`date +%Y.%m.%d-%H:%M:%S`
ds=`date +%Y.%m.%d-%H:%M:%S`
jitter="-1"
jitter="-1"


. functions.sh

usage () {
usage () {
	echo "Usage: $scriptname optional arguments:"
	echo "Usage: $scriptname optional arguments:"
	echo "       --bootargs kernel-boot-arguments"
	echo "       --bootargs kernel-boot-arguments"
@@ -93,6 +93,11 @@ do
		checkarg --cpus "(number)" "$#" "$2" '^[0-9]*$' '^--'
		checkarg --cpus "(number)" "$#" "$2" '^[0-9]*$' '^--'
		cpus=$2
		cpus=$2
		TORTURE_ALLOTED_CPUS="$2"
		TORTURE_ALLOTED_CPUS="$2"
		max_cpus="`identify_qemu_vcpus`"
		if test "$TORTURE_ALLOTED_CPUS" -gt "$max_cpus"
		then
			TORTURE_ALLOTED_CPUS=$max_cpus
		fi
		shift
		shift
		;;
		;;
	--datestamp)
	--datestamp)