diff mbox

[RFC,v1,5/5] Call irqbypass update routine when updating irqfd

Message ID 1436497207-4786-6-git-send-email-feng.wu@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wu, Feng July 10, 2015, 3 a.m. UTC
Call update routine when updating irqfd, this can update the
IRTE for Intel posted-interrupts.

Signed-off-by: Feng Wu <feng.wu@intel.com>
---
 virt/kvm/eventfd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Alex Williamson July 10, 2015, 3:26 a.m. UTC | #1
On Fri, 2015-07-10 at 11:00 +0800, Feng Wu wrote:
> Call update routine when updating irqfd, this can update the
> IRTE for Intel posted-interrupts.
> 
> Signed-off-by: Feng Wu <feng.wu@intel.com>
> ---
>  virt/kvm/eventfd.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
> index a32cf6c..1226835 100644
> --- a/virt/kvm/eventfd.c
> +++ b/virt/kvm/eventfd.c
> @@ -570,8 +570,10 @@ void kvm_irq_routing_update(struct kvm *kvm)
>  
>  	spin_lock_irq(&kvm->irqfds.lock);
>  
> -	list_for_each_entry(irqfd, &kvm->irqfds.items, list)
> +	list_for_each_entry(irqfd, &kvm->irqfds.items, list) {
>  		irqfd_update(kvm, irqfd);
> +		irqfd->consumer.update(&irqfd->consumer);
> +	}
>  
>  	spin_unlock_irq(&kvm->irqfds.lock);
>  }

I don't understand why the irq bypass manager needs to know about this
update callback.  We could just as easily make it be a function pointer
on the irqfd structure or maybe just open code it.  It's defined by the
consumer and called by the consumer, the irq bypass manager shouldn't
know about it.  Thanks,

Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Wu, Feng July 10, 2015, 4:12 a.m. UTC | #2
> -----Original Message-----

> From: kvm-owner@vger.kernel.org [mailto:kvm-owner@vger.kernel.org] On

> Behalf Of Alex Williamson

> Sent: Friday, July 10, 2015 11:26 AM

> To: Wu, Feng

> Cc: kvm@vger.kernel.org; pbonzini@redhat.com; joro@8bytes.org;

> avi.kivity@gmail.com; eric.auger@linaro.org

> Subject: Re: [RFC v1 5/5] Call irqbypass update routine when updating irqfd

> 

> On Fri, 2015-07-10 at 11:00 +0800, Feng Wu wrote:

> > Call update routine when updating irqfd, this can update the

> > IRTE for Intel posted-interrupts.

> >

> > Signed-off-by: Feng Wu <feng.wu@intel.com>

> > ---

> >  virt/kvm/eventfd.c | 4 +++-

> >  1 file changed, 3 insertions(+), 1 deletion(-)

> >

> > diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c

> > index a32cf6c..1226835 100644

> > --- a/virt/kvm/eventfd.c

> > +++ b/virt/kvm/eventfd.c

> > @@ -570,8 +570,10 @@ void kvm_irq_routing_update(struct kvm *kvm)

> >

> >  	spin_lock_irq(&kvm->irqfds.lock);

> >

> > -	list_for_each_entry(irqfd, &kvm->irqfds.items, list)

> > +	list_for_each_entry(irqfd, &kvm->irqfds.items, list) {

> >  		irqfd_update(kvm, irqfd);

> > +		irqfd->consumer.update(&irqfd->consumer);

> > +	}

> >

> >  	spin_unlock_irq(&kvm->irqfds.lock);

> >  }

> 

> I don't understand why the irq bypass manager needs to know about this

> update callback.  We could just as easily make it be a function pointer

> on the irqfd structure or maybe just open code it.  It's defined by the

> consumer and called by the consumer, the irq bypass manager shouldn't

> know about it.  Thanks,


Yes, you are right. All we need is the producer information which has been
passed in the register routine. And we can easily make this update logic
inside the consumer. Thanks for your comments!

Thanks,
Feng

> 

> Alex

> 

> --

> To unsubscribe from this list: send the line "unsubscribe kvm" in

> the body of a message to majordomo@vger.kernel.org

> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Wu, Feng July 10, 2015, 8:28 a.m. UTC | #3
DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogV3UsIEZlbmcNCj4gU2Vu
dDogRnJpZGF5LCBKdWx5I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Vuc3Vic2NyaWJlIGt2bSIgaW4NCj4gPiB0aGUgYm9keSBvZiBh
IG1lc3NhZ2UgdG8gbWFqb3Jkb21vQHZnZXIua2VybmVsLm9yZw0KPiA+IE1vcmUgbWFqb3Jkb21v
IGluZm8gYXQgIGh0dHA6Ly92Z2VyLmtlcm5lbC5vcmcvbWFqb3Jkb21vLWluZm8uaHRtbA0K
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paolo Bonzini July 10, 2015, 12:47 p.m. UTC | #4
On 10/07/2015 10:28, Wu, Feng wrote:
> > Yes, you are right. All we need is the producer information which has been
> > passed in the register routine. And we can easily make this update logic
> > inside the consumer. Thanks for your comments!
> 
> BTW, Paolo & Alex, in VFIO framework, how can we know a vCPU or a guest
> has assigned devices to it?

See here:
http://article.gmane.org/gmane.comp.emulators.kvm.devel/137930/raw

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alex Williamson July 10, 2015, 2:11 p.m. UTC | #5
On Fri, 2015-07-10 at 14:47 +0200, Paolo Bonzini wrote:
> 
> On 10/07/2015 10:28, Wu, Feng wrote:
> > > Yes, you are right. All we need is the producer information which has been
> > > passed in the register routine. And we can easily make this update logic
> > > inside the consumer. Thanks for your comments!
> > 
> > BTW, Paolo & Alex, in VFIO framework, how can we know a vCPU or a guest
> > has assigned devices to it?
> 
> See here:
> http://article.gmane.org/gmane.comp.emulators.kvm.devel/137930/raw


In general, VFIO has zero visibility into KVM.  VFIO doesn't know or
care what the userspace driver is, whether it's QEMU/KVM, a set of ruby
bindings for VFIO, a DPDK library, etc.  As Paolo points out, KVM does
have ways to be told about assigned devices from userspace and probe
some properties, like whether the IOMMU allows non-coherent DMA.  These
are handled by the KVM-VFIO pseudo device (virt/kvm/vfio.c).  Thanks,

Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index a32cf6c..1226835 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -570,8 +570,10 @@  void kvm_irq_routing_update(struct kvm *kvm)
 
 	spin_lock_irq(&kvm->irqfds.lock);
 
-	list_for_each_entry(irqfd, &kvm->irqfds.items, list)
+	list_for_each_entry(irqfd, &kvm->irqfds.items, list) {
 		irqfd_update(kvm, irqfd);
+		irqfd->consumer.update(&irqfd->consumer);
+	}
 
 	spin_unlock_irq(&kvm->irqfds.lock);
 }