[PATCH] srcu: Add notes for not-effective mutex

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxxxxxxxx/T/#maf99cf1d92077a1b0b8e5c411c79fa4444576624

Signed-off-by: Pingfan Liu <kernelfans@xxxxxxxxx>
Cc: Lai Jiangshan <jiangshanlai@xxxxxxxxx>
Cc: "Paul E. McKenney" <paulmck@xxxxxxxxxx>
Cc: Frederic Weisbecker <frederic@xxxxxxxxxx>
Cc: Josh Triplett <josh@xxxxxxxxxxxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
Cc: "Zhang, Qiang1" <qiang1.zhang@xxxxxxxxx>
Cc: Boqun Feng <boqun.feng@xxxxxxxxx>
Cc: Joel Fernandes <joel@xxxxxxxxxxxxxxxxx>
To: rcu@xxxxxxxxxxxxxxx
---
 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




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux