mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yunhong Jiang <yunhong.jiang@linux.intel.com>
To: alex.williamson@redhat.com, pbonzini@redhat.com
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/5] KVM: Add the irq handling consumer
Date: Thu,  3 Dec 2015 10:22:51 -0800	[thread overview]
Message-ID: <1449166972-8894-5-git-send-email-yunhong.jiang@linux.intel.com> (raw)
In-Reply-To: <1449166972-8894-1-git-send-email-yunhong.jiang@linux.intel.com>

Add an irq_bypass consumer to the KVM eventfd, so that when a MSI interrupt
happens and triggerred from VFIO, it can be handled fast.

Signed-off-by: Yunhong Jiang <yunhong.jiang@linux.intel.com>
---
 include/linux/kvm_irqfd.h |  1 +
 virt/kvm/eventfd.c        | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/include/linux/kvm_irqfd.h b/include/linux/kvm_irqfd.h
index 0c1de05098c8..5573d53ccebb 100644
--- a/include/linux/kvm_irqfd.h
+++ b/include/linux/kvm_irqfd.h
@@ -65,6 +65,7 @@ struct kvm_kernel_irqfd {
 	poll_table pt;
 	struct work_struct shutdown;
 	struct irq_bypass_consumer consumer;
+	struct irq_bypass_consumer fastpath;
 	struct irq_bypass_producer *producer;
 };
 
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index c31d43b762db..b20a2d1bbf73 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -144,6 +144,8 @@ irqfd_shutdown(struct work_struct *work)
 #ifdef CONFIG_HAVE_KVM_IRQ_BYPASS
 	irq_bypass_unregister_consumer(&irqfd->consumer);
 #endif
+	if (irqfd->fastpath.token)
+		irq_bypass_unregister_consumer(&irqfd->fastpath);
 	eventfd_ctx_put(irqfd->eventfd);
 	kfree(irqfd);
 }
@@ -203,6 +205,14 @@ irqfd_wakeup_pollin(struct kvm_kernel_irqfd *irqfd)
 }
 
 static int
+kvm_fastpath_irq(void *arg)
+{
+	struct kvm_kernel_irqfd *irqfd = arg;
+
+	return irqfd_wakeup_pollin(irqfd);
+}
+
+static int
 irqfd_wakeup_pollup(struct kvm_kernel_irqfd *irqfd)
 {
 	struct kvm *kvm = irqfd->kvm;
@@ -296,6 +306,34 @@ int  __attribute__((weak)) kvm_arch_update_irqfd_routing(
 }
 #endif
 
+static int kvm_fastpath_stub(struct irq_bypass_consumer *stub,
+			     struct irq_bypass_producer *stub1)
+{
+	return 0;
+}
+
+static void kvm_fastpath_stub1(struct irq_bypass_consumer *stub,
+			     struct irq_bypass_producer *stub1)
+{
+}
+
+static int setup_fastpath_consumer(struct kvm_kernel_irqfd *irqfd)
+{
+	int ret;
+
+	irqfd->fastpath.token = (void *)irqfd->eventfd;
+	irqfd->fastpath.add_producer = kvm_fastpath_stub;
+	irqfd->fastpath.del_producer = kvm_fastpath_stub1;
+	irqfd->fastpath.handle_irq = kvm_fastpath_irq;
+	irqfd->fastpath.irq_context = irqfd;
+	ret = irq_bypass_register_consumer(&irqfd->fastpath);
+
+	if (ret)
+		/* A special tag to indicate consumer not working */
+		irqfd->fastpath.token = (void *)0;
+	return ret;
+}
+
 static int
 kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
 {
@@ -435,6 +473,10 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
 				irqfd->consumer.token, ret);
 #endif
 
+	if (setup_fastpath_consumer(irqfd))
+		pr_info("irq bypass fastpath consumer (toke %p) registration fails: %d\n",
+				irqfd->eventfd, ret);
+
 	return 0;
 
 fail:
-- 
1.8.3.1


  parent reply	other threads:[~2015-12-03 18:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-03 18:22 [PATCH 0/5] Threaded MSI interrupt for VFIO PCI device Yunhong Jiang
2015-12-03 18:22 ` [PATCH 1/5] KVM: Extract the irqfd_wakeup_pollin/irqfd_wakeup_pollup Yunhong Jiang
2015-12-03 18:22 ` [PATCH 2/5] VIRT: Support runtime irq_bypass consumer Yunhong Jiang
2015-12-16 19:48   ` Alex Williamson
2015-12-03 18:22 ` [PATCH 3/5] VFIO: Support threaded interrupt handling on VFIO Yunhong Jiang
2015-12-16 19:49   ` Alex Williamson
2015-12-03 18:22 ` Yunhong Jiang [this message]
2015-12-04  0:33   ` [PATCH 4/5] KVM: Add the irq handling consumer kbuild test robot
2015-12-03 18:22 ` [PATCH 5/5] KVM: Expose x86 kvm_arch_set_irq_inatomic() Yunhong Jiang
2015-12-03 18:55 ` [PATCH 0/5] Threaded MSI interrupt for VFIO PCI device Alex Williamson
2015-12-03 22:31   ` Yunhong Jiang
2015-12-16 17:56 ` Paolo Bonzini
2015-12-16 19:15   ` Alex Williamson
2015-12-16 21:55     ` Paolo Bonzini
2016-01-06  7:42       ` Yunhong Jiang
2016-01-06  7:40     ` Yunhong Jiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449166972-8894-5-git-send-email-yunhong.jiang@linux.intel.com \
    --to=yunhong.jiang@linux.intel.com \
    --cc=alex.williamson@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®