From: Koichiro Den <den@valinux.co.jp>
To: Anup Patel <anup@brainfault.org>, Atish Patra <atish.patra@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 2/2] RISC-V: KVM: Skip steal-time updates when run_delay is unchanged
Date: Wed, 18 Nov 2026 15:22:42 +0900 [thread overview]
Message-ID: <20261118062242.2914385-3-den@valinux.co.jp> (raw)
In-Reply-To: <20261118062242.2914385-1-den@valinux.co.jp>
Check run_delay against last_steal and skip the update if they match.
This avoids accessing the SBI STA shared structure and marking its page
dirty on vCPU loads with no new steal time to report.
Signed-off-by: Koichiro Den <den@valinux.co.jp>
---
arch/riscv/kvm/vcpu_sbi_sta.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/riscv/kvm/vcpu_sbi_sta.c b/arch/riscv/kvm/vcpu_sbi_sta.c
index cfc6f22c3e33..8b2499876fb4 100644
--- a/arch/riscv/kvm/vcpu_sbi_sta.c
+++ b/arch/riscv/kvm/vcpu_sbi_sta.c
@@ -31,7 +31,7 @@ void kvm_riscv_vcpu_record_steal_time(struct kvm_vcpu *vcpu)
__le32 sequence_le;
__le64 steal_le;
u32 sequence;
- u64 steal;
+ u64 steal, run_delay;
unsigned long hva;
bool dirty = false, success = false;
gfn_t gfn;
@@ -52,6 +52,10 @@ void kvm_riscv_vcpu_record_steal_time(struct kvm_vcpu *vcpu)
return;
}
+ run_delay = READ_ONCE(current->sched_info.run_delay);
+ if (run_delay == last_steal)
+ return;
+
st = (struct sbi_sta_struct __user *)(hva + offset_in_page(shmem));
might_fault();
if (WARN_ON(!user_access_begin(st, sizeof(*st))))
@@ -66,7 +70,7 @@ void kvm_riscv_vcpu_record_steal_time(struct kvm_vcpu *vcpu)
smp_wmb();
unsafe_get_user(steal_le, &st->steal, update_sequence);
steal = le64_to_cpu(steal_le);
- vcpu->arch.sta.last_steal = READ_ONCE(current->sched_info.run_delay);
+ vcpu->arch.sta.last_steal = run_delay;
steal += vcpu->arch.sta.last_steal - last_steal;
unsafe_put_user(cpu_to_le64(steal), &st->steal, update_sequence);
success = true;
--
2.54.0
next prev parent reply other threads:[~2026-11-18 6:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 6:22 [PATCH 0/2] RISC-V: KVM: Lessen steal time update overhead Koichiro Den
2026-11-18 6:22 ` [PATCH 1/2] RISC-V: KVM: Batch user accesses when updating steal time Koichiro Den
2026-11-20 16:40 ` Andrew Jones
2026-11-20 17:20 ` Koichiro Den
2026-11-18 6:22 ` Koichiro Den [this message]
2026-11-20 16:45 ` [PATCH 2/2] RISC-V: KVM: Skip steal-time updates when run_delay is unchanged Andrew Jones
2026-11-20 17:25 ` 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=20261118062242.2914385-3-den@valinux.co.jp \
--to=den@valinux.co.jp \
--cc=alex@ghiti.fr \
--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®