mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Koichiro Den <den@valinux.co.jp>
To: Anup Patel <anup@brainfault.org>,
	Atish Patra <atish.patra@linux.dev>,
	Andrew Jones <andrew.jones@linux.dev>
Cc: Paul Walmsley <pjw@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>,
	Bingyu Xian <shanbeeyoo@gmail.com>,
	kvm@vger.kernel.org, kvm-riscv@lists.infradead.org,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 0/3] RISC-V: KVM: Lessen steal time update overhead
Date: Sun, 22 Nov 2026 02:35:23 +0900	[thread overview]
Message-ID: <20261121173526.892344-1-den@valinux.co.jp> (raw)

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@valinux.co.jp/


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


             reply	other threads:[~2026-11-21 17:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21 17:35 Koichiro Den [this message]
2026-11-21 17:35 ` [PATCH v2 1/3] RISC-V: KVM: Order writes to the SBI STA shared structure Koichiro Den
2026-11-21 17:35 ` [PATCH v2 2/3] RISC-V: KVM: Batch user accesses when updating steal time Koichiro Den
2026-11-21 17:35 ` [PATCH v2 3/3] RISC-V: KVM: Skip steal-time updates when run_delay is unchanged Koichiro Den

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=20261121173526.892344-1-den@valinux.co.jp \
    --to=den@valinux.co.jp \
    --cc=alex@ghiti.fr \
    --cc=andrew.jones@linux.dev \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=atish.patra@linux.dev \
    --cc=kvm-riscv@lists.infradead.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=shanbeeyoo@gmail.com \
    /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®