From: "Paul E. McKenney" <paulmck@linux.ibm.com>
To: rcu@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, mingo@kernel.org,
jiangshanlai@gmail.com, dipankar@in.ibm.com,
akpm@linux-foundation.org, mathieu.desnoyers@efficios.com,
josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org,
rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com,
fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org,
"Paul E. McKenney" <paulmck@linux.ibm.com>
Subject: [PATCH tip/core/rcu 04/21] rcutorture: Fix stutter_wait() return value and freelist checks
Date: Thu, 30 May 2019 08:16:55 -0700 [thread overview]
Message-ID: <20190530151712.1612-4-paulmck@linux.ibm.com> (raw)
In-Reply-To: <20190530151650.GA422@linux.ibm.com>
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: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
---
kernel/rcu/rcutorture.c | 16 ++++++++++++----
kernel/torture.c | 17 +++++++++++++----
2 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 7906ba2d9dad..954ac2b98619 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -1010,10 +1010,13 @@ rcu_torture_writer(void *arg)
!rcu_gp_is_normal();
}
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++)
- if (list_empty(&rcu_tortures[i].rtort_free))
- WARN_ON_ONCE(1);
+ if (list_empty(&rcu_tortures[i].rtort_free) &&
+ 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());
/* Reset expediting back to unexpedited. */
if (expediting > 0)
@@ -1709,6 +1712,8 @@ static void rcu_torture_fwd_prog_nr(int *tested, int *tested_tries)
}
/* Tight loop containing cond_resched(). */
+ WRITE_ONCE(rcu_fwd_cb_nodelay, true);
+ cur_ops->sync(); /* Later readers see above write. */
if (selfpropcb) {
WRITE_ONCE(fcs.stop, 0);
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)
WARN_ON(READ_ONCE(fcs.stop) != 2);
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. */
@@ -1816,7 +1823,6 @@ static void rcu_torture_fwd_prog_cr(void)
cur_ops->cb_barrier(); /* Wait for callbacks to be invoked. */
(void)rcu_torture_fwd_prog_cbfree();
- WRITE_ONCE(rcu_fwd_cb_nodelay, false);
if (!torture_must_stop() && !READ_ONCE(rcu_fwd_emergency_stop)) {
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",
@@ -1827,6 +1833,8 @@ static void rcu_torture_fwd_prog_cr(void)
n_max_gps, n_max_cbs, cver, gps);
rcu_torture_fwd_cb_hist();
}
+ schedule_timeout_uninterruptible(HZ); /* Let CBs drain. */
+ WRITE_ONCE(rcu_fwd_cb_nodelay, false);
}
diff --git a/kernel/torture.c b/kernel/torture.c
index 17b2be9bde12..de0e0ecf88e1 100644
--- a/kernel/torture.c
+++ b/kernel/torture.c
@@ -578,10 +578,12 @@ static int stutter;
bool stutter_wait(const char *title)
{
int spt;
+ bool ret = false;
cond_resched_tasks_rcu_qs();
spt = READ_ONCE(stutter_pause_test);
for (; spt; spt = READ_ONCE(stutter_pause_test)) {
+ ret = true;
if (spt == 1) {
schedule_timeout_interruptible(1);
} else if (spt == 2) {
@@ -592,7 +594,7 @@ bool stutter_wait(const char *title)
}
torture_shutdown_absorb(title);
}
- return !!spt;
+ return ret;
}
EXPORT_SYMBOL_GPL(stutter_wait);
@@ -602,13 +604,20 @@ EXPORT_SYMBOL_GPL(stutter_wait);
*/
static int torture_stutter(void *arg)
{
+ int wtime;
+
VERBOSE_TOROUT_STRING("torture_stutter task started");
do {
if (!torture_must_stop() && stutter > 1) {
- WRITE_ONCE(stutter_pause_test, 1);
- schedule_timeout_interruptible(stutter - 1);
+ wtime = stutter;
+ 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);
- schedule_timeout_interruptible(1);
+ schedule_timeout_interruptible(wtime);
}
WRITE_ONCE(stutter_pause_test, 0);
if (!torture_must_stop())
--
2.17.1
next prev parent reply other threads:[~2019-05-30 15:18 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-30 15:16 [PATCH tip/core/rcu 0/21] Torture-test updates for v5.3 Paul E. McKenney
2019-05-30 15:16 ` [PATCH tip/core/rcu 01/21] rcutorture: Select from only online CPUs Paul E. McKenney
2019-05-30 15:16 ` [PATCH tip/core/rcu 02/21] rcutorture: Add cpu0 to the set of CPUs to add jitter Paul E. McKenney
2019-05-30 15:16 ` [PATCH tip/core/rcu 03/21] rcutorture: Add cond_resched() to forward-progress free-up loop Paul E. McKenney
2019-05-30 15:16 ` Paul E. McKenney [this message]
2019-05-30 15:16 ` [PATCH tip/core/rcu 05/21] torture: Allow inter-stutter interval to be specified Paul E. McKenney
2019-05-30 15:16 ` [PATCH tip/core/rcu 06/21] torture: Make kvm-find-errors.sh and kvm-recheck.sh provide exit status Paul E. McKenney
2019-05-30 15:16 ` [PATCH tip/core/rcu 07/21] rcutorture: Provide rudimentary Makefile Paul E. McKenney
2019-05-30 15:16 ` [PATCH tip/core/rcu 08/21] rcutorture: Exempt tasks RCU from timely draining of grace periods Paul E. McKenney
2019-05-30 15:17 ` [PATCH tip/core/rcu 09/21] rcutorture: Exempt TREE01 from forward-progress testing Paul E. McKenney
2019-05-30 15:17 ` [PATCH tip/core/rcu 10/21] rcutorture: Give the scheduler a chance on PREEMPT && NO_HZ_FULL kernels Paul E. McKenney
2019-05-30 15:17 ` [PATCH tip/core/rcu 11/21] rcutorture: Halt forward-progress checks at end of run Paul E. McKenney
2019-05-30 15:17 ` [PATCH tip/core/rcu 12/21] rcutorture: Add trivial RCU implementation Paul E. McKenney
2019-05-30 15:17 ` [PATCH tip/core/rcu 13/21] rcutorture: Tweak kvm options Paul E. McKenney
2019-05-30 15:17 ` [PATCH tip/core/rcu 14/21] torture: Capture qemu output Paul E. McKenney
2019-05-30 15:17 ` [PATCH tip/core/rcu 15/21] torture: Add function graph-tracing cheat sheet Paul E. McKenney
2019-05-30 15:17 ` [PATCH tip/core/rcu 16/21] torture: Run kernel build in source directory Paul E. McKenney
2019-05-30 15:17 ` [PATCH tip/core/rcu 17/21] torture: Make --cpus override idleness calculations Paul E. McKenney
2019-05-30 15:17 ` [PATCH tip/core/rcu 18/21] torture: Add --trust-make to suppress "make clean" Paul E. McKenney
2019-05-30 15:17 ` [PATCH tip/core/rcu 19/21] rcutorture: Dump trace buffer for callback pipe drain failures Paul E. McKenney
2019-05-30 15:17 ` [PATCH tip/core/rcu 20/21] torture: Suppress propagating trace_printk() warning Paul E. McKenney
2019-05-30 15:17 ` [PATCH tip/core/rcu 21/21] rcutorture: Upper case solves the case of the vanishing NULL pointer Paul E. McKenney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190530151712.1612-4-paulmck@linux.ibm.com \
--to=paulmck@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=edumazet@google.com \
--cc=fweisbec@gmail.com \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox