From: Koichiro Den <den@valinux.co.jp>
To: Andrew Jones <andrew.jones@linux.dev>
Cc: Anup Patel <anup@brainfault.org>,
Atish Patra <atish.patra@linux.dev>,
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: Re: [PATCH 2/2] RISC-V: KVM: Skip steal-time updates when run_delay is unchanged
Date: Sat, 21 Nov 2026 02:25:15 +0900 [thread overview]
Message-ID: <awCBn-a_i8k2hkbe@z790sl> (raw)
In-Reply-To: <awB4BxCHBu6nacbO@orel>
On Fri, Nov 20, 2026 at 05:45:09PM +0100, Andrew Jones wrote:
> On Wed, Nov 18, 2026 at 03:22:42PM +0900, Koichiro Den wrote:
> > 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;
> > +
>
> If we move the new check to just below the 'if (shmem == INVALID_GPA)'
> check then we also avoid a memslot lookup.
Indeed. Thanks for pointing that out! Will move the check in v2.
Best regards,
Koichiro Den
>
> > 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
> >
>
> Otherwise,
>
> Reviewed-by: Andrew Jones <andrew.jones@linux.dev>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
prev parent reply other threads:[~2026-11-20 17:25 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 ` [PATCH 2/2] RISC-V: KVM: Skip steal-time updates when run_delay is unchanged Koichiro Den
2026-11-20 16:45 ` Andrew Jones
2026-11-20 17:25 ` Koichiro Den [this message]
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=awCBn-a_i8k2hkbe@z790sl \
--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