From: David Woodhouse <dwmw2@infradead.org>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
"Paul E . McKenney" <paulmck@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Frederic Weisbecker <frederic@kernel.org>,
Neeraj Upadhyay <neeraj.upadhyay@kernel.org>,
Joel Fernandes <joelagnelf@nvidia.com>,
Josh Triplett <josh@joshtriplett.org>,
Boqun Feng <boqun@kernel.org>,
Uladzislau Rezki <urezki@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Lai Jiangshan <jiangshanlai@gmail.com>,
Zqiang <qiang.zhang@linux.dev>,
Davidlohr Bueso <dave@stgolabs.net>,
Kunwu Chan <kunwu.chan@gmail.com>,
Puranjay Mohan <puranjay@kernel.org>,
rcu@vger.kernel.org
Subject: Re: [PATCH v2 0/7] srcu: NMI-safe atomic SRCU readers, and their irqsave forms
Date: Wed, 11 Nov 2026 18:53:47 -0700 [thread overview]
Message-ID: <f4e56be61d46472ab1484900ba13bfc6e51a16b6.camel@infradead.org> (raw)
In-Reply-To: <20261111145949.70845-1-mathieu.desnoyers@efficios.com>
[-- Attachment #1: Type: text/plain, Size: 3532 bytes --]
On Wed, 2026-11-11 at 09:59 -0500, Mathieu Desnoyers wrote:
> Hi Paul,
>
> This series adapts atomic SRCU to the needs of RCU pseudo-transactions
> [1], as we discussed [2]. Their readers resolve a proxy within a short
> section, in any context, NMI included. A writer waits for these
> sections without sleeping, from task, softirq or hardirq context.
> Atomic SRCU fits, with one fix, one rule made explicit and two
> additions:
>
> - Patch 1 fixes Tiny synchronize_srcu_atomic(). With
> CONFIG_PREEMPTION=y, it called synchronize_rcu(), which ends an RCU
> grace period on Tiny RCU. That is wrong when the caller is in an
> interrupt handler or within rcu_read_lock().
> - Patch 2 is about calling synchronize_srcu_atomic() from an interrupt
> handler. All calls on that srcu_struct, task context included, must
> then disable interrupts around it. Otherwise, the interrupt handler
> may spin forever on the CPU of a waiter it interrupted. Patch 2
> documents this rule, and warns when it is broken.
> - Patch 3 makes the atomic readers NMI-safe. They use the counter
> increments of __srcu_read_lock_nmisafe(), which keep the full barriers
> that synchronize_srcu_atomic() pairs with.
> - Patch 4 adds srcu_read_lock_atomic_irqsave() and
> srcu_read_unlock_atomic_irqrestore(). They disable interrupts instead
> of preemption, for a domain whose writers wait with interrupts
> disabled.
> - Patch 5 makes rcutorture run readers from NMI, for the NMI-safe reader
> flavors.
> - Patch 6 makes rcutorture alternate the atomic readers of each CPU with
> irqsave readers, with a new atomic_irqsave parameter. It also adds an
> SRCU-P run of this mode to torture.sh.
> - Patch 7 makes rcutorture check what patch 1 fixes.
>
> Patch 2 does not make synchronize_srcu_atomic() disable interrupts
> itself. A reader that disables only preemption may wait for an IPI to
> the waiter's CPU, and that IPI would never run. Only the caller knows
> that its readers disable interrupts.
>
> On architectures without NMI-safe this_cpu_inc(), every atomic reader
> now pays an atomic increment at lock and at unlock. The update side is
> unchanged. On architectures with NMI-safe this_cpu_inc(), such as x86,
> the readers use the same counter increments as before. David agreed to
> the change, as long as synchronize_srcu_atomic() stays within the 4-16us
> it was designed for [3].
Tested-by: David Woodhouse <dwmw@amazon.co.uk>
I gave it a spin on the 192-way Granite Rapids box I've been using for
the KVM gfn-to-pfn-cache conversion to atomic SRCU.
All my torture tests pass, including the mmu_notifier race test which
does a full invalidate/refresh cycle for every one of 5000 event
channel deliveries. That works out at over 1.2 million calls to
synchronize_srcu_atomic() per run, of which 99.4% are below 8µs:
with series without
[4, 8)µs 99.388% 99.458%
[8, 16) 0.583% 0.508%
[16, 32) 0.026% 0.032%
> 32µs 0.003% 0.002%
worst 128-256µs bucket 512µs-1ms bucket
(n) 1235551 1126320
So it's basically identical to the same measurement without your
series, which is fairly much as we expected.
Also, rcutorture with reader_flavor=0x10 ran clean for five minutes,
for whatever that's worth on a config where NEED_SRCU_NMI_SAFE is off.
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 6179 bytes --]
prev parent reply other threads:[~2026-11-12 1:53 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 14:59 Mathieu Desnoyers
2026-11-11 14:59 ` [PATCH v2 1/7] srcutiny: Do not call synchronize_rcu() from synchronize_srcu_atomic() Mathieu Desnoyers
2026-11-11 18:35 ` Paul E. McKenney
2026-11-11 14:59 ` [PATCH v2 2/7] srcu: Rule for using synchronize_srcu_atomic() from interrupt handlers Mathieu Desnoyers
2026-11-11 18:54 ` Paul E. McKenney
2026-11-11 14:59 ` [PATCH v2 3/7] srcu: Make atomic SRCU readers NMI-safe Mathieu Desnoyers
2026-11-11 19:55 ` Paul E. McKenney
2026-11-11 14:59 ` [PATCH v2 4/7] srcu: Add irqsave variants of the atomic SRCU readers Mathieu Desnoyers
2026-11-11 19:58 ` Paul E. McKenney
2026-11-11 20:04 ` Paul E. McKenney
2026-11-11 20:13 ` Mathieu Desnoyers
2026-11-12 0:07 ` Paul E. McKenney
2026-11-12 1:32 ` Mathieu Desnoyers
2026-11-12 2:13 ` Paul E. McKenney
2026-11-11 14:59 ` [PATCH v2 5/7] rcutorture: Run NMI-safe SRCU readers from NMI Mathieu Desnoyers
2026-11-12 0:39 ` Paul E. McKenney
2026-11-11 14:59 ` [PATCH v2 6/7] rcutorture: Test the irqsave forms of atomic SRCU readers Mathieu Desnoyers
2026-11-12 0:45 ` Paul E. McKenney
2026-11-11 14:59 ` [PATCH v2 7/7] rcutorture: Check an atomic SRCU wait within an RCU reader Mathieu Desnoyers
2026-11-12 0:46 ` Paul E. McKenney
2026-11-11 19:02 ` [PATCH v2 0/7] srcu: NMI-safe atomic SRCU readers, and their irqsave forms David Woodhouse
2026-11-11 19:33 ` Mathieu Desnoyers
2026-11-11 19:35 ` Paul E. McKenney
2026-11-11 19:37 ` David Woodhouse
2026-11-11 19:40 ` Mathieu Desnoyers
2026-11-11 19:50 ` Paul E. McKenney
2026-11-11 19:34 ` Paul E. McKenney
2026-11-12 1:53 ` David Woodhouse [this message]
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=f4e56be61d46472ab1484900ba13bfc6e51a16b6.camel@infradead.org \
--to=dwmw2@infradead.org \
--cc=boqun@kernel.org \
--cc=dave@stgolabs.net \
--cc=frederic@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=joelagnelf@nvidia.com \
--cc=josh@joshtriplett.org \
--cc=kunwu.chan@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=neeraj.upadhyay@kernel.org \
--cc=paulmck@kernel.org \
--cc=puranjay@kernel.org \
--cc=qiang.zhang@linux.dev \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=urezki@gmail.com \
/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®