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

rcutorture: Fix stutter_wait() return value and freelist checks

The stutter_wait() function is supposed to return true if it actually
waits and false otherwise, but it instead unconditionally returns false.
Which hides a bug in rcu_torture_writer() that fails to account for
the fact that one of the rcu_tortures[] array elements will normally be
referenced by rcu_torture_current, and thus not be on the freelist.

This commit therefore corrects the stutter_wait() return value and adds a
check for rcu_torture_current to rcu_torture_writer()'s check that things
get freed after everything goes quiescent.  In addition, this commit
causes torture_stutter() to give a bit more than one second (instead of
only one jiffy) warning of the end of the stutter interval.  Finally,
this commit disables long-delay readers and aggressive update-side
forward-progress checks while forward-progress testing is in flight.
Reported-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.ibm.com>
parent 140e53f2
...@@ -1010,10 +1010,13 @@ rcu_torture_writer(void *arg) ...@@ -1010,10 +1010,13 @@ rcu_torture_writer(void *arg)
!rcu_gp_is_normal(); !rcu_gp_is_normal();
} }
rcu_torture_writer_state = RTWS_STUTTER; rcu_torture_writer_state = RTWS_STUTTER;
if (stutter_wait("rcu_torture_writer")) if (stutter_wait("rcu_torture_writer") &&
!READ_ONCE(rcu_fwd_cb_nodelay))
for (i = 0; i < ARRAY_SIZE(rcu_tortures); i++) for (i = 0; i < ARRAY_SIZE(rcu_tortures); i++)
if (list_empty(&rcu_tortures[i].rtort_free)) if (list_empty(&rcu_tortures[i].rtort_free) &&
WARN_ON_ONCE(1); rcu_access_pointer(rcu_torture_current) !=
&rcu_tortures[i])
WARN(1, "%s: rtort_pipe_count: %d\n", __func__, rcu_tortures[i].rtort_pipe_count);
} while (!torture_must_stop()); } while (!torture_must_stop());
/* Reset expediting back to unexpedited. */ /* Reset expediting back to unexpedited. */
if (expediting > 0) if (expediting > 0)
...@@ -1709,6 +1712,8 @@ static void rcu_torture_fwd_prog_nr(int *tested, int *tested_tries) ...@@ -1709,6 +1712,8 @@ static void rcu_torture_fwd_prog_nr(int *tested, int *tested_tries)
} }
/* Tight loop containing cond_resched(). */ /* Tight loop containing cond_resched(). */
WRITE_ONCE(rcu_fwd_cb_nodelay, true);
cur_ops->sync(); /* Later readers see above write. */
if (selfpropcb) { if (selfpropcb) {
WRITE_ONCE(fcs.stop, 0); WRITE_ONCE(fcs.stop, 0);
cur_ops->call(&fcs.rh, rcu_torture_fwd_prog_cb); cur_ops->call(&fcs.rh, rcu_torture_fwd_prog_cb);
...@@ -1747,6 +1752,8 @@ static void rcu_torture_fwd_prog_nr(int *tested, int *tested_tries) ...@@ -1747,6 +1752,8 @@ static void rcu_torture_fwd_prog_nr(int *tested, int *tested_tries)
WARN_ON(READ_ONCE(fcs.stop) != 2); WARN_ON(READ_ONCE(fcs.stop) != 2);
destroy_rcu_head_on_stack(&fcs.rh); destroy_rcu_head_on_stack(&fcs.rh);
} }
schedule_timeout_uninterruptible(HZ / 10); /* Let kthreads recover. */
WRITE_ONCE(rcu_fwd_cb_nodelay, false);
} }
/* Carry out call_rcu() forward-progress testing. */ /* Carry out call_rcu() forward-progress testing. */
...@@ -1816,7 +1823,6 @@ static void rcu_torture_fwd_prog_cr(void) ...@@ -1816,7 +1823,6 @@ static void rcu_torture_fwd_prog_cr(void)
cur_ops->cb_barrier(); /* Wait for callbacks to be invoked. */ cur_ops->cb_barrier(); /* Wait for callbacks to be invoked. */
(void)rcu_torture_fwd_prog_cbfree(); (void)rcu_torture_fwd_prog_cbfree();
WRITE_ONCE(rcu_fwd_cb_nodelay, false);
if (!torture_must_stop() && !READ_ONCE(rcu_fwd_emergency_stop)) { if (!torture_must_stop() && !READ_ONCE(rcu_fwd_emergency_stop)) {
WARN_ON(n_max_gps < MIN_FWD_CBS_LAUNDERED); WARN_ON(n_max_gps < MIN_FWD_CBS_LAUNDERED);
pr_alert("%s Duration %lu barrier: %lu pending %ld n_launders: %ld n_launders_sa: %ld n_max_gps: %ld n_max_cbs: %ld cver %ld gps %ld\n", pr_alert("%s Duration %lu barrier: %lu pending %ld n_launders: %ld n_launders_sa: %ld n_max_gps: %ld n_max_cbs: %ld cver %ld gps %ld\n",
...@@ -1827,6 +1833,8 @@ static void rcu_torture_fwd_prog_cr(void) ...@@ -1827,6 +1833,8 @@ static void rcu_torture_fwd_prog_cr(void)
n_max_gps, n_max_cbs, cver, gps); n_max_gps, n_max_cbs, cver, gps);
rcu_torture_fwd_cb_hist(); rcu_torture_fwd_cb_hist();
} }
schedule_timeout_uninterruptible(HZ); /* Let CBs drain. */
WRITE_ONCE(rcu_fwd_cb_nodelay, false);
} }
......
...@@ -578,10 +578,12 @@ static int stutter; ...@@ -578,10 +578,12 @@ static int stutter;
bool stutter_wait(const char *title) bool stutter_wait(const char *title)
{ {
int spt; int spt;
bool ret = false;
cond_resched_tasks_rcu_qs(); cond_resched_tasks_rcu_qs();
spt = READ_ONCE(stutter_pause_test); spt = READ_ONCE(stutter_pause_test);
for (; spt; spt = READ_ONCE(stutter_pause_test)) { for (; spt; spt = READ_ONCE(stutter_pause_test)) {
ret = true;
if (spt == 1) { if (spt == 1) {
schedule_timeout_interruptible(1); schedule_timeout_interruptible(1);
} else if (spt == 2) { } else if (spt == 2) {
...@@ -592,7 +594,7 @@ bool stutter_wait(const char *title) ...@@ -592,7 +594,7 @@ bool stutter_wait(const char *title)
} }
torture_shutdown_absorb(title); torture_shutdown_absorb(title);
} }
return !!spt; return ret;
} }
EXPORT_SYMBOL_GPL(stutter_wait); EXPORT_SYMBOL_GPL(stutter_wait);
...@@ -602,13 +604,20 @@ EXPORT_SYMBOL_GPL(stutter_wait); ...@@ -602,13 +604,20 @@ EXPORT_SYMBOL_GPL(stutter_wait);
*/ */
static int torture_stutter(void *arg) static int torture_stutter(void *arg)
{ {
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) {
WRITE_ONCE(stutter_pause_test, 1); wtime = stutter;
schedule_timeout_interruptible(stutter - 1); if (stutter > HZ + 1) {
WRITE_ONCE(stutter_pause_test, 1);
wtime = stutter - HZ - 1;
schedule_timeout_interruptible(wtime);
wtime = HZ + 1;
}
WRITE_ONCE(stutter_pause_test, 2); WRITE_ONCE(stutter_pause_test, 2);
schedule_timeout_interruptible(1); schedule_timeout_interruptible(wtime);
} }
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