mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@kernel.org>
To: rcu@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com,
	rostedt@goodmis.org, "Paul E. McKenney" <paulmck@kernel.org>
Subject: [PATCH rcu 03/25] rcutorture: Abstract synchronous and polled API testing
Date: Wed, 31 Aug 2022 11:11:48 -0700	[thread overview]
Message-ID: <20220831181210.2695080-3-paulmck@kernel.org> (raw)
In-Reply-To: <20220831181207.GA2694717@paulmck-ThinkPad-P17-Gen-1>

This commit abstracts a do_rtws_sync() function that does synchronous
grace-period testing, but also testing the polled API 25% of the time
each for the normal and full-state variants of the polled API.

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

diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 4f196ebce7f29..c3c94e343eb28 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -1207,6 +1207,40 @@ static void rcu_torture_write_types(void)
 	}
 }
 
+/*
+ * Do the specified rcu_torture_writer() synchronous grace period,
+ * while also testing out the polled APIs.  Note well that the single-CPU
+ * grace-period optimizations must be accounted for.
+ */
+static void do_rtws_sync(struct torture_random_state *trsp, void (*sync)(void))
+{
+	unsigned long cookie;
+	struct rcu_gp_oldstate cookie_full;
+	bool dopoll;
+	bool dopoll_full;
+	unsigned long r = torture_random(trsp);
+
+	dopoll = cur_ops->get_gp_state && cur_ops->poll_gp_state && !(r & 0x300);
+	dopoll_full = cur_ops->get_gp_state_full && cur_ops->poll_gp_state_full && !(r & 0xc00);
+	if (dopoll || dopoll_full)
+		cpus_read_lock();
+	if (dopoll)
+		cookie = cur_ops->get_gp_state();
+	if (dopoll_full)
+		cur_ops->get_gp_state_full(&cookie_full);
+	if (dopoll || (!IS_ENABLED(CONFIG_TINY_RCU) && dopoll_full && num_online_cpus() <= 1))
+		sync();
+	sync();
+	WARN_ONCE(dopoll && !cur_ops->poll_gp_state(cookie),
+		  "%s: Cookie check 3 failed %pS() online %*pbl.",
+		  __func__, sync, cpumask_pr_args(cpu_online_mask));
+	WARN_ONCE(dopoll_full && !cur_ops->poll_gp_state_full(&cookie_full),
+		  "%s: Cookie check 4 failed %pS() online %*pbl",
+		  __func__, sync, cpumask_pr_args(cpu_online_mask));
+	if (dopoll || dopoll_full)
+		cpus_read_unlock();
+}
+
 /*
  * RCU torture writer kthread.  Repeatedly substitutes a new structure
  * for that pointed to by rcu_torture_current, freeing the old structure
@@ -1295,12 +1329,7 @@ rcu_torture_writer(void *arg)
 				break;
 			case RTWS_EXP_SYNC:
 				rcu_torture_writer_state = RTWS_EXP_SYNC;
-				if (cur_ops->get_gp_state_full && cur_ops->poll_gp_state_full)
-					cur_ops->get_gp_state_full(&cookie_full);
-				cur_ops->exp_sync();
-				cur_ops->exp_sync();
-				if (cur_ops->get_gp_state_full && cur_ops->poll_gp_state_full)
-					WARN_ON_ONCE(!cur_ops->poll_gp_state_full(&cookie_full));
+				do_rtws_sync(&rand, cur_ops->exp_sync);
 				rcu_torture_pipe_update(old_rp);
 				break;
 			case RTWS_COND_GET:
@@ -1339,12 +1368,7 @@ rcu_torture_writer(void *arg)
 				break;
 			case RTWS_SYNC:
 				rcu_torture_writer_state = RTWS_SYNC;
-				if (cur_ops->get_gp_state && cur_ops->poll_gp_state)
-					cookie = cur_ops->get_gp_state();
-				cur_ops->sync();
-				cur_ops->sync();
-				if (cur_ops->get_gp_state && cur_ops->poll_gp_state)
-					WARN_ON_ONCE(!cur_ops->poll_gp_state(cookie));
+				do_rtws_sync(&rand, cur_ops->sync);
 				rcu_torture_pipe_update(old_rp);
 				break;
 			default:
-- 
2.31.1.189.g2e36527f23


  parent reply	other threads:[~2022-08-31 18:16 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-31 18:12 [PATCH rcu 0/7] Polled grace-period updates for v6.1 Paul E. McKenney
2022-08-31 18:11 ` [PATCH rcu 01/25] rcu: Add full-sized polling for get_completed*() and poll_state*() Paul E. McKenney
2022-08-31 18:11 ` [PATCH rcu 02/25] rcu: Add full-sized polling for get_state() Paul E. McKenney
2022-08-31 18:11 ` Paul E. McKenney [this message]
2022-08-31 18:11 ` [PATCH rcu 04/25] rcutorture: Allow per-RCU-flavor polled double-GP check Paul E. McKenney
2022-08-31 18:11 ` [PATCH rcu 05/25] rcutorture: Verify RCU reader prevents full polling from completing Paul E. McKenney
2022-08-31 18:11 ` [PATCH rcu 06/25] rcutorture: Remove redundant RTWS_DEF_FREE check Paul E. McKenney
2022-08-31 18:11 ` [PATCH rcu 07/25] rcutorture: Verify long-running reader prevents full polling from completing Paul E. McKenney
2022-08-31 18:11 ` [PATCH rcu 08/25] rcu: Add full-sized polling for start_poll() Paul E. McKenney
2022-08-31 18:11 ` [PATCH rcu 09/25] rcu: Add full-sized polling for start_poll_expedited() Paul E. McKenney
2022-08-31 18:11 ` [PATCH rcu 10/25] rcu: Remove blank line from poll_state_synchronize_rcu() docbook header Paul E. McKenney
2022-08-31 18:11 ` [PATCH rcu 11/25] rcu: Add full-sized polling for cond_sync_full() Paul E. McKenney
2022-08-31 18:11 ` [PATCH rcu 12/25] rcu: Add full-sized polling for cond_sync_exp_full() Paul E. McKenney
2022-08-31 18:11 ` [PATCH rcu 13/25] rcu: Disable run-time single-CPU grace-period optimization Paul E. McKenney
2022-08-31 18:11 ` [PATCH rcu 14/25] rcu: Set rcu_data structures' initial ->gpwrap value to true Paul E. McKenney
2022-08-31 18:12 ` [PATCH rcu 15/25] rcu-tasks: Remove grace-period fast-path rcu-tasks helper Paul E. McKenney
2022-08-31 18:12 ` [PATCH rcu 16/25] rcu: Make synchronize_rcu() fast path update ->gp_seq counters Paul E. McKenney
2022-08-31 18:12 ` [PATCH rcu 17/25] rcu: Remove expedited grace-period fast-path forward-progress helper Paul E. McKenney
2022-08-31 18:12 ` [PATCH rcu 18/25] rcu: Make synchronize_rcu_expedited() fast path update .expedited_sequence Paul E. McKenney
2022-08-31 18:12 ` [PATCH rcu 19/25] rcu: Remove ->rgos_polled field from rcu_gp_oldstate structure Paul E. McKenney
2022-08-31 18:12 ` [PATCH rcu 20/25] rcutorture: Adjust rcu_poll_need_2gp() for rcu_gp_oldstate field removal Paul E. McKenney
2022-08-31 18:12 ` [PATCH rcu 21/25] rcu: Make synchronize_rcu() fastpath update only boot-CPU counters Paul E. McKenney
2022-08-31 18:12 ` [PATCH rcu 22/25] rcutorture: Use 1-suffixed variable in rcu_torture_write_types() check Paul E. McKenney
2022-08-31 18:12 ` [PATCH rcu 23/25] rcutorture: Expand rcu_torture_write_types() first "if" statement Paul E. McKenney
2022-08-31 18:12 ` [PATCH rcu 24/25] rcu: Add functions to compare grace-period state values Paul E. McKenney
2022-08-31 18:12 ` [PATCH rcu 25/25] rcutorture: Limit read-side polling-API testing 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=20220831181210.2695080-3-paulmck@kernel.org \
    --to=paulmck@kernel.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /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

all inboxes | Powered by JetHome®