Skip to content

Commit 0bca7c3

Browse files
committed
torture: Use elapsed time to detect hangs
The kvm-test-1-run.sh currently counts "sleep 1" commands to detect hangs. This can fail spectacularly on busy systems, where "sleep 1" might take far longer than one second to complete. This commit therefore changes hang detection to use elapsed time measurements. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org>
1 parent d0d0606 commit 0bca7c3

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

‎tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,18 @@ fi
167167
qemu_pid=$!
168168
commandcompleted=0
169169
echo Monitoring qemu job at pid $qemu_pid
170-
for ((i=0;i<$seconds;i++))
170+
while :
171171
do
172+
kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null`
172173
if kill -0 $qemu_pid > /dev/null 2>&1
173174
then
175+
if test $kruntime -ge $seconds
176+
then
177+
break;
178+
fi
174179
sleep 1
175180
else
176181
commandcompleted=1
177-
kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null`
178182
if test $kruntime -lt $seconds
179183
then
180184
echo Completed in $kruntime vs. $seconds >> $resdir/Warnings 2>&1
@@ -194,20 +198,22 @@ done
194198
if test $commandcompleted -eq 0
195199
then
196200
echo Grace period for qemu job at pid $qemu_pid
197-
for ((i=0;i<=$grace;i++))
201+
while :
198202
do
203+
kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null`
199204
if kill -0 $qemu_pid > /dev/null 2>&1
200205
then
201-
sleep 1
206+
:
202207
else
203208
break
204209
fi
205-
if test $i -eq $grace
210+
if test $kruntime -ge $((seconds + grace))
206211
then
207-
kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }'`
208212
echo "!!! Hang at $kruntime vs. $seconds seconds" >> $resdir/Warnings 2>&1
209213
kill -KILL $qemu_pid
214+
break
210215
fi
216+
sleep 1
211217
done
212218
fi
213219

0 commit comments

Comments
 (0)