linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: paulmck@kernel.org
To: rcu@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com,
	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@kernel.org>
Subject: [PATCH tip/core/rcu 17/18] rcutorture: Manually clean up after rcu_barrier() failure
Date: Fri, 14 Feb 2020 16:41:24 -0800	[thread overview]
Message-ID: <20200215004125.16953-11-paulmck@kernel.org> (raw)
In-Reply-To: <20200215003634.GA16227@paulmck-ThinkPad-P72>

From: "Paul E. McKenney" <paulmck@kernel.org>

Currently, if rcu_barrier() returns too soon, the test waits 100ms and
then does another instance of the test.  However, if rcu_barrier() were
to have waited for more than 100ms too short a time, this could cause
the test's rcu_head structures to be reused while they were still on
RCU's callback lists.  This can result in knock-on errors that obscure
the original rcu_barrier() test failure.

This commit therefore adds code that attempts to wait until all of
the test's callbacks have been invoked.  Of course, if RCU completely
lost track of the corresponding rcu_head structures, this wait could be
forever.  This commit therefore also complains if this attempted recovery
takes more than one second, and it also gives up when the test ends.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/rcutorture.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index f82515c..5453bd5 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -2124,7 +2124,21 @@ static int rcu_torture_barrier(void *arg)
 			pr_err("barrier_cbs_invoked = %d, n_barrier_cbs = %d\n",
 			       atomic_read(&barrier_cbs_invoked),
 			       n_barrier_cbs);
-			WARN_ON_ONCE(1);
+			WARN_ON(1);
+			// Wait manually for the remaining callbacks
+			i = 0;
+			do {
+				if (WARN_ON(i++ > HZ))
+					i = INT_MIN;
+				schedule_timeout_interruptible(1);
+				cur_ops->cb_barrier();
+			} while (atomic_read(&barrier_cbs_invoked) !=
+				 n_barrier_cbs &&
+				 !torture_must_stop());
+			smp_mb(); // Can't trust ordering if broken.
+			if (!torture_must_stop())
+				pr_err("Recovered: barrier_cbs_invoked = %d\n",
+				       atomic_read(&barrier_cbs_invoked));
 		} else {
 			n_barrier_successes++;
 		}
-- 
2.9.5


  parent reply	other threads:[~2020-02-15  0:42 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-15  0:36 [PATCH tip/core/rcu 0/18] Torture-test updates for v5.7 Paul E. McKenney
2020-02-15  0:36 ` [PATCH tip/core/rcu 01/18] rcutorture: Suppress forward-progress complaints during early boot paulmck
2020-02-15  0:36 ` [PATCH tip/core/rcu 02/18] torture: Make results-directory date format completion-friendly paulmck
2020-02-15  0:36 ` [PATCH tip/core/rcu 03/18] rcutorture: Refrain from callback flooding during boot paulmck
2020-02-15  0:36 ` [PATCH tip/core/rcu 04/18] torture: Forgive -EBUSY from boottime CPU-hotplug operations paulmck
2020-02-15  0:36 ` [PATCH tip/core/rcu 05/18] rcutorture: Allow boottime stall warnings to be suppressed paulmck
2020-02-15  0:36 ` [PATCH tip/core/rcu 06/18] rcutorture: Suppress boottime bad-sequence warnings paulmck
2020-02-15  0:41 ` [PATCH tip/core/rcu 07/18] torture: Allow disabling of boottime CPU-hotplug torture operations paulmck
2020-02-15  0:41 ` [PATCH tip/core/rcu 08/18] rcutorture: Add 100-CPU configuration paulmck
2020-02-15  0:41 ` [PATCH tip/core/rcu 09/18] rcutorture: Summarize summary of build and run results paulmck
2020-02-15  0:41 ` [PATCH tip/core/rcu 10/18] rcutorture: Make kvm-find-errors.sh abort on bad directory paulmck
2020-02-15  0:41 ` [PATCH tip/core/rcu 11/18] rcutorture: Fix rcu_torture_one_read()/rcu_torture_writer() data race paulmck
2020-02-15  0:41 ` [PATCH tip/core/rcu 12/18] rcutorture: Fix stray access to rcu_fwd_cb_nodelay paulmck
2020-02-15  0:41 ` [PATCH tip/core/rcu 13/18] rcutorture: Add READ_ONCE() to rcu_torture_count and rcu_torture_batch paulmck
2020-02-15  0:41 ` [PATCH tip/core/rcu 14/18] rcutorture: Annotation lockless accesses to rcu_torture_current paulmck
2020-02-15  0:41 ` [PATCH tip/core/rcu 15/18] rcuperf: Measure memory footprint during kfree_rcu() test paulmck
2020-02-15  0:41 ` [PATCH tip/core/rcu 16/18] rcutorture: Make rcu_torture_barrier_cbs() post from corresponding CPU paulmck
2020-02-15  0:41 ` paulmck [this message]
2020-02-15  0:41 ` [PATCH tip/core/rcu 18/18] rcutorture: Set KCSAN Kconfig options to detect more data races paulmck

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=20200215004125.16953-11-paulmck@kernel.org \
    --to=paulmck@kernel.org \
    --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=kernel-team@fb.com \
    --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;
as well as URLs for NNTP newsgroup(s).