Skip to content

Commit e95f6cc

Browse files
committed
rcutorture: Fix jitter.sh spin time
An embarrassing syntax error in jitter.sh makes for fixed spin time. This commit therefore makes it be variable, as intended, albeit with very coarse-grained adjustment. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
1 parent 61399e0 commit e95f6cc

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

  • tools/testing/selftests/rcutorture/bin

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ do
3939
fi
4040
done
4141

42+
# Uses global variables startsecs, startns, endsecs, endns, and limit.
43+
# Exit code is success for time not yet elapsed and failure otherwise.
44+
function timecheck {
45+
local done=`awk -v limit=$limit \
46+
-v startsecs=$startsecs \
47+
-v startns=$startns \
48+
-v endsecs=$endsecs \
49+
-v endns=$endns < /dev/null '
50+
BEGIN {
51+
delta = (endsecs - startsecs) * 1000 * 1000;
52+
delta += int((endns - startns) / 1000);
53+
print delta >= limit;
54+
}'`
55+
return $done
56+
}
57+
4258
while :
4359
do
4460
# Check for done.
@@ -85,15 +101,20 @@ do
85101
n=$(($n+1))
86102
sleep .$sleeptime
87103

88-
# Spin a random duration
104+
# Spin a random duration, but with rather coarse granularity.
89105
limit=`awk -v me=$me -v n=$n -v spinmax=$spinmax 'BEGIN {
90106
srand(n + me + systime());
91107
printf("%06d", int(rand() * spinmax));
92108
}' < /dev/null`
93109
n=$(($n+1))
94-
for i in {1..$limit}
110+
startsecs=`date +%s`
111+
startns=`date +%N`
112+
endsecs=$startns
113+
endns=$endns
114+
while timecheck
95115
do
96-
echo > /dev/null
116+
endsecs=`date +%s`
117+
endns=`date +%N`
97118
done
98119
done
99120

0 commit comments

Comments
 (0)