From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: 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.vnet.ibm.com>
Subject: [PATCH tip/core/rcu 10/17] rcutorture: Add self-propagating callback to forward-progress testing
Date: Wed, 29 Aug 2018 14:47:43 -0700 [thread overview]
Message-ID: <20180829214750.26972-10-paulmck@linux.vnet.ibm.com> (raw)
In-Reply-To: <20180829214722.GA23411@linux.vnet.ibm.com>
If rcutorture is run on a quiet system with the rcutorture.stutter module
parameter set high, then there can legitimately be an extended period
during which no RCU forward progress takes place. This can result
in false-positive no-forward-progress splats. This commit therefore
makes rcu_torture_fwd_prog() create a self-propagating RCU callback
to ensure that grace periods are in progress for the duration of the
forward-progress test.
Note that the RCU flavor under test must define ->call(), ->sync(),
and ->cb_barrier() for this self-propagating callback to be created.
If one or more of those rcu_torture_ops fields are NULL, then the
rcu_torture_fwd_prog() function will silently proceed without creating
the self-propagating callback.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
kernel/rcu/rcutorture.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 89cc4d9c9a0c..316083687fd7 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -1670,20 +1670,49 @@ static int __init rcu_torture_stall_init(void)
return torture_create_kthread(rcu_torture_stall, NULL, stall_task);
}
+/* State structure for forward-progress self-propagating RCU callback. */
+struct fwd_cb_state {
+ struct rcu_head rh;
+ int stop;
+};
+
+/*
+ * Forward-progress self-propagating RCU callback function. Because
+ * callbacks run from softirq, this function is an implicit RCU read-side
+ * critical section.
+ */
+static void rcu_torture_fwd_prog_cb(struct rcu_head *rhp)
+{
+ struct fwd_cb_state *fcsp = container_of(rhp, struct fwd_cb_state, rh);
+
+ if (READ_ONCE(fcsp->stop)) {
+ WRITE_ONCE(fcsp->stop, 2);
+ return;
+ }
+ cur_ops->call(&fcsp->rh, rcu_torture_fwd_prog_cb);
+}
+
/* Carry out grace-period forward-progress testing. */
static int rcu_torture_fwd_prog(void *args)
{
unsigned long cver;
+ struct fwd_cb_state fcs = { .stop = 0 };
unsigned long gps;
int idx;
int sd;
int sd4;
+ bool selfpropcb = false;
unsigned long stopat;
bool tested = false;
int tested_tries = 0;
static DEFINE_TORTURE_RANDOM(trs);
VERBOSE_TOROUT_STRING("rcu_torture_fwd_progress task started");
+ if (cur_ops->call && cur_ops->sync && cur_ops->cb_barrier) {
+ init_rcu_head_on_stack(&fcs.rh);
+ cur_ops->call(&fcs.rh, rcu_torture_fwd_prog_cb);
+ selfpropcb = true;
+ }
do {
schedule_timeout_interruptible(fwd_progress_holdoff * HZ);
cver = READ_ONCE(rcu_torture_current_version);
@@ -1708,6 +1737,13 @@ static int rcu_torture_fwd_prog(void *args)
/* Avoid slow periods, better to test when busy. */
stutter_wait("rcu_torture_fwd_prog");
} while (!torture_must_stop());
+ if (selfpropcb) {
+ WRITE_ONCE(fcs.stop, 1);
+ cur_ops->sync(); /* Wait for running callback to complete. */
+ cur_ops->cb_barrier(); /* Wait for queued callbacks. */
+ WARN_ON(READ_ONCE(fcs.stop) != 2);
+ destroy_rcu_head_on_stack(&fcs.rh);
+ }
/* Short runs might not contain a valid forward-progress attempt. */
WARN_ON(!tested && tested_tries >= 5);
torture_kthread_stopping("rcu_torture_fwd_prog");
--
2.17.1
next prev parent reply other threads:[~2018-08-29 21:48 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-29 21:47 [PATCH tip/core/rcu 0/17] Torture-test changes for v4.20/v5.0 Paul E. McKenney
2018-08-29 21:47 ` [PATCH tip/core/rcu 01/17] torture: Stop overwriting Make.out file with obsolete version Paul E. McKenney
2018-08-29 21:47 ` [PATCH tip/core/rcu 02/17] rcutorture: Force occasional reader waits Paul E. McKenney
2018-08-29 21:47 ` [PATCH tip/core/rcu 03/17] rcutorture: Warn on bad torture type for built-in tests Paul E. McKenney
2018-08-29 21:47 ` [PATCH tip/core/rcu 04/17] rcuperf: Warn on bad perf " Paul E. McKenney
2018-08-29 21:47 ` [PATCH tip/core/rcu 05/17] rcutorture: Remove TREE06 and TREE08 from the default test list Paul E. McKenney
2018-08-29 21:47 ` [PATCH tip/core/rcu 06/17] rcutorture: Add forward-progress tests for RCU grace periods Paul E. McKenney
2018-08-29 21:47 ` [PATCH tip/core/rcu 07/17] rcutorture: Also use GP sequence to judge forward progress Paul E. McKenney
2018-08-29 21:47 ` [PATCH tip/core/rcu 08/17] rcutorture: Avoid no-test complaint if too few forward-progress tries Paul E. McKenney
2018-08-29 21:47 ` [PATCH tip/core/rcu 09/17] rcutorture: Vary forward-progress test interval Paul E. McKenney
2018-08-29 21:47 ` Paul E. McKenney [this message]
2018-08-29 21:47 ` [PATCH tip/core/rcu 11/17] rcutorture: Increase rcu_read_delay() longdelay_ms Paul E. McKenney
2018-08-29 21:47 ` [PATCH tip/core/rcu 12/17] rcutorture: Limit reader duration if irq or bh disabled Paul E. McKenney
2018-08-29 21:47 ` [PATCH tip/core/rcu 13/17] rcutorture: Reduce priority of forward-progress testing Paul E. McKenney
2018-08-29 21:47 ` [PATCH tip/core/rcu 14/17] rcutorture: Adjust number of reader kthreads per CPU-hotplug operations Paul E. McKenney
2018-08-29 21:47 ` [PATCH tip/core/rcu 15/17] rcutorture: Print forward-progress test interval on error Paul E. McKenney
2018-08-29 21:47 ` [PATCH tip/core/rcu 16/17] rcutorture: Check GP completion at stutter end Paul E. McKenney
2018-08-29 21:47 ` [PATCH tip/core/rcu 17/17] rcutorture: Maintain self-propagating CB only during forward-progress test 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=20180829214750.26972-10-paulmck@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.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=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;
as well as URLs for NNTP newsgroup(s).