mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@kernel.org>
To: David Woodhouse <dwmw2@infradead.org>
Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-team@meta.com, rostedt@goodmis.org
Subject: Re: [PATCH v2 04/21] srcutree: Add an atomic Tree SRCU
Date: Thu, 8 Oct 2026 08:51:21 -0700	[thread overview]
Message-ID: <d1539cc5-0ff3-400e-a487-eedd942cf6f5@paulmck-laptop> (raw)
In-Reply-To: <729dfdb236e4daaf2438b74d4d921993a156ec34.camel@infradead.org>

On Thu, Oct 08, 2026 at 09:39:29AM +0200, David Woodhouse wrote:
> On Wed, 2026-10-07 at 13:59 -0700, Paul E. McKenney wrote:
> > Some dedicated srcu_struct users have read-side critical sections
> > which are short, never sleep, and never block on anything which may
> > itself depend on memory allocation — because they were, until
> > recently, spinlock or rwlock critical sections. For such a domain the
> > update side can safely wait for readers by spinning, from contexts
> > where sleeping is undesirable or the grace-period machinery's
> > latency (workqueue scheduling, jiffy-paced retries) dominates the
> > actual reader drain time.
> > 
> > But that is only safe if every reader keeps the promise. Make the
> > promise explicit and machine-checkable:
> > 
> >  - srcu_read_lock_atomic() / srcu_read_unlock_atomic() enter the
> >    usual (smp_mb-based) read-side critical section with preemption
> >    disabled and (except in hardirq, where it is redundant)
> >    non_block_start() armed, recording SRCU_READ_FLAVOR_ATOMIC in the
> >    per-CPU reader flavor. Disabling preemption enforces the
> >    no-sleeping promise on every configuration and bounds the section,
> >    so it is always running on some CPU; non_block_start() extends the
> >    enforcement to even potentially-sleeping calls on paths which
> >    happen not to block. The existing reader-flavor consistency checks
> >    complain about any mixing with other flavors.
> > 
> >  - synchronize_srcu_atomic() waits for all pre-existing readers by
> >    repeating the try_synchronize_srcu() both-epoch counter proof with
> >    cpu_relax() until it succeeds: no sleeping, no index flip, no
> >    grace-period sequence update, and therefore no interaction with
> >    concurrent call_srcu(), synchronize_srcu() or srcu_barrier(). It
> >    always provides the full grace-period guarantee: if the domain
> >    turns out to have had readers of any other flavor — a caller bug,
> >    since such a reader may be asleep and spinning on it would be
> >    unbounded — it complains and falls back to a real (sleeping) grace
> >    period internally, that being the only correct wait for a
> >    possibly-sleeping reader. The flavor mask is rechecked on every
> >    iteration so a first non-atomic reader appearing mid-spin takes
> >    the same path.
> > 
> > The immediate motivation is the proposed conversion of KVM's
> > gfn_to_pfn_cache to SRCU¹, whose mmu_notifier invalidation path drains
> > readers before the primary MMU zaps a page. With the readers declared
> > atomic, that drain becomes spin-only: no sleeping at all in the
> > notifier, bounded by the longest reader section, satisfying even the
> > strictest reading of the OOM-reaper non-blocking requirement without
> > needing to touch the non_block_start() annotation².
> > 
> > This commit also adds atomic-SRCU-specific initializers:
> > init_srcu_struct_atomic(), DEFINE_SRCU_ATOMIC(), and
> > DEFINE_STATIC_SRCU_ATOMIC().
> > 
> > This commit implements only Tree SRCU.  Tiny SRCU will follow.
> > 
> > ¹ https://lore.kernel.org/all/20260811132237.102400-1-dwmw2@infradead.org/
> > ² https://lore.kernel.org/all/20260812134934.GC662699@ziepe.ca/
> > 
> > [ paulmck: Apply Kunwu Chan feedback. ]
> > 
> > Co-developed-by: David Woodhouse <dwmw2@infradead.org>
> > Signed-off-by: David Woodhouse <dwmw2@infradead.org>
> > Assisted-by: Claude:claude-mythos-5
> > Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> 
> Thank you for seeing this concept through to completion.
> 
> If it isn't already too late (i.e. if it hasn't already made it to a
> tree where changing commit-ids is painful), please could you change my
> attribution to use the dwmw@amazon.co.uk email address for both Co-
> developed-by: and Signed-off-by: tags? I'm fairly sure you made up that
> Signed-off-by: with the infradead address, which is naughty of you :)

