torture: Run kernel build in source directory

For historical reasons, rcutorture places its build products in a
tools/testing/selftests/rcutorture/b1 directory using the O= kbuild
command-line argument.  However, doing this requires that the source
directory be pristine: Not just "make clean" pristine, but instead "make
mrproper" (or, equivalently, "make distclean") pristine.  Therefore,
rcutorture executes a "make mrproper" before each build.  Unfortunately,
"make mrproper" has the side effect of removing pretty much everything,
including tags files and cscope databases, which can be inconvenient
to people whose workflow centers around a single source tree.

This commit therefore makes rcutorture do the build directly in the
source directory, removing the need for "make mrproper".  This works
because all needed build products are moved to their proper place in the
"res" directory immediately after the build completes, so that multiple
rcutorture kernels can still run concurrently.

Reported-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
This commit is contained in:
Paul E. McKenney 2019-05-10 21:31:52 -07:00
parent cd6cb7c8a5
commit 6dc82595ef
4 changed files with 22 additions and 47 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# SPDX-License-Identifier: GPL-2.0+ # SPDX-License-Identifier: GPL-2.0+
# #
# Usage: configinit.sh config-spec-file build-output-dir results-dir # Usage: configinit.sh config-spec-file results-dir
# #
# Create a .config file from the spec file. Run from the kernel source tree. # Create a .config file from the spec file. Run from the kernel source tree.
# Exits with 0 if all went well, with 1 if all went well but the config # Exits with 0 if all went well, with 1 if all went well but the config
@ -11,10 +11,6 @@
# desired settings, for example, "CONFIG_NO_HZ=y". For best results, # desired settings, for example, "CONFIG_NO_HZ=y". For best results,
# this should be a full pathname. # this should be a full pathname.
# #
# The second argument is a optional path to a build output directory,
# for example, "O=/tmp/foo". If this argument is omitted, the .config
# file will be generated directly in the current directory.
#
# Copyright (C) IBM Corporation, 2013 # Copyright (C) IBM Corporation, 2013
# #
# Authors: Paul E. McKenney <paulmck@linux.ibm.com> # Authors: Paul E. McKenney <paulmck@linux.ibm.com>
@ -26,34 +22,20 @@ mkdir $T
# Capture config spec file. # Capture config spec file.
c=$1 c=$1
buildloc=$2 resdir=$2
resdir=$3
builddir=
if echo $buildloc | grep -q '^O='
then
builddir=`echo $buildloc | sed -e 's/^O=//'`
if test ! -d $builddir
then
mkdir $builddir
fi
else
echo Bad build directory: \"$buildloc\"
exit 2
fi
sed -e 's/^\(CONFIG[0-9A-Z_]*\)=.*$/grep -v "^# \1" |/' < $c > $T/u.sh sed -e 's/^\(CONFIG[0-9A-Z_]*\)=.*$/grep -v "^# \1" |/' < $c > $T/u.sh
sed -e 's/^\(CONFIG[0-9A-Z_]*=\).*$/grep -v \1 |/' < $c >> $T/u.sh sed -e 's/^\(CONFIG[0-9A-Z_]*=\).*$/grep -v \1 |/' < $c >> $T/u.sh
grep '^grep' < $T/u.sh > $T/upd.sh grep '^grep' < $T/u.sh > $T/upd.sh
echo "cat - $c" >> $T/upd.sh echo "cat - $c" >> $T/upd.sh
make mrproper make clean > $resdir/Make.clean 2>&1
make $buildloc distclean > $resdir/Make.distclean 2>&1 make $TORTURE_DEFCONFIG > $resdir/Make.defconfig.out 2>&1
make $buildloc $TORTURE_DEFCONFIG > $resdir/Make.defconfig.out 2>&1 mv .config .config.sav
mv $builddir/.config $builddir/.config.sav sh $T/upd.sh < .config.sav > .config
sh $T/upd.sh < $builddir/.config.sav > $builddir/.config cp .config .config.new
cp $builddir/.config $builddir/.config.new yes '' | make oldconfig > $resdir/Make.oldconfig.out 2> $resdir/Make.oldconfig.err
yes '' | make $buildloc oldconfig > $resdir/Make.oldconfig.out 2> $resdir/Make.oldconfig.err
# verify new config matches specification. # verify new config matches specification.
configcheck.sh $builddir/.config $c configcheck.sh .config $c
exit 0 exit 0

View File

@ -3,7 +3,7 @@
# #
# Build a kvm-ready Linux kernel from the tree in the current directory. # Build a kvm-ready Linux kernel from the tree in the current directory.
# #
# Usage: kvm-build.sh config-template build-dir resdir # Usage: kvm-build.sh config-template resdir
# #
# Copyright (C) IBM Corporation, 2011 # Copyright (C) IBM Corporation, 2011
# #
@ -15,8 +15,7 @@ then
echo "kvm-build.sh :$config_template: Not a readable file" echo "kvm-build.sh :$config_template: Not a readable file"
exit 1 exit 1
fi fi
builddir=${2} resdir=${2}
resdir=${3}
T=${TMPDIR-/tmp}/test-linux.sh.$$ T=${TMPDIR-/tmp}/test-linux.sh.$$
trap 'rm -rf $T' 0 trap 'rm -rf $T' 0
@ -29,14 +28,14 @@ CONFIG_VIRTIO_PCI=y
CONFIG_VIRTIO_CONSOLE=y CONFIG_VIRTIO_CONSOLE=y
___EOF___ ___EOF___
configinit.sh $T/config O=$builddir $resdir configinit.sh $T/config $resdir
retval=$? retval=$?
if test $retval -gt 1 if test $retval -gt 1
then then
exit 2 exit 2
fi fi
ncpus=`cpus2use.sh` ncpus=`cpus2use.sh`
make O=$builddir -j$ncpus $TORTURE_KMAKE_ARG > $resdir/Make.out 2>&1 make -j$ncpus $TORTURE_KMAKE_ARG > $resdir/Make.out 2>&1
retval=$? retval=$?
if test $retval -ne 0 || grep "rcu[^/]*": < $resdir/Make.out | egrep -q "Stop|Error|error:|warning:" || egrep -q "Stop|Error|error:" < $resdir/Make.out if test $retval -ne 0 || grep "rcu[^/]*": < $resdir/Make.out | egrep -q "Stop|Error|error:|warning:" || egrep -q "Stop|Error|error:" < $resdir/Make.out
then then

