]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
torture: Do Kconfig analysis only once per scenario
authorPaul E. McKenney <paulmck@kernel.org>
Thu, 24 Dec 2020 23:28:14 +0000 (15:28 -0800)
committerPaul E. McKenney <paulmck@kernel.org>
Tue, 5 Jan 2021 19:33:20 +0000 (11:33 -0800)
Currently, if a scenario is repeated as in "--configs '4*TREE01'",
the Kconfig analysis is performed for each occurrance (four times in
this example) and each analysis places the exact same data into the
exact same files.  This is not really an issue in this repetition-four
example, but it can needlessly consume tens of seconds of wallclock time
for something like "--config '128*TINY01'".

This commit therefore does Kconfig analysis only once per set of
repeats of a given scenario, courtesy of the "sort -u" command and an
automatically generated awk script.

While in the area, this commit also wordsmiths a comment.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
tools/testing/selftests/rcutorture/bin/kvm.sh

index 605186888fd90ccf073e35b4918ce11f04a2a53f..8d3c99b35e06032da71711b0f2b7d3d141da61a2 100755 (executable)
@@ -286,7 +286,8 @@ then
                exit 1
        fi
 fi
-for CF1 in $configs_derep
+echo 'BEGIN {' > $T/cfgcpu.awk
+for CF1 in `echo $configs_derep | tr -s ' ' '\012' | sort -u`
 do
        if test -f "$CONFIGFRAG/$CF1"
        then
@@ -299,12 +300,20 @@ do
                fi
                cpu_count=`configfrag_boot_cpus "$TORTURE_BOOTARGS" "$CONFIGFRAG/$CF1" "$cpu_count"`
                cpu_count=`configfrag_boot_maxcpus "$TORTURE_BOOTARGS" "$CONFIGFRAG/$CF1" "$cpu_count"`
-               echo $CF1 $cpu_count >> $T/cfgcpu
+               echo 'scenariocpu["'"$CF1"'"] = '"$cpu_count"';' >> $T/cfgcpu.awk
        else
                echo "The --configs file $CF1 does not exist, terminating."
                exit 1
        fi
 done
+cat << '___EOF___' >> $T/cfgcpu.awk
+}
+{
+       for (i = 1; i <= NF; i++)
+               print $i, scenariocpu[$i];
+}
+___EOF___
+echo $configs_derep | awk -f $T/cfgcpu.awk > $T/cfgcpu
 sort -k2nr $T/cfgcpu -T="$T" > $T/cfgcpu.sort
 
 # Use a greedy bin-packing algorithm, sorting the list accordingly.
@@ -324,11 +333,10 @@ END {
        batch = 0;
        nc = -1;
 
-       # Each pass through the following loop creates on test batch
-       # that can be executed concurrently given ncpus.  Note that a
-       # given test that requires more than the available CPUs will run in
-       # their own batch.  Such tests just have to make do with what
-       # is available.
+       # Each pass through the following loop creates on test batch that
+       # can be executed concurrently given ncpus.  Note that a given test
+       # that requires more than the available CPUs will run in its own
+       # batch.  Such tests just have to make do with what is available.
        while (nc != ncpus) {
                batch++;
                nc = ncpus;