mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kunwu Chan <kunwu.chan@gmail.com>
To: paulmck@kernel.org, rcu@vger.kernel.org
Cc: dwmw2@infradead.org, jiangshanlai@gmail.com,
	josh@joshtriplett.org, work@onurozkan.dev, rostedt@goodmis.org,
	mathieu.desnoyers@efficios.com, dave@stgolabs.net,
	jfern@kernel.org, frederic@kernel.org,
	neeraj.upadhyay@kernel.org, boqun@kernel.org, urezki@gmail.com,
	qiang.zhang@linux.dev, puranjay@kernel.org, shuah@kernel.org,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	Kunwu Chan <kunwu.chan@gmail.com>
Subject: [PATCH 00/17] srcu: Try idle expedited GPs in the caller
Date: Wed,  2 Dec 2026 00:17:58 +0800	[thread overview]
Message-ID: <20261201161815.1637481-1-kunwu.chan@gmail.com> (raw)

David Woodhouse asked for the reader-free fastpath to also be used
from synchronize_srcu_expedited(). On eligible idle Tree SRCU domains
with full-barrier readers, this series tries to finish an expedited
grace period in the caller: when both ordered reader scans pass, the
caller avoids queueing its completion callback,
sleeping and being woken by the worker.

The attempt uses the normal grace-period completion path and
preserves the guarantee that a cookie obtained before
synchronize_srcu_expedited() polls complete after it
returns.

Preemption is disabled before either mutex is taken and held
across both. If either scan misses after the grace period starts,
irq_work is queued before the mutexes are released so the worker can
continue that grace period while the caller falls back to the normal
synchronous wait.

In nested x86 KVM tests with the vCPU stopped and no bus
registration, memslot move p50 fell from 8.95 to 5.15 and from 12.58
to 4.77 us in two paired groups. Immediately after MMIO eventfd
registration, the first wait always entered with a grace period
already in flight and used the worker, so p50 stayed near 19.6 ms;
the second wait completed in the caller in under a microsecond.

With one sleep between calls, single-writer expedited API p50 fell
from 17.2 to 3.0 us on four-vCPU x86 RT BIG and from 24.1 to 5.8 us on
32-vCPU arm64 RT BIG. With two arm64 writers, p50 stayed near 39 us,
and the x86 RT SMALL two-writer p99 rose in two of three pairs and
fell in the third.

In an unbroken FIFO loop, the first sequence-maintenance fallback
keeps later calls on the worker: the fallback callback wakes the
writer before the worker drops the callback count, so the callback
queue never looks empty. A sleep between calls drains the count and
restores caller completion.

Patches 1-4 prepare, implement and tune the caller path.
Patches 5-11 add parser selftests, report completed writer waits
and add optional expedited wait bursts.
Patches 12-17 print one final NMI coverage record after the
producers stop and callbacks drain, check it and document the workload.

A successful run without the requested NMI activity reports SKIP,
and a missing or invalid final record reports FAIL.

Tested on x86-64 and arm64 KVM. The base and every patch built with
W=1 in ordinary and PREEMPT_RT configurations (36 x86 builds, plus
the arm64 base and tip).

All 43 x86 KVM runs met their expected results:
SMALL and BIG exercised NMI readers and callbacks, both
PMU-off runs reported SKIP, and 60-second hotplug runs matched
NMI callback counts.

Directed trace runs covered caller completion and both forced scan
misses, with the worker finishing the original
grace period before the caller queued its fallback in both cases.
Two arm64 RT runs converted SMALL to BIG at runtime. Eight LKMM litmus
cases gave the expected results, and the writer-progress and NMI
shell suites passed 33 and 31 cases under mawk, gawk and BusyBox awk.
The documented x86 kvm.sh recipe needs the separate QEMU CPU-selection
fix; the guest tests set the CPU option directly.


