Commit fda5ba9e authored by Paul E. McKenney's avatar Paul E. McKenney

torture: Make torture_stutter() use hrtimer

The torture_stutter() function uses schedule_timeout_interruptible()
to time the stutter duration, but this can miss race conditions due to
its being time-synchronized with everything else that is based on the
timer wheels.  This commit therefore converts torture_stutter() to use
the high-resolution timers via schedule_hrtimeout(), and also to fuzz
the stutter interval.  While in the area, this commit also limits the
spin-loop portion of the stutter_wait() function's wait loop to two
jiffies, down from about one second.
Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
parent 19012b78
...@@ -641,20 +641,27 @@ EXPORT_SYMBOL_GPL(stutter_wait); ...@@ -641,20 +641,27 @@ EXPORT_SYMBOL_GPL(stutter_wait);
*/ */
static int torture_stutter(void *arg) static int torture_stutter(void *arg)
{ {
ktime_t delay;
DEFINE_TORTURE_RANDOM(rand);
int wtime; int wtime;
VERBOSE_TOROUT_STRING("torture_stutter task started"); VERBOSE_TOROUT_STRING("torture_stutter task started");
do { do {
if (!torture_must_stop() && stutter > 1) { if (!torture_must_stop() && stutter > 1) {
wtime = stutter; wtime = stutter;
if (stutter > HZ + 1) { if (stutter > 2) {
WRITE_ONCE(stutter_pause_test, 1); WRITE_ONCE(stutter_pause_test, 1);
wtime = stutter - HZ - 1; wtime = stutter - 3;
schedule_timeout_interruptible(wtime); delay = ktime_divns(NSEC_PER_SEC * wtime, HZ);
wtime = HZ + 1; delay += (torture_random(&rand) >> 3) % NSEC_PER_MSEC;
set_current_state(TASK_INTERRUPTIBLE);
schedule_hrtimeout(&delay, HRTIMER_MODE_REL);
wtime = 2;
} }
WRITE_ONCE(stutter_pause_test, 2); WRITE_ONCE(stutter_pause_test, 2);
schedule_timeout_interruptible(wtime); delay = ktime_divns(NSEC_PER_SEC * wtime, HZ);
set_current_state(TASK_INTERRUPTIBLE);
schedule_hrtimeout(&delay, HRTIMER_MODE_REL);
} }
WRITE_ONCE(stutter_pause_test, 0); WRITE_ONCE(stutter_pause_test, 0);
if (!torture_must_stop()) if (!torture_must_stop())
......
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