public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] riscv: KVM: Remove unnecessary vcpu kick
@ 2025-02-21 10:45 BillXiang
  2025-02-21 11:11 ` Andrew Jones
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: BillXiang @ 2025-02-21 10:45 UTC (permalink / raw)
  To: anup
  Cc: ajones, xiangwencheng, kvm-riscv, kvm, linux-riscv, linux-kernel,
	atishp, paul.walmsley, palmer, aou, rkrcmar

Remove the unnecessary kick to the vCPU after writing to the vs_file
of IMSIC in kvm_riscv_vcpu_aia_imsic_inject.

For vCPUs that are running, writing to the vs_file directly forwards
the interrupt as an MSI to them and does not need an extra kick.

For vCPUs that are descheduled after emulating WFI, KVM will enable
the guest external interrupt for that vCPU in
kvm_riscv_aia_wakeon_hgei. This means that writing to the vs_file
will cause a guest external interrupt, which will cause KVM to wake
up the vCPU in hgei_interrupt to handle the interrupt properly.

Signed-off-by: BillXiang <xiangwencheng@lanxincomputing.com>
---
v2: Revise the commit message to ensure it meets the required 
    standards for acceptance

 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);
 	} else {
 		eix = &imsic->swfile->eix[iid / BITS_PER_TYPE(u64)];
 		set_bit(iid & (BITS_PER_TYPE(u64) - 1), eix->eip);
-- 
2.46.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] riscv: KVM: Remove unnecessary vcpu kick
  2025-02-21 10:45 [PATCH v2] riscv: KVM: Remove unnecessary vcpu kick BillXiang
@ 2025-02-21 11:11 ` Andrew Jones
  2025-02-21 11:20 ` Radim Krčmář
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Andrew Jones @ 2025-02-21 11:11 UTC (permalink / raw)
  To: BillXiang
  Cc: anup, kvm-riscv, kvm, linux-riscv, linux-kernel, atishp,
	paul.walmsley, palmer, aou, rkrcmar

On Fri, Feb 21, 2025 at 06:45:38PM +0800, BillXiang wrote:
> Remove the unnecessary kick to the vCPU after writing to the vs_file
> of IMSIC in kvm_riscv_vcpu_aia_imsic_inject.
> 
> For vCPUs that are running, writing to the vs_file directly forwards
> the interrupt as an MSI to them and does not need an extra kick.
> 
> For vCPUs that are descheduled after emulating WFI, KVM will enable
> the guest external interrupt for that vCPU in
> kvm_riscv_aia_wakeon_hgei. This means that writing to the vs_file
> will cause a guest external interrupt, which will cause KVM to wake
> up the vCPU in hgei_interrupt to handle the interrupt properly.
> 
> Signed-off-by: BillXiang <xiangwencheng@lanxincomputing.com>
> ---
> v2: Revise the commit message to ensure it meets the required 
>     standards for acceptance
> 
>  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);
>  	} else {
>  		eix = &imsic->swfile->eix[iid / BITS_PER_TYPE(u64)];
>  		set_bit(iid & (BITS_PER_TYPE(u64) - 1), eix->eip);
> -- 
> 2.46.2

Reviewed-by: Andrew Jones <ajones@ventanamicro.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] riscv: KVM: Remove unnecessary vcpu kick
  2025-02-21 10:45 [PATCH v2] riscv: KVM: Remove unnecessary vcpu kick BillXiang
  2025-02-21 11:11 ` Andrew Jones
