From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Williamson Subject: Re: [PATCH 3/5] VFIO: Support threaded interrupt handling on VFIO Date: Wed, 16 Dec 2015 12:49:06 -0700 Message-ID: <1450295346.2674.50.camel@redhat.com> References: <1449166972-8894-1-git-send-email-yunhong.jiang@linux.intel.com> <1449166972-8894-4-git-send-email-yunhong.jiang@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org To: Yunhong Jiang , pbonzini@redhat.com Return-path: In-Reply-To: <1449166972-8894-4-git-send-email-yunhong.jiang@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Thu, 2015-12-03 at 10:22 -0800, Yunhong Jiang wrote: > For VFIO device with MSI interrupt type, it's possible to handle the > interrupt on hard interrupt context without invoking the interrupt > thread. Handling the interrupt on hard interrupt context reduce the > interrupt latency. >=20 > Signed-off-by: Yunhong Jiang > --- > =C2=A0drivers/vfio/pci/vfio_pci_intrs.c | 39 ++++++++++++++++++++++++= ++++++++++----- > =C2=A01 file changed, 34 insertions(+), 5 deletions(-) >=20 > diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfi= o_pci_intrs.c > index 3b3ba15558b7..108d335c5656 100644 > --- a/drivers/vfio/pci/vfio_pci_intrs.c > +++ b/drivers/vfio/pci/vfio_pci_intrs.c > @@ -236,12 +236,35 @@ static void vfio_intx_disable(struct vfio_pci_d= evice *vdev) > =C2=A0 kfree(vdev->ctx); > =C2=A0} > =C2=A0 > +static irqreturn_t vfio_msihandler(int irq, void *arg) > +{ > + struct vfio_pci_irq_ctx *ctx =3D arg; > + struct irq_bypass_producer *producer =3D &ctx->producer; > + struct irq_bypass_consumer *consumer; > + int ret =3D IRQ_HANDLED, idx; > + > + idx =3D srcu_read_lock(&producer->srcu); > + > + list_for_each_entry_rcu(consumer, &producer->consumers, sibling) { > + /* > + =C2=A0* Invoke the thread handler if any consumer would block, but > + =C2=A0* finish all consumes. > + =C2=A0*/ > + if (consumer->handle_irq(consumer->irq_context) =3D=3D -EWOULDBLOC= K) > + ret =3D IRQ_WAKE_THREAD; > + continue; > + } > + > + srcu_read_unlock(&producer->srcu, idx); There should be an irq bypass manager interface to abstract this.