mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] rcuscale: add srcu_atomic scale type
@ 2026-09-27 10:03 Kunwu Chan
  2026-09-27 20:00 ` Bradley Morgan
  0 siblings, 1 reply; 2+ messages in thread
From: Kunwu Chan @ 2026-09-27 10:03 UTC (permalink / raw)
  To: dave, paulmck, josh, frederic, neeraj.upadhyay, joelagnelf,
	boqun, urezki
  Cc: rostedt, mathieu.desnoyers, jiangshanlai, qiang.zhang,
	linux-kernel, rcu, Kunwu Chan

Add support for scaling atomic SRCU grace periods using
srcu_read_lock_atomic()/srcu_read_unlock_atomic() and
synchronize_srcu_atomic().

Signed-off-by: Kunwu Chan <kunwu.chan@gmail.com>
---
 kernel/rcu/rcuscale.c | 47 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/kernel/rcu/rcuscale.c b/kernel/rcu/rcuscale.c
index 5aca31c3c01d..86f1a912ebee 100644
--- a/kernel/rcu/rcuscale.c
+++ b/kernel/rcu/rcuscale.c
@@ -264,6 +264,51 @@ static struct rcu_scale_ops srcu_ops = {
 	.name		= "srcu"
 };
 
+static struct srcu_struct srcu_atomic_ctlp;
+
+static int srcu_scale_atomic_read_lock(void)
+{
+	return srcu_read_lock_atomic(&srcu_atomic_ctlp);
+}
+
+static void srcu_scale_atomic_read_unlock(int idx)
+{
+	srcu_read_unlock_atomic(&srcu_atomic_ctlp, idx);
+}
+
+static void srcu_scale_atomic_synchronize(void)
+{
+	synchronize_srcu_atomic(&srcu_atomic_ctlp);
+}
+
+static void srcu_atomic_scale_init(void)
+{
+	init_srcu_struct_atomic(&srcu_atomic_ctlp);
+}
+
+static void srcu_atomic_scale_cleanup(void)
+{
+	cleanup_srcu_struct(&srcu_atomic_ctlp);
+}
+
+static unsigned long srcu_atomic_scale_completed(void)
+{
+	return srcu_batches_completed(&srcu_atomic_ctlp);
+}
+
+static struct rcu_scale_ops srcu_atomic_ops = {
+	.ptype		= SRCU_FLAVOR,
+	.init		= srcu_atomic_scale_init,
+	.cleanup	= srcu_atomic_scale_cleanup,
+	.readlock	= srcu_scale_atomic_read_lock,
+	.readunlock	= srcu_scale_atomic_read_unlock,
+	.get_gp_seq	= srcu_atomic_scale_completed,
+	.gp_diff	= rcu_seq_diff,
+	.exp_completed	= srcu_atomic_scale_completed,
+	.sync		= srcu_scale_atomic_synchronize,
+	.name		= "srcu_atomic"
+};
+
 static struct srcu_struct srcud;
 
 static void srcu_sync_scale_init(void)
@@ -1176,7 +1221,7 @@ rcu_scale_init(void)
 	long i;
 	long j;
 	static struct rcu_scale_ops *scale_ops[] = {
-		&rcu_ops, &srcu_ops, &srcud_ops,
+		&rcu_ops, &srcu_ops, &srcu_atomic_ops, &srcud_ops,
 		TASKS_OPS TASKS_RUDE_OPS TASKS_TRACING_OPS
 		HAZPTR_SCALE_OPS
 	};
-- 
2.43.0


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

end of thread, other threads:[~2026-09-27 20:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-27 10:03 [PATCH] rcuscale: add srcu_atomic scale type Kunwu Chan
2026-09-27 20:00 ` Bradley Morgan

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®