Kunwu Chan (17):
  srcu: Move callback mutex acquisition to the GP end wrapper
  srcu: Let GP completion take a size-state snapshot
  srcu: Try idle expedited GPs in the caller
  srcu: Check only the boot CPU callback queue in SMALL domains
  rcutorture: Add selftests for console writer progress
  rcutorture: Compare console version counters exactly
  rcutorture: Recognize completed writer waits in console logs
  rcutorture: Emit the version with the statistics prefix
  rcutorture: Report completed synchronous writer waits
  rcutorture: Use writer wait counts in kernel stall diagnostics
  rcutorture: Add consecutive expedited waits per writer iteration
  rcutorture: Check NMI coverage
  rcutorture: Test NMI coverage result classification
  rcutorture: Test NMI summary field validation
  rcutorture: Test NMI console-log boundaries
  rcutorture: Document how to check SRCU NMI coverage
  rcutorture: Document directed SRCU NMI tests

 Documentation/RCU/torture.rst                 | 101 ++++++++++
 .../admin-guide/kernel-parameters.txt         |   5 +
 kernel/rcu/rcutorture.c                       |  67 +++++--
 kernel/rcu/srcutree.c                         | 150 ++++++++++++++-
 .../rcutorture/bin/kvm-recheck-nmi-test.sh    | 172 ++++++++++++++++++
 .../rcutorture/bin/kvm-recheck-nmi.sh         |  72 ++++++++
 .../bin/parse-console-progress-test.sh        | 123 +++++++++++++
 .../selftests/rcutorture/bin/parse-console.sh |  46 ++++-
 8 files changed, 710 insertions(+), 26 deletions(-)
 create mode 100755 tools/testing/selftests/rcutorture/bin/kvm-recheck-nmi-test.sh
 create mode 100755 tools/testing/selftests/rcutorture/bin/kvm-recheck-nmi.sh
 create mode 100755 tools/testing/selftests/rcutorture/bin/parse-console-progress-test.sh


base-commit: 68dcfb0e34ee3a9628f6b5ce7e06931b5248bb9e
-- 
2.43.0


             reply	other threads:[~2026-12-01 16:18 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 16:17 Kunwu Chan [this message]
2026-12-01 16:17 ` [PATCH 01/17] srcu: Move callback mutex acquisition to the GP end wrapper Kunwu Chan
2026-12-01 16:18 ` [PATCH 02/17] srcu: Let GP completion take a size-state snapshot Kunwu Chan
2026-12-01 16:18 ` [PATCH 03/17] srcu: Try idle expedited GPs in the caller Kunwu Chan
2026-12-01 16:18 ` [PATCH 04/17] srcu: Check only the boot CPU callback queue in SMALL domains Kunwu Chan
2026-12-01 16:18 ` [PATCH 05/17] rcutorture: Add selftests for console writer progress Kunwu Chan
2026-12-01 16:18 ` [PATCH 06/17] rcutorture: Compare console version counters exactly Kunwu Chan
2026-12-01 16:18 ` [PATCH 07/17] rcutorture: Recognize completed writer waits in console logs Kunwu Chan
2026-12-01 16:18 ` [PATCH 08/17] rcutorture: Emit the version with the statistics prefix Kunwu Chan
2026-12-01 16:18 ` [PATCH 09/17] rcutorture: Report completed synchronous writer waits Kunwu Chan
2026-12-01 16:18 ` [PATCH 10/17] rcutorture: Use writer wait counts in kernel stall diagnostics Kunwu Chan
2026-12-01 16:18 ` [PATCH 11/17] rcutorture: Add consecutive expedited waits per writer iteration Kunwu Chan
2026-12-01 16:18 ` [PATCH 12/17] rcutorture: Check NMI coverage Kunwu Chan
2026-12-01 16:18 ` [PATCH 13/17] rcutorture: Test NMI coverage result classification Kunwu Chan
2026-12-01 16:18 ` [PATCH 14/17] rcutorture: Test NMI summary field validation Kunwu Chan
2026-12-01 16:18 ` [PATCH 15/17] rcutorture: Test NMI console-log boundaries Kunwu Chan
2026-12-01 16:18 ` [PATCH 16/17] rcutorture: Document how to check SRCU NMI coverage Kunwu Chan
2026-12-01 16:18 ` [PATCH 17/17] rcutorture: Document directed SRCU NMI tests Kunwu Chan

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=20261201161815.1637481-1-kunwu.chan@gmail.com \
    --to=kunwu.chan@gmail.com \
    --cc=boqun@kernel.org \
    --cc=dave@stgolabs.net \
    --cc=dwmw2@infradead.org \
    --cc=frederic@kernel.org \
    --cc=jfern@kernel.org \
    --cc=jiangshanlai@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@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=shuah@kernel.org \
    --cc=urezki@gmail.com \
    --cc=work@onurozkan.dev \
    /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®