View File

@ -36,11 +36,6 @@ config_template=${1}
config_dir=`echo $config_template | sed -e 's,/[^/]*$,,'` config_dir=`echo $config_template | sed -e 's,/[^/]*$,,'`
title=`echo $config_template | sed -e 's/^.*\///'` title=`echo $config_template | sed -e 's/^.*\///'`
builddir=${2} builddir=${2}
if test -z "$builddir" -o ! -d "$builddir" -o ! -w "$builddir"
then
echo "kvm-test-1-run.sh :$builddir: Not a writable directory, cannot build into it"
exit 1
fi
resdir=${3} resdir=${3}
if test -z "$resdir" -o ! -d "$resdir" -o ! -w "$resdir" if test -z "$resdir" -o ! -d "$resdir" -o ! -w "$resdir"
then then
@ -85,18 +80,18 @@ then
ln -s $base_resdir/.config $resdir # for kvm-recheck.sh ln -s $base_resdir/.config $resdir # for kvm-recheck.sh
# Arch-independent indicator # Arch-independent indicator
touch $resdir/builtkernel touch $resdir/builtkernel
elif kvm-build.sh $T/Kc2 $builddir $resdir elif kvm-build.sh $T/Kc2 $resdir
then then
# Had to build a kernel for this test. # Had to build a kernel for this test.
QEMU="`identify_qemu $builddir/vmlinux`" QEMU="`identify_qemu vmlinux`"
BOOT_IMAGE="`identify_boot_image $QEMU`" BOOT_IMAGE="`identify_boot_image $QEMU`"
cp $builddir/vmlinux $resdir cp vmlinux $resdir
cp $builddir/.config $resdir cp .config $resdir
cp $builddir/Module.symvers $resdir > /dev/null || : cp Module.symvers $resdir > /dev/null || :
cp $builddir/System.map $resdir > /dev/null || : cp System.map $resdir > /dev/null || :
if test -n "$BOOT_IMAGE" if test -n "$BOOT_IMAGE"
then then
cp $builddir/$BOOT_IMAGE $resdir cp $BOOT_IMAGE $resdir
KERNEL=$resdir/${BOOT_IMAGE##*/} KERNEL=$resdir/${BOOT_IMAGE##*/}
# Arch-independent indicator # Arch-independent indicator
touch $resdir/builtkernel touch $resdir/builtkernel
@ -107,7 +102,7 @@ then
parse-build.sh $resdir/Make.out $title parse-build.sh $resdir/Make.out $title
else else
# Build failed. # Build failed.
cp $builddir/.config $resdir || : cp .config $resdir || :
echo Build failed, not running KVM, see $resdir. echo Build failed, not running KVM, see $resdir.
if test -f $builddir.wait if test -f $builddir.wait
then then

View File

@ -342,7 +342,7 @@ function dump(first, pastlast, batchnum)
print "needqemurun=" print "needqemurun="
jn=1 jn=1
for (j = first; j < pastlast; j++) { for (j = first; j < pastlast; j++) {
builddir=KVM "/b1" builddir=KVM "/b" j - first + 1
cpusr[jn] = cpus[j]; cpusr[jn] = cpus[j];
if (cfrep[cf[j]] == "") { if (cfrep[cf[j]] == "") {
cfr[jn] = cf[j]; cfr[jn] = cf[j];
@ -358,7 +358,6 @@ function dump(first, pastlast, batchnum)
print "echo ", cfr[jn], cpusr[jn] ovf ": Starting build. `date` | tee -a " rd "log"; print "echo ", cfr[jn], cpusr[jn] ovf ": Starting build. `date` | tee -a " rd "log";
print "rm -f " builddir ".*"; print "rm -f " builddir ".*";
print "touch " builddir ".wait"; print "touch " builddir ".wait";
print "mkdir " builddir " > /dev/null 2>&1 || :";
print "mkdir " rd cfr[jn] " || :"; print "mkdir " rd cfr[jn] " || :";
print "kvm-test-1-run.sh " CONFIGDIR cf[j], builddir, rd cfr[jn], dur " \"" TORTURE_QEMU_ARG "\" \"" TORTURE_BOOTARGS "\" > " rd cfr[jn] "/kvm-test-1-run.sh.out 2>&1 &" print "kvm-test-1-run.sh " CONFIGDIR cf[j], builddir, rd cfr[jn], dur " \"" TORTURE_QEMU_ARG "\" \"" TORTURE_BOOTARGS "\" > " rd cfr[jn] "/kvm-test-1-run.sh.out 2>&1 &"
print "echo ", cfr[jn], cpusr[jn] ovf ": Waiting for build to complete. `date` | tee -a " rd "log"; print "echo ", cfr[jn], cpusr[jn] ovf ": Waiting for build to complete. `date` | tee -a " rd "log";