Indeed, I would have grabbed the first email I could find from you and
applied the From: field from that email, as opposed to finding the exact
email containing your prototype of the patch and then locating and copying
out the Signed-off-by.  And if I were to happen to find the email that
I am now replying to, I would once again get infradead rather than amazon.

Apologies, but life was flowing fast, and it probably will be from time
to time in the future.  So thank you for checking and please continue
to do so.

> I tell people you should only ever cut-and-paste SoB lines, because
> that way the magic is intact. So here are the two you need for patches
> 4 and 5 of this series:
> 
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>

Thank you again, and I have this note to myself for my next rebase:

a5130cf7b27f ("srcutree: Add an atomic Tree SRCU")
85d5f89bdc42 ("srcutiny: Add an atomic Tiny SRCU")
	Co-developed-by: David Woodhouse <dwmw@amazon.co.uk>
	Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>

Does that cover it?

And while we are discussing, how goes the use case?

							Thanx, Paul

  reply	other threads:[~2026-10-08 15:51 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-07 20:59 [PATCH v2 0/21] Add atomic SRCU &c for v7.4 Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 01/21] srcutiny: Make a Tiny SRCU grace period imply an RCU grace period Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 02/21] srcutree: Suppress srcu_advance_state() mutex_lock in atomic Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 03/21] srcutree: Suppress to-big transition for atomic SRCU Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 04/21] srcutree: Add an atomic Tree SRCU Paul E. McKenney
2026-10-08  7:39   ` David Woodhouse
2026-10-08 15:51     ` Paul E. McKenney [this message]
2026-10-12 12:49       ` David Woodhouse
2026-10-14 21:14         ` Paul E. McKenney
2026-10-14 21:31           ` David Woodhouse
2026-10-14 22:02             ` Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 05/21] srcutiny: Add an atomic Tiny SRCU Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 06/21] rcutorture: Add support for testing synchronize_srcu_atomic() Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 07/21] srcutree: Disable preemption across synchronize_srcu_atomic() Paul E. McKenney
2026-10-23  0:19   ` Joel Fernandes
2026-10-23  2:22     ` Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 08/21] srcu: Use IRQ_WORK_INIT_HARD for srcu's irq_work Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 09/21] srcutree: Warn if Tiny SRCU readers are preempted Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 10/21] srcutree: Explicitly note DEFINE_SRCU() needs for srcu_barrier() Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 11/21] rcutorture: Add atomic-SRCU support to torture.sh Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 12/21] srcutree: Add reader-free fastpath to synchronize_srcu_atomic() Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 13/21] srcutree: Skip callback scheduling for atomic SRCU grace periods Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 14/21] srcutree: Remove srcu_barrier() sleep for atomic SRCU Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 15/21] srcu: Restrict atomic-SRCU non_block annotation to task context Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 16/21] srcutree: Make init_srcu_struct_atomic() prevent transition to big Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 17/21] srcutree: Don't transition atomic SRCU to big in srcu_gp_end() Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 18/21] srcutree: Skip torture to-big transition for atomic SRCU Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 19/21] srcutree: Add lockdep and early-boot checks to synchronize_srcu_atomic() Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 20/21] srcutiny: " Paul E. McKenney
2026-10-07 20:59 ` [PATCH v2 21/21] srcutree: Preserve IRQ state in synchronize_srcu_atomic() callchain 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=d1539cc5-0ff3-400e-a487-eedd942cf6f5@paulmck-laptop \
    --to=paulmck@kernel.org \
    --cc=dwmw2@infradead.org \
    --cc=kernel-team@meta.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®