From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966794AbbLPTtL (ORCPT ); Wed, 16 Dec 2015 14:49:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41510 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966681AbbLPTtH (ORCPT ); Wed, 16 Dec 2015 14:49:07 -0500 Message-ID: <1450295346.2674.50.camel@redhat.com> Subject: Re: [PATCH 3/5] VFIO: Support threaded interrupt handling on VFIO From: Alex Williamson To: Yunhong Jiang , pbonzini@redhat.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 16 Dec 2015 12:49:06 -0700 In-Reply-To: <1449166972-8894-4-git-send-email-yunhong.jiang@linux.intel.com> References: <1449166972-8894-1-git-send-email-yunhong.jiang@linux.intel.com> <1449166972-8894-4-git-send-email-yunhong.jiang@linux.intel.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@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. > > Signed-off-by: Yunhong Jiang > --- >  drivers/vfio/pci/vfio_pci_intrs.c | 39 ++++++++++++++++++++++++++++++++++----- >  1 file changed, 34 insertions(+), 5 deletions(-) > > diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_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_device *vdev) >   kfree(vdev->ctx); >  } >   > +static irqreturn_t vfio_msihandler(int irq, void *arg) > +{ > + struct vfio_pci_irq_ctx *ctx = arg; > + struct irq_bypass_producer *producer = &ctx->producer; > + struct irq_bypass_consumer *consumer; > + int ret = IRQ_HANDLED, idx; > + > + idx = srcu_read_lock(&producer->srcu); > + > + list_for_each_entry_rcu(consumer, &producer->consumers, sibling) { > + /* > +  * Invoke the thread handler if any consumer would block, but > +  * finish all consumes. > +  */ > + if (consumer->handle_irq(consumer->irq_context) == -EWOULDBLOCK) > + ret = IRQ_WAKE_THREAD; > + continue; > + } > + > + srcu_read_unlock(&producer->srcu, idx); There should be an irq bypass manager interface to abstract this.