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

torture: Make stutter use torture_hrtimeout_*() functions

This commit saves a few lines of code by making the stutter_wait()
and torture_stutter() functions use torture_hrtimeout_jiffies() and
torture_hrtimeout_us().
Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
parent ea31fd9c
...@@ -677,7 +677,6 @@ static int stutter_gap; ...@@ -677,7 +677,6 @@ static int stutter_gap;
*/ */
bool stutter_wait(const char *title) bool stutter_wait(const char *title)
{ {
ktime_t delay;
unsigned int i = 0; unsigned int i = 0;
bool ret = false; bool ret = false;
int spt; int spt;
...@@ -693,11 +692,8 @@ bool stutter_wait(const char *title) ...@@ -693,11 +692,8 @@ bool stutter_wait(const char *title)
schedule_timeout_interruptible(1); schedule_timeout_interruptible(1);
} else if (spt == 2) { } else if (spt == 2) {
while (READ_ONCE(stutter_pause_test)) { while (READ_ONCE(stutter_pause_test)) {
if (!(i++ & 0xffff)) { if (!(i++ & 0xffff))
set_current_state(TASK_INTERRUPTIBLE); torture_hrtimeout_us(10, 0, NULL);
delay = 10 * NSEC_PER_USEC;
schedule_hrtimeout(&delay, HRTIMER_MODE_REL);
}
cond_resched(); cond_resched();
} }
} else { } else {
...@@ -715,7 +711,6 @@ EXPORT_SYMBOL_GPL(stutter_wait); ...@@ -715,7 +711,6 @@ EXPORT_SYMBOL_GPL(stutter_wait);
*/ */
static int torture_stutter(void *arg) static int torture_stutter(void *arg)
{ {
ktime_t delay;
DEFINE_TORTURE_RANDOM(rand); DEFINE_TORTURE_RANDOM(rand);
int wtime; int wtime;
...@@ -726,20 +721,15 @@ static int torture_stutter(void *arg) ...@@ -726,20 +721,15 @@ static int torture_stutter(void *arg)
if (stutter > 2) { if (stutter > 2) {
WRITE_ONCE(stutter_pause_test, 1); WRITE_ONCE(stutter_pause_test, 1);
wtime = stutter - 3; wtime = stutter - 3;
delay = ktime_divns(NSEC_PER_SEC * wtime, HZ); torture_hrtimeout_jiffies(wtime, &rand);
delay += (torture_random(&rand) >> 3) % NSEC_PER_MSEC;
set_current_state(TASK_INTERRUPTIBLE);
schedule_hrtimeout(&delay, HRTIMER_MODE_REL);
wtime = 2; wtime = 2;
} }
WRITE_ONCE(stutter_pause_test, 2); WRITE_ONCE(stutter_pause_test, 2);
delay = ktime_divns(NSEC_PER_SEC * wtime, HZ); torture_hrtimeout_jiffies(wtime, NULL);
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())
schedule_timeout_interruptible(stutter_gap); torture_hrtimeout_jiffies(stutter_gap, NULL);
torture_shutdown_absorb("torture_stutter"); torture_shutdown_absorb("torture_stutter");
} while (!torture_must_stop()); } while (!torture_must_stop());
torture_kthread_stopping("torture_stutter"); torture_kthread_stopping("torture_stutter");
......
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