@ 2025-02-21 11:20 ` Radim Krčmář
  2025-02-21 17:06 ` Anup Patel
  2025-03-27  3:24 ` patchwork-bot+linux-riscv
  3 siblings, 0 replies; 5+ messages in thread
From: Radim Krčmář @ 2025-02-21 11:20 UTC (permalink / raw)
  To: BillXiang, anup
  Cc: ajones, kvm-riscv, kvm, linux-riscv, linux-kernel, atishp,
	paul.walmsley, palmer, aou

2025-02-21T18:45:38+08:00, BillXiang <xiangwencheng@lanxincomputing.com>:
> Remove the unnecessary kick to the vCPU after writing to the vs_file
> of IMSIC in kvm_riscv_vcpu_aia_imsic_inject.
>
> For vCPUs that are running, writing to the vs_file directly forwards
> the interrupt as an MSI to them and does not need an extra kick.
>
> For vCPUs that are descheduled after emulating WFI, KVM will enable
> the guest external interrupt for that vCPU in
> kvm_riscv_aia_wakeon_hgei. This means that writing to the vs_file
> will cause a guest external interrupt, which will cause KVM to wake
> up the vCPU in hgei_interrupt to handle the interrupt properly.
>
> Signed-off-by: BillXiang <xiangwencheng@lanxincomputing.com>
> ---
> v2: Revise the commit message to ensure it meets the required 
>     standards for acceptance

Nice, thanks.

Reviewed-by: Radim Krčmář <rkrcmar@ventanamicro.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] riscv: KVM: Remove unnecessary vcpu kick
  2025-02-21 10:45 [PATCH v2] riscv: KVM: Remove unnecessary vcpu kick BillXiang
  2025-02-21 11:11 ` Andrew Jones
  2025-02-21 11:20 ` Radim Krčmář
@ 2025-02-21 17:06 ` Anup Patel
  2025-03-27  3:24 ` patchwork-bot+linux-riscv
  3 siblings, 0 replies; 5+ messages in thread
From: Anup Patel @ 2025-02-21 17:06 UTC (permalink / raw)
  To: BillXiang
  Cc: ajones, kvm-riscv, kvm, linux-riscv, linux-kernel, atishp,
	paul.walmsley, palmer, aou, rkrcmar

On Fri, Feb 21, 2025 at 4:16 PM BillXiang
<xiangwencheng@lanxincomputing.com> wrote:
>
> Remove the unnecessary kick to the vCPU after writing to the vs_file
> of IMSIC in kvm_riscv_vcpu_aia_imsic_inject.
>
> For vCPUs that are running, writing to the vs_file directly forwards
> the interrupt as an MSI to them and does not need an extra kick.
>
> For vCPUs that are descheduled after emulating WFI, KVM will enable
> the guest external interrupt for that vCPU in
> kvm_riscv_aia_wakeon_hgei. This means that writing to the vs_file
> will cause a guest external interrupt, which will cause KVM to wake
> up the vCPU in hgei_interrupt to handle the interrupt properly.
>
> Signed-off-by: BillXiang <xiangwencheng@lanxincomputing.com>

Queued this patch as a fix for Linux-6.14-rcX.

Thanks,
Anup

> ---
> v2: Revise the commit message to ensure it meets the required
>     standards for acceptance
>
>  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);
>         } else {
>                 eix = &imsic->swfile->eix[iid / BITS_PER_TYPE(u64)];
>                 set_bit(iid & (BITS_PER_TYPE(u64) - 1), eix->eip);
> --
> 2.46.2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] riscv: KVM: Remove unnecessary vcpu kick
  2025-02-21 10:45 [PATCH v2] riscv: KVM: Remove unnecessary vcpu kick BillXiang
                   ` (2 preceding siblings ...)
  2025-02-21 17:06 ` Anup Patel
@ 2025-03-27  3:24 ` patchwork-bot+linux-riscv
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+linux-riscv @ 2025-03-27  3:24 UTC (permalink / raw)
  To: BillXiang
  Cc: linux-riscv, anup, ajones, kvm-riscv, kvm, linux-kernel, atishp,
	paul.walmsley, palmer, aou, rkrcmar

Hello:

This patch was applied to riscv/linux.git (for-next)
by Anup Patel <anup@brainfault.org>:

On Fri, 21 Feb 2025 18:45:38 +0800 you wrote:
> Remove the unnecessary kick to the vCPU after writing to the vs_file
> of IMSIC in kvm_riscv_vcpu_aia_imsic_inject.
> 
> For vCPUs that are running, writing to the vs_file directly forwards
> the interrupt as an MSI to them and does not need an extra kick.
> 
> For vCPUs that are descheduled after emulating WFI, KVM will enable
> the guest external interrupt for that vCPU in
> kvm_riscv_aia_wakeon_hgei. This means that writing to the vs_file
> will cause a guest external interrupt, which will cause KVM to wake
> up the vCPU in hgei_interrupt to handle the interrupt properly.
> 
> [...]

Here is the summary with links:
  - [v2] riscv: KVM: Remove unnecessary vcpu kick
    https://git.kernel.org/riscv/c/d252435aca44

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-03-27  3:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-21 10:45 [PATCH v2] riscv: KVM: Remove unnecessary vcpu kick BillXiang
2025-02-21 11:11 ` Andrew Jones
2025-02-21 11:20 ` Radim Krčmář
2025-02-21 17:06 ` Anup Patel
2025-03-27  3:24 ` patchwork-bot+linux-riscv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox