[PATCH 0/2] RISC-V: KVM: Lessen steal time update overhead
From: Koichiro Den
Date: Wed Nov 18 2026 - 01:22:59 EST
Hi,
For guests that register an SBI STA shared-memory area, this small patch
set reduces update overhead by batching user accesses and also skipping
updates when run_delay is unchanged.
Tested on SpacemiT K3:
The benchmark uses KVM selftest helpers. The guest registers its STA
shared memory and calls GUEST_UCALL_NONE() in a loop. The vCPU thread is
pinned to one host CPU and re-enters KVM_RUN after each exit.
The table shows the median vCPU thread CPU time per round trip (from
host userspace to the guest and back), measured with
CLOCK_THREAD_CPUTIME_ID. Each case has five runs of 1,000,000
iterations, preceded by 10,000 warm-up iterations per run.
Below, "contended" adds a busy loop on that CPU.
Before After
------------ ---------- -------------------
uncontended 2966.51 ns 2703.26 ns (-8.87%)
contended 2973.46 ns 2717.72 ns (-8.60%)
Based off of riscv_kvm_next, commit e9bf49bbc422 ("RISC-V: KVM: Fix
G-stage page table memory leak on VM destroy")
Best regards,
Koichiro Den
Koichiro Den (2):
RISC-V: KVM: Batch user accesses when updating steal time
RISC-V: KVM: Skip steal-time updates when run_delay is unchanged
arch/riscv/kvm/vcpu_sbi_sta.c | 61 +++++++++++++++++++++--------------
1 file changed, 37 insertions(+), 24 deletions(-)
base-commit: e9bf49bbc4227048685c78f97e1446845760df4f
--
2.54.0