mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/5] KVM: riscv: Speed up dirty logging write faults
@ 2026-05-17 15:34 Jinyu Tang
  2026-05-17 15:34 ` [PATCH 1/5] KVM: riscv: Rely on common MMU notifier locking Jinyu Tang
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Jinyu Tang @ 2026-05-17 15:34 UTC (permalink / raw)
  To: Anup Patel, Anup Patel, Paolo Bonzini, Sean Christopherson
  Cc: kvm, kvm-riscv, linux-riscv, linux-kernel, Atish Patra,
	Paul Walmsley, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti, Radim Krčmář,
	Andrew Jones, Conor Dooley, Yong-Xuan Wang, Nutty Liu,
	Jinyu Tang

This series speeds up the common dirty logging write fault path for
RISC-V KVM.

When dirty logging is enabled, guest writes to write-protected G-stage
4K leaves currently go through the full fault path and take mmu_lock for
write.  That is expensive once the leaf already exists and
only needs its permission and dirty state updated.

The series first makes the existing MMU notifier locking contract
explicit, switches RISC-V KVM to KVM's rwlock form of mmu_lock, adds an
atomic G-stage PTE update helper, uses it for existing permission
updates, and finally handles dirty logging write faults under the read
side of mmu_lock when a 4K G-stage leaf is already present.

The locking and concurrency model follows existing KVM patterns from x86
and arm64: use an rwlock mmu_lock, keep structural page-table changes on
the write side, and use atomic PTE updates for permission-only changes
that may race with another vCPU.

The fast path marks the memslot page dirty before making the PTE writable
again.  It also sets the PTE dirty bit, so systems that trap when D is
clear do not fall back to the slow path for a writable-but-clean PTE.

Performance was measured with KVM selftests inside a QEMU RISC-V host.

  dirty_log_perf_test -m 19 -v 4 -b 1G -i 3
    base dirty memory avg, iterations 2-3: 53.262493s
    patch 1-4 dirty memory avg, iterations 2-3: 52.735675s
    patch 1-5 dirty memory avg, iterations 2-3: 26.422964s
    patch 1-5 improvement over base: 50.4%

  dirty_log_perf_test -m 19 -v 4 -b 64M -i 3
    base dirty memory avg, iterations 2-3: 3.203170s
    patch 1-5 dirty memory avg, iterations 2-3: 1.762452s
    improvement: 45.0%

Patch 1-4 are prerequisites for the read-side fast path. The
main speedup comes from patch 5 avoiding the full fault path 
for dirty logging write faults.

Jinyu Tang (5):
  KVM: riscv: Rely on common MMU notifier locking
  KVM: riscv: Use an rwlock for mmu_lock
  KVM: riscv: Add a G-stage PTE cmpxchg helper
  KVM: riscv: Update G-stage PTE permissions atomically
  KVM: riscv: Fast-path dirty logging write faults

 arch/riscv/include/asm/kvm_gstage.h |   4 ++
 arch/riscv/include/asm/kvm_host.h   |   2 +
 arch/riscv/kvm/gstage.c             |  35 +++++++---
 arch/riscv/kvm/mmu.c                | 105 +++++++++++++++++++++++-----
 4 files changed, 122 insertions(+), 24 deletions(-)

-- 
2.43.0


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

end of thread, other threads:[~2026-06-26  8:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-17 15:34 [PATCH 0/5] KVM: riscv: Speed up dirty logging write faults Jinyu Tang
2026-05-17 15:34 ` [PATCH 1/5] KVM: riscv: Rely on common MMU notifier locking Jinyu Tang
2026-05-17 15:34 ` [PATCH 2/5] KVM: riscv: Use an rwlock for mmu_lock Jinyu Tang
2026-05-17 15:34 ` [PATCH 3/5] KVM: riscv: Add a G-stage PTE cmpxchg helper Jinyu Tang
2026-05-17 15:34 ` [PATCH 4/5] KVM: riscv: Update G-stage PTE permissions atomically Jinyu Tang
2026-05-17 15:34 ` [PATCH 5/5] KVM: riscv: Fast-path dirty logging write faults Jinyu Tang
2026-05-28 22:35   ` Inochi Amaoto
2026-06-03 13:12 ` [PATCH 0/5] KVM: riscv: Speed up " Anup Patel
2026-06-26  8:21 ` patchwork-bot+linux-riscv

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®