rcutorture: Avoid torture.sh compressing identical files
authorPaul E. McKenney <paulmck@kernel.org>
Tue, 30 Aug 2022 18:52:13 +0000 (11:52 -0700)
committerPaul E. McKenney <paulmck@kernel.org>
Thu, 20 Oct 2022 22:28:38 +0000 (15:28 -0700)
Currently, torture.sh will compress the vmlinux files for KASAN and
KCSAN runs.  But it will compress all of the files, including those
copied verbatim by the kvm-again.sh script.  Compression takes around ten
minutes, so this is not a good thing.  This commit therefore compresses
only one of a given set of identical vmlinux files, and then hard-links
it to the directories produced by kvm-again.sh.

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

index b376688..a0be345 100755 (executable)
@@ -536,7 +536,10 @@ if test -n "$tdir" && test $compress_concurrency -gt 0
 then
        # KASAN vmlinux files can approach 1GB in size, so compress them.
        echo Looking for K[AC]SAN files to compress: `date` > "$tdir/log-xz" 2>&1
-       find "$tdir" -type d -name '*-k[ac]san' -print > $T/xz-todo
+       find "$tdir" -type d -name '*-k[ac]san' -print > $T/xz-todo-all
+       find "$tdir" -type f -name 're-run' -print | sed -e 's,/re-run,,' |
+               grep -e '-k[ac]san$' > $T/xz-todo-copy
+       sort $T/xz-todo-all $T/xz-todo-copy | uniq -u > $T/xz-todo
        ncompresses=0
        batchno=1
        if test -s $T/xz-todo
@@ -568,6 +571,24 @@ then
                        echo Waiting for final batch $batchno of $ncompresses compressions `date` | tee -a "$tdir/log-xz" | tee -a $T/log
                fi
                wait
+               if test -s $T/xz-todo-copy
+               then
+                       # The trick here is that we need corresponding
+                       # vmlinux files from corresponding scenarios.
+                       echo Linking vmlinux.xz files to re-use scenarios `date` | tee -a "$tdir/log-xz" | tee -a $T/log
+                       dirstash="`pwd`"
+                       for i in `cat $T/xz-todo-copy`
+                       do
+                               cd $i
+                               find . -name vmlinux -print > $T/xz-todo-copy-vmlinux
+                               for v in `cat $T/xz-todo-copy-vmlinux`
+                               do
+                                       rm -f "$v"
+                                       cp -l `cat $i/re-run`/"$i/$v".xz "`dirname "$v"`"
+                               done
+                               cd "$dirstash"
+                       done
+               fi
                echo Size after compressing $n2compress files: `du -sh $tdir | awk '{ print $1 }'` `date` 2>&1 | tee -a "$tdir/log-xz" | tee -a $T/log
                echo Total duration `get_starttime_duration $starttime`. | tee -a $T/log
        else