From: Kunwu Chan <kunwu.chan@gmail.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: Kunwu Chan <kunwu.chan@gmail.com>,
paulmck@kernel.org, jiangshanlai@gmail.com,
josh@joshtriplett.org, rostedt@goodmis.org,
mathieu.desnoyers@efficios.com, rcu@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 03/13] srcutree: Add reader-free fastpath to synchronize_srcu_atomic()
Date: Wed, 9 Sep 2026 11:35:45 +0800 [thread overview]
Message-ID: <20260909033546.2432205-1-kunwu.chan@gmail.com> (raw)
In-Reply-To: <0d4af6318ac67486858be1df8d436147b444a2d2.camel@infradead.org>
On Tue, 08 Sep 2026 23:26:06 +0100 David Woodhouse <dwmw2@infradead.org> wrote:
> On Tue, 2026-09-08 at 13:29 -0700, Paul E. McKenney wrote:
> > On Mon, Sep 07, 2026 at 03:58:19PM +0800, Kunwu Chan wrote:
> > > From: Kunwu Chan <kunwu.chan@gmail.com>
> > >
> > > synchronize_srcu_atomic() is restricted to srcu_read_lock_atomic() and
> > > srcu_read_unlock_atomic(), whose read-side critical sections disable
> > > preemption. In the common case where there are no readers at all, the
> > > grace period therefore need not do the index flip. Add a fastpath
> > > that sums both ranks of the per-CPU ->srcu_ctrs[] counters and, if the
> > > lock counts match the unlock counts on both ranks, ends the grace
> > > period immediately, skipping the srcu_advance_state() scans, mirroring
> > > the similar Tiny SRCU fastpath.
> > >
> > > Correctness requires the counter-sum proof to follow the grace-period
> > > anchor written by srcu_gp_start(); placing it before the anchor could
> > > let this grace period miss a pre-existing reader and return without
> > > waiting for it. The smp_mb() between the unlock and lock sums pairs
> > > with the smp_mb() in __srcu_read_lock(). The grace period is ended
> > > manually under ->lock and ->srcu_atomic_gp_flag.
> > >
> > > Signed-off-by: Kunwu Chan <kunwu.chan@gmail.com>
> >
> > Adding David Woodhouse on CC.
> >
> > David, does this provide appropriate performance in your use case?
>
> Compared with the early bail that I had before, there's a *slight*
> shift into the higher-latency buckets as expected, but definitely not
> enough that I care. We're doing this whole thing to eliminate the
> multi-millisecond p100 latencies that happen when we invoke the
> workqueue, and the differences we're looking at in the table below are
> *well* below what we care about:
>
>
> ┌─────────────┬───────────────────┬───────────────────┬───────┐
> │ bucket │ try-first (#10) │ Kunwu (#11) │ Δ │
> ├─────────────┼───────────────────┼───────────────────┼───────┤
> │ [0,1µs) │ 5,338,474 (60.8%) │ 4,953,657 (56.8%) │ −7% │
> ├─────────────┼───────────────────┼───────────────────┼───────┤
> │ [1,2) │ 1,077,998 │ 1,087,133 │ ≈ │
> ├─────────────┼───────────────────┼───────────────────┼───────┤
> │ [2,4) │ 803,244 │ 790,489 │ ≈ │
> ├─────────────┼───────────────────┼───────────────────┼───────┤
> │ [4,8) │ 811,708 │ 880,673 │ +8% │
> ├─────────────┼───────────────────┼───────────────────┼───────┤
> │ [8,16) │ 366,183 │ 597,443 │ +63% │
> ├─────────────┼───────────────────┼───────────────────┼───────┤
> │ [16,32) │ 338,731 │ 361,243 │ +7% │
> ├─────────────┼───────────────────┼───────────────────┼───────┤
> │ [32,64) │ 14,290 │ 28,823 │ ×2.0 │
> ├─────────────┼───────────────────┼───────────────────┼───────┤
> │ [64,128) │ 2,549 │ 3,655 │ +43% │
> ├─────────────┼───────────────────┼───────────────────┼───────┤
> │ [128,256) │ 555 │ 783 │ +41% │
> ├─────────────┼───────────────────┼───────────────────┼───────┤
> │ [256,512) │ 456 │ 625 │ +37% │
> ├─────────────┼───────────────────┼───────────────────┼───────┤
> │ [512µs+) │ 13 │ 8 │ ≈ │
> ├─────────────┼───────────────────┼───────────────────┼───────┤
> │ max │ 1.07ms │ 1.56ms │ +46% │
> ├─────────────┼───────────────────┼───────────────────┼───────┤
> │ total walks │ 8,777,514 │ 8,723,453 │ −0.6% │
> └─────────────┴───────────────────┴───────────────────┴───────┘
>
> (192-CPU PREEMPT_RT host, 12 concurrent gfn_to_pfn_cache invalidation
> reproducers, 300-second windows; each "walk" is one invalidation drain
> which includes the synchronize_srcu_atomic() call. #10/#11 are just
> local build numbers.)
>
Thanks, David, for testing this with your KVM workload and confirming
the current approach works well.
I’ll keep looking into the fastpath for synchronize_srcu_expedited()
as well, while preserving the existing SRCU semantics.
Thanks,
KunWu
next prev parent reply other threads:[~2026-09-09 3:35 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 7:58 [PATCH 00/13] srcu: Round out atomic SRCU support Kunwu Chan
2026-09-07 7:58 ` [PATCH 01/13] litmus: Add SRCU fastpath anchor-before-scan test Kunwu Chan
2026-09-08 23:58 ` Paul E. McKenney
2026-09-09 3:02 ` Kunwu Chan
2026-09-07 7:58 ` [PATCH 02/13] litmus: Add SRCU fastpath scan-before-anchor test Kunwu Chan
2026-09-07 7:58 ` [PATCH 03/13] srcutree: Add reader-free fastpath to synchronize_srcu_atomic() Kunwu Chan
2026-09-08 20:29 ` Paul E. McKenney
2026-09-08 21:13 ` David Woodhouse
2026-09-08 21:54 ` Paul E. McKenney
2026-09-08 22:09 ` David Woodhouse
2026-09-08 22:55 ` Paul E. McKenney
2026-09-08 22:26 ` David Woodhouse
2026-09-08 22:53 ` Paul E. McKenney
2026-09-08 22:56 ` David Woodhouse
2026-09-08 23:34 ` Paul E. McKenney
2026-09-09 3:35 ` Kunwu Chan [this message]
2026-09-07 7:58 ` [PATCH 04/13] rcutorture: Add atomic-SRCU support to torture.sh Kunwu Chan
2026-09-08 23:34 ` Paul E. McKenney
2026-09-09 22:35 ` Paul E. McKenney
2026-09-10 1:30 ` KunWu Chan
2026-09-10 3:47 ` Paul E. McKenney
2026-09-10 4:31 ` KunWu Chan
2026-09-07 7:58 ` [PATCH 05/13] srcutree: Honor is_atomic in check_init_srcu_struct() Kunwu Chan
2026-09-08 20:27 ` Paul E. McKenney
2026-09-07 7:58 ` [PATCH 06/13] srcutree: Make init_srcu_struct_atomic() prevent transition to big Kunwu Chan
2026-09-08 23:36 ` Paul E. McKenney
2026-09-09 2:34 ` Kunwu Chan
2026-09-10 0:08 ` Paul E. McKenney
2026-09-07 7:58 ` [PATCH 07/13] srcutree: Don't transition atomic SRCU to big in srcu_gp_end() Kunwu Chan
2026-09-08 23:38 ` Paul E. McKenney
2026-09-09 2:45 ` Kunwu Chan
2026-09-10 0:13 ` Paul E. McKenney
2026-09-10 3:18 ` KunWu Chan
2026-09-10 3:46 ` Paul E. McKenney
2026-09-10 4:27 ` KunWu Chan
2026-09-07 7:58 ` [PATCH 08/13] srcutree: Forbid srcu_expedite_current() on atomic SRCU Kunwu Chan
2026-09-08 23:43 ` Paul E. McKenney
2026-09-07 7:58 ` [PATCH 09/13] rcutorture: Disable srcu_expedite_current() for " Kunwu Chan
2026-09-08 23:48 ` Paul E. McKenney
2026-09-07 7:58 ` [PATCH 10/13] srcutree: Skip callback scheduling for atomic SRCU grace periods Kunwu Chan
2026-09-09 0:01 ` Paul E. McKenney
2026-09-07 7:58 ` [PATCH 11/13] srcutree: Remove srcu_barrier() sleep for atomic SRCU Kunwu Chan
2026-09-09 0:05 ` Paul E. McKenney
2026-09-07 7:58 ` [PATCH 12/13] srcutree: Remove debug pr_alert()s Kunwu Chan
2026-09-09 0:06 ` Paul E. McKenney
2026-09-07 7:58 ` [PATCH 13/13] srcu: Restrict atomic-SRCU non_block annotation to task context Kunwu Chan
2026-09-09 0:11 ` Paul E. McKenney
2026-09-10 12:16 ` [PATCH 00/13] srcu: Round out atomic SRCU support Zqiang
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=20260909033546.2432205-1-kunwu.chan@gmail.com \
--to=kunwu.chan@gmail.com \
--cc=dwmw2@infradead.org \
--cc=jiangshanlai@gmail.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=paulmck@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.