diff mbox series

riscv: KVM: Remove unnecessary vcpu kick

Message ID 38cc241c40a8ef2775e304d366bcd07df733ecf0.1d66512d.85e4.41a5.8cf7.4c1fdb05d775@feishu.cn (mailing list archive)
State New
Headers show
Series riscv: KVM: Remove unnecessary vcpu kick | expand

Commit Message

xiangwencheng Feb. 18, 2025, 8 a.m. UTC
From 30dd00f6886119ecc5c39b6b88f8617a57e598fc Mon Sep 17 00:00:00 2001
From: BillXiang <xiangwencheng@lanxincomputing.com>
Date: Tue, 18 Feb 2025 15:45:52 +0800
Subject: [PATCH] riscv: KVM: Remove unnecessary vcpu kick

Hello everyone,
I'm wondering whether it's necessary to kick the virtual hart
after writing to the vsfile of IMSIC.
From my understanding, writing to the vsfile should directly
forward the interrupt as MSI to the virtual hart. This means that
an additional kick should not be necessary, as it would cause the
vCPU to exit unnecessarily and potentially degrade performance.
I've tested this behavior in QEMU, and it seems to work perfectly
fine without the extra kick.
Would appreciate any insights or confirmation on this!
Best regards.

Signed-off-by: BillXiang <xiangwencheng@lanxincomputing.com>
---
 arch/riscv/kvm/aia_imsic.c | 1 -
 1 file changed, 1 deletion(-)

--
2.46.2

Comments

Andrew Jones Feb. 18, 2025, 5:48 p.m. UTC | #1
On Tue, Feb 18, 2025 at 04:00:24PM +0800, 项文成 wrote:
> From 30dd00f6886119ecc5c39b6b88f8617a57e598fc Mon Sep 17 00:00:00 2001
> From: BillXiang <xiangwencheng@lanxincomputing.com>
> Date: Tue, 18 Feb 2025 15:45:52 +0800
> Subject: [PATCH] riscv: KVM: Remove unnecessary vcpu kick
> 
> Hello everyone,
> I'm wondering whether it's necessary to kick the virtual hart
> after writing to the vsfile of IMSIC.
> From my understanding, writing to the vsfile should directly
> forward the interrupt as MSI to the virtual hart. This means that
> an additional kick should not be necessary, as it would cause the
> vCPU to exit unnecessarily and potentially degrade performance.
> I've tested this behavior in QEMU, and it seems to work perfectly
> fine without the extra kick.
> Would appreciate any insights or confirmation on this!
> Best regards.

The above should be in a cover letter so the commit message can
be written following the guidelines of [1]

[1] Documentation/process/submitting-patches.rst

> 
> Signed-off-by: BillXiang <xiangwencheng@lanxincomputing.com>
> ---
>  arch/riscv/kvm/aia_imsic.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/arch/riscv/kvm/aia_imsic.c b/arch/riscv/kvm/aia_imsic.c
> index a8085cd8215e..29ef9c2133a9 100644
> --- a/arch/riscv/kvm/aia_imsic.c
> +++ b/arch/riscv/kvm/aia_imsic.c
> @@ -974,7 +974,6 @@ int kvm_riscv_vcpu_aia_imsic_inject(struct kvm_vcpu *vcpu,
> 
>         if (imsic->vsfile_cpu >= 0) {
>                 writel(iid, imsic->vsfile_va + IMSIC_MMIO_SETIPNUM_LE);
> -               kvm_vcpu_kick(vcpu);

We can't completely remove the kick, but we could replace it with a
kvm_vcpu_wake_up().

There's also a kick in kvm_riscv_vcpu_vstimer_expired() which could be a
kvm_vcpu_wake_up() when hideleg has IRQ_VS_TIMER set (which it currently
always does).

Thanks,
drew

>         } else {
>                 eix = &imsic->swfile->eix[iid / BITS_PER_TYPE(u64)];
>                 set_bit(iid & (BITS_PER_TYPE(u64) - 1), eix->eip);
> --
> 2.46.2
> 
> -- 
> kvm-riscv mailing list
> kvm-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kvm-riscv
diff mbox series

Patch

diff --git a/arch/riscv/kvm/aia_imsic.c b/arch/riscv/kvm/aia_imsic.c
index a8085cd8215e..29ef9c2133a9 100644
--- a/arch/riscv/kvm/aia_imsic.c
+++ b/arch/riscv/kvm/aia_imsic.c
@@ -974,7 +974,6 @@  int kvm_riscv_vcpu_aia_imsic_inject(struct kvm_vcpu *vcpu,

        if (imsic->vsfile_cpu >= 0) {
                writel(iid, imsic->vsfile_va + IMSIC_MMIO_SETIPNUM_LE);
-               kvm_vcpu_kick(vcpu);
        } else {
                eix = &imsic->swfile->eix[iid / BITS_PER_TYPE(u64)];
                set_bit(iid & (BITS_PER_TYPE(u64) - 1), eix->eip);