Skip to content

Commit 9aa55ec

Browse files
committed
rcutorture: Dispense with Dracut for initrd creation
The dracut scripting does not work on all platforms, and there are no known failures from the init binary based on the statically linked C program. This commit therefore removes the dracut scripting so that the statically linked C program is always used to create the init "script". Signed-off-by: Paul E. McKenney <[email protected]>
1 parent c493f1c commit 9aa55ec

File tree

1 file changed

+3
-52
lines changed

1 file changed

+3
-52
lines changed

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

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -20,58 +20,9 @@ if [ -s "$D/initrd/init" ]; then
2020
exit 0
2121
fi
2222

23-
T=${TMPDIR-/tmp}/mkinitrd.sh.$$
24-
trap 'rm -rf $T' 0 2
25-
mkdir $T
26-
27-
cat > $T/init << '__EOF___'
28-
#!/bin/sh
29-
# Run in userspace a few milliseconds every second. This helps to
30-
# exercise the NO_HZ_FULL portions of RCU. The 192 instances of "a" was
31-
# empirically shown to give a nice multi-millisecond burst of user-mode
32-
# execution on a 2GHz CPU, as desired. Modern CPUs will vary from a
33-
# couple of milliseconds up to perhaps 100 milliseconds, which is an
34-
# acceptable range.
35-
#
36-
# Why not calibrate an exact delay? Because within this initrd, we
37-
# are restricted to Bourne-shell builtins, which as far as I know do not
38-
# provide any means of obtaining a fine-grained timestamp.
39-
40-
a4="a a a a"
41-
a16="$a4 $a4 $a4 $a4"
42-
a64="$a16 $a16 $a16 $a16"
43-
a192="$a64 $a64 $a64"
44-
while :
45-
do
46-
q=
47-
for i in $a192
48-
do
49-
q="$q $i"
50-
done
51-
sleep 1
52-
done
53-
__EOF___
54-
55-
# Try using dracut to create initrd
56-
if command -v dracut >/dev/null 2>&1
57-
then
58-
echo Creating $D/initrd using dracut.
59-
# Filesystem creation
60-
dracut --force --no-hostonly --no-hostonly-cmdline --module "base" $T/initramfs.img
61-
cd $D
62-
mkdir -p initrd
63-
cd initrd
64-
zcat $T/initramfs.img | cpio -id
65-
cp $T/init init
66-
chmod +x init
67-
echo Done creating $D/initrd using dracut
68-
exit 0
69-
fi
70-
71-
# No dracut, so create a C-language initrd/init program and statically
72-
# link it. This results in a very small initrd, but might be a bit less
73-
# future-proof than dracut.
74-
echo "Could not find dracut, attempting C initrd"
23+
# Create a C-language initrd/init infinite-loop program and statically
24+
# link it. This results in a very small initrd.
25+
echo "Creating a statically linked C-language initrd"
7526
cd $D
7627
mkdir -p initrd
7728
cd initrd

0 commit comments

Comments
 (0)