Commit 229ab0cb authored by Paul E. McKenney's avatar Paul E. McKenney Committed by Paul E. McKenney

rcutorture: Make initrd/init execute in userspace

Currently, the initrd/init script and executable remain blocked almost
all the time.  However, it is necessary to test nohz_full userspace
execution, which both variants of initrd/init fail to do.  This commit
therefore causes initrd/init to spend about a millisecond per second
executing in userspace.
Reported-by: default avatarJosh Triplett <josh@joshtriplett.org>
Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
parent 38e63042
...@@ -39,9 +39,22 @@ mkdir $T ...@@ -39,9 +39,22 @@ mkdir $T
cat > $T/init << '__EOF___' cat > $T/init << '__EOF___'
#!/bin/sh #!/bin/sh
# Run in userspace a few milliseconds every second. This helps to
# exercise the NO_HZ_FULL portions of RCU.
while : while :
do do
sleep 1000000 q=
for i in \
a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a \
a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a \
a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a \
a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a \
a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a \
a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
do
q="$q $i"
done
sleep 1
done done
__EOF___ __EOF___
...@@ -70,15 +83,37 @@ mkdir initrd ...@@ -70,15 +83,37 @@ mkdir initrd
cd initrd cd initrd
cat > init.c << '___EOF___' cat > init.c << '___EOF___'
#include <unistd.h> #include <unistd.h>
#include <sys/time.h>
volatile unsigned long delaycount;
int main(int argc, int argv[]) int main(int argc, int argv[])
{ {
for (;;) int i;
sleep(1000*1000*1000); /* One gigasecond is ~30 years. */ struct timeval tv;
struct timeval tvb;
for (;;) {
sleep(1);
/* Need some userspace time. */
if (gettimeofday(&tvb, NULL))
continue;
do {
for (i = 0; i < 1000 * 100; i++)
delaycount = i * i;
if (gettimeofday(&tv, NULL))
break;
tv.tv_sec -= tvb.tv_sec;
if (tv.tv_sec > 1)
break;
tv.tv_usec += tv.tv_sec * 1000 * 1000;
tv.tv_usec -= tvb.tv_usec;
} while (tv.tv_usec < 1000);
}
return 0; return 0;
} }
___EOF___ ___EOF___
gcc -static -Os -o init init.c cc -static -Os -o init init.c
strip init strip init
rm init.c rm init.c
echo "Done creating a statically linked C-language initrd" echo "Done creating a statically linked C-language initrd"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment