[PATCH] KVM: eventfd: Remove redundant synchronize_srcu_expedited from irqfd assignment

lirongqing posted 1 patch 1 month ago
virt/kvm/eventfd.c | 1 -
1 file changed, 1 deletion(-)
[PATCH] KVM: eventfd: Remove redundant synchronize_srcu_expedited from irqfd assignment
Posted by lirongqing 1 month ago
From: Li RongQing <lirongqing@baidu.com>

The synchronize_srcu_expedited() call in kvm_irqfd_assign() is unnecessary
when adding a new irqfd to the resampler list. The list insertion is
already RCU-safe, and existing readers will either see the old or the
updated list without inconsistency. Removing this call reduces latency
during resampling irqfd setup.

Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 virt/kvm/eventfd.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 3201f60..facfeab 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -450,7 +450,6 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
 		}
 
 		list_add_rcu(&irqfd->resampler_link, &irqfd->resampler->list);
-		synchronize_srcu_expedited(&kvm->irq_srcu);
 
 		mutex_unlock(&kvm->irqfds.resampler_lock);
 	}
-- 
2.9.4
Re: [PATCH] KVM: eventfd: Remove redundant synchronize_srcu_expedited from irqfd assignment
Posted by Sean Christopherson 1 month ago
On Mon, Mar 09, 2026, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
> 
> The synchronize_srcu_expedited() call in kvm_irqfd_assign() is unnecessary
> when adding a new irqfd to the resampler list. The list insertion is
> already RCU-safe, and existing readers will either see the old or the
> updated list without inconsistency.

It's not required for kernel safety, but I do think it's required for KVM's ABI,
e.g. to ensure the resampler is visible to readers before KVM_IRQFD returns to
userspace.

> Removing this call reduces latency during resampling irqfd setup.

May I ask why you're micro-optimizing VMs with an in-kernel I/O APIC?

> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> ---
>  virt/kvm/eventfd.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
> index 3201f60..facfeab 100644
> --- a/virt/kvm/eventfd.c
> +++ b/virt/kvm/eventfd.c
> @@ -450,7 +450,6 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
>  		}
>  
>  		list_add_rcu(&irqfd->resampler_link, &irqfd->resampler->list);
> -		synchronize_srcu_expedited(&kvm->irq_srcu);
>  
>  		mutex_unlock(&kvm->irqfds.resampler_lock);
>  	}
> -- 
> 2.9.4
>
答复: [????] Re: [PATCH] KVM: eventfd: Remove redundant synchronize_srcu_expedited from irqfd assignment
Posted by Li,Rongqing(ACG CCN) 1 month ago

> On Mon, Mar 09, 2026, lirongqing wrote:
> > From: Li RongQing <lirongqing@baidu.com>
> >
> > The synchronize_srcu_expedited() call in kvm_irqfd_assign() is
> > unnecessary when adding a new irqfd to the resampler list. The list
> > insertion is already RCU-safe, and existing readers will either see
> > the old or the updated list without inconsistency.
> 
> It's not required for kernel safety, but I do think it's required for KVM's ABI, e.g.
> to ensure the resampler is visible to readers before KVM_IRQFD returns to
> userspace.
> 

Thanks for explanation, It would be best if a comment could be added.

> > Removing this call reduces latency during resampling irqfd setup.
> 
> May I ask why you're micro-optimizing VMst with an in-kernel I/O APIC?

Few devices use it anymore; I just think the kernel ABI shouldn't require synchronize_srcu_expedited.

Thanks

[Li,Rongqing] 
Re: 答复: [????] Re: [PATCH] KVM: eventfd: Remove redundant synchronize_srcu_expedited from irqfd assignment
Posted by Sean Christopherson 1 month ago
On Tue, Mar 10, 2026, Li,Rongqing(ACG CCN) wrote:
> > > Removing this call reduces latency during resampling irqfd setup.
> > 
> > May I ask why you're micro-optimizing VMst with an in-kernel I/O APIC?
> 
> Few devices use it anymore; I just think the kernel ABI shouldn't require
> synchronize_srcu_expedited.

That's a *very* broad stance to take.  For all intents and purposes, eliminating
SRCU synchronization in KVM means eliminating SRCU usage entirely.  That's not
completely infeasible, but I don't see it happening anytime soon given how much
KVM relies on the properties of SRCU to avoid unnecessary serialization.