Linux RCU subsystem development
 help / color / mirror / Atom feed
* [PATCH] srcu: Add notes for not-effective mutex
@ 2022-12-14 14:24 Pingfan Liu
  2022-12-18 17:53 ` Paul E. McKenney
  0 siblings, 1 reply; 3+ messages in thread
From: Pingfan Liu @ 2022-12-14 14:24 UTC (permalink / raw)
  To: rcu
  Cc: Pingfan Liu, Lai Jiangshan, Paul E. McKenney, Frederic Weisbecker,
	Josh Triplett, Steven Rostedt, Mathieu Desnoyers, Zhang, Qiang1,
	Boqun Feng, Joel Fernandes

Capped by the design and implementation of workqueue, the same work can not
be re-entrant.

SRCU has only a single work ssp->work, there is no way to occur the
concurrent scene in its state machine. Hence the mutexes for the
concurrency in the state machine is unnecessary. On the other hand,
using two works to utilize the window from the release of srcu_gp_mutex
to the end of srcu_gp_end() to enhance the parallelism has limited
effect. [1]

To save any trying of improving parallelism by using two work_struct,
put some notes around the srcu_gp_mutex and srcu_cb_mutex. And keep them
instead of removing them, in case in future, the state machine is moved
out of the protection of workqueue non-reentrant protection.

Some test data to show how dual work_struct affects the SRCU
performance:

-1. on 144 cpus hpe-dl560gen10
  modprobe rcutorture   torture_type=srcud  fwd_progress=144 fwd_progress_holdoff=1 shutdown_secs=36000 stat_interval=60 verbose=1
  # base line
  [37587.632155] srcud:  End-test grace-period state: g28287244 f0x0 total-gps=28287244
  # two dual work_struct
  [36443.468017] srcud:  End-test grace-period state: g29026056 f0x0 total-gps=29026056

-2. on 256 cpus amd-milan
  modprobe rcutorture   torture_type=srcud  fwd_progress=256 fwd_progress_holdoff=1 shutdown_secs=36000 stat_interval=60 verbose=1
  # base line
  [36093.605732] srcud:  End-test grace-period state: g10850284 f0x0 total-gps=10850284
  # two dual work_struct
  [36093.856713] srcud:  End-test grace-period state: g10672632 f0x0 total-gps=10672632

The first test shows that it has about 2.6% improvement, while the
second test shows it has no significant effect.

[1]: https://lore.kernel.org/rcu/Y5nC2yBhaUYirByo@piliu.users.ipa.redhat.com/T/#maf99cf1d92077a1b0b8e5c411c79fa4444576624

Signed-off-by: Pingfan Liu <kernelfans@gmail.com>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: "Paul E. McKenney" <paulmck@kernel.org>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: "Zhang, Qiang1" <qiang1.zhang@intel.com>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
To: rcu@vger.kernel.org
---
 include/linux/srcutree.h | 4 ++++
 kernel/rcu/srcutree.c    | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/include/linux/srcutree.h b/include/linux/srcutree.h
index 558057b517b7..f199c31493ab 100644
--- a/include/linux/srcutree.h
+++ b/include/linux/srcutree.h
@@ -66,8 +66,12 @@ struct srcu_struct {
 						/* First node at each level. */
 	int srcu_size_state;			/* Small-to-big transition state. */
 	struct mutex srcu_cb_mutex;		/* Serialize CB preparation. */
+						/* Not take effect since the only single sdp->work */
+						/* meets the workqueue non-reentrant condition */
 	spinlock_t __private lock;		/* Protect counters and size state. */
 	struct mutex srcu_gp_mutex;		/* Serialize GP work. */
+						/* Not take effect since the only single sdp->work */
+						/* meets the workqueue non-reentrant condition */
 	unsigned int srcu_idx;			/* Current rdr array element. */
 	unsigned long srcu_gp_seq;		/* Grace-period seq #. */
 	unsigned long srcu_gp_seq_needed;	/* Latest gp_seq needed. */
diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index ce39907fa381..8ebb1a240219 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -815,7 +815,10 @@ static void srcu_gp_end(struct srcu_struct *ssp)
 	struct srcu_node *snp;
 	int ss_state;
 
-	/* Prevent more than one additional grace period. */
+	/*
+	 * Prevent more than one additional grace period. But at present, it does
+	 * not take effect. Refer to the note at the definition.
+	 * /
 	mutex_lock(&ssp->srcu_cb_mutex);
 
 	/* End the current grace period. */
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-23 12:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-14 14:24 [PATCH] srcu: Add notes for not-effective mutex Pingfan Liu
2022-12-18 17:53 ` Paul E. McKenney
2022-12-23 12:58   ` Pingfan Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox