Re: [PATCH v2 0/3] RISC-V: KVM: Lessen steal time update overhead

From: Anup Patel

Date: Sun Nov 29 2026 - 07:31:02 EST


On Sat, Nov 21, 2026 at 11:05 PM Koichiro Den <den@xxxxxxxxxxxxx> wrote:
>
> 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 2900.01 ns 2669.59 ns (-7.95%)
> contended 2876.42 ns 2670.01 ns (-7.18%)
>
> 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
> ---
> v1->v2 changes:
> - Address Andrew's feedback. See the individual patches for details.
> - Rerun the benchmark on SpacemiT K3 and update the results.
> - Add Andrew's Reviewed-by to patch 3.
>
> v1: https://lore.kernel.org/r/20261118062242.2914385-1-den@xxxxxxxxxxxxx/
>
>
> Koichiro Den (3):
> RISC-V: KVM: Order writes to the SBI STA shared structure
> 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 | 68 ++++++++++++++++++++---------------
> 1 file changed, 39 insertions(+), 29 deletions(-)
>
>
> base-commit: e9bf49bbc4227048685c78f97e1446845760df4f
> --
> 2.54.0
>

Queued this series for Linux-7.5

Thanks,
Anup