Skip to content

Commit b22eb7c

Browse files
committed
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: Paul E. McKenney <[email protected]>
1 parent 25b4da7 commit b22eb7c

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,10 @@ fi
133133
qemu_args="-enable-kvm -nographic $qemu_args"
134134
cpu_count=`configNR_CPUS.sh $resdir/ConfigFragment`
135135
cpu_count=`configfrag_boot_cpus "$boot_args" "$config_template" "$cpu_count"`
136-
vcpus=`identify_qemu_vcpus`
137-
if test $cpu_count -gt $vcpus
136+
if test "$cpu_count" -gt "$TORTURE_ALLOTED_CPUS"
138137
then
139-
echo CPU count limited from $cpu_count to $vcpus | tee -a $resdir/Warnings
140-
cpu_count=$vcpus
138+
echo CPU count limited from $cpu_count to $TORTURE_ALLOTED_CPUS | tee -a $resdir/Warnings
139+
cpu_count=$TORTURE_ALLOTED_CPUS
141140
fi
142141
qemu_args="`specify_qemu_cpus "$QEMU" "$qemu_args" "$cpu_count"`"
143142

tools/testing/selftests/rcutorture/bin/kvm.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ dur=$((30*60))
2424
dryrun=""
2525
KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
2626
PATH=${KVM}/bin:$PATH; export PATH
27-
TORTURE_ALLOTED_CPUS=""
27+
. functions.sh
28+
29+
TORTURE_ALLOTED_CPUS="`identify_qemu_vcpus`"
2830
TORTURE_DEFCONFIG=defconfig
2931
TORTURE_BOOT_IMAGE=""
3032
TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
@@ -40,8 +42,6 @@ cpus=0
4042
ds=`date +%Y.%m.%d-%H:%M:%S`
4143
jitter="-1"
4244

43-
. functions.sh
44-
4545
usage () {
4646
echo "Usage: $scriptname optional arguments:"
4747
echo " --bootargs kernel-boot-arguments"
@@ -93,6 +93,11 @@ do
9393
checkarg --cpus "(number)" "$#" "$2" '^[0-9]*$' '^--'
9494
cpus=$2
9595
TORTURE_ALLOTED_CPUS="$2"
96+
max_cpus="`identify_qemu_vcpus`"
97+
if test "$TORTURE_ALLOTED_CPUS" -gt "$max_cpus"
98+
then
99+
TORTURE_ALLOTED_CPUS=$max_cpus
100+
fi
96101
shift
97102
;;
98103
--datestamp)

0 commit comments

Comments
 (0)