* [v3 1/5] KVM: x86: select IRQ_BYPASS_MANAGER
2015-07-29 8:46 [v3 0/5] KVM: irqfd consumer based on IRQ bypass manager Feng Wu
@ 2015-07-29 8:46 ` Feng Wu
2015-07-29 8:47 ` [v3 2/5] KVM: arm/arm64: " Feng Wu
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Feng Wu @ 2015-07-29 8:46 UTC (permalink / raw)
To: linux-kernel, kvm; +Cc: pbonzini, alex.williamson, joro, eric.auger, feng.wu
Select IRQ_BYPASS_MANAGER for x86 when CONFIG_KVM is set
Signed-off-by: Feng Wu <feng.wu@intel.com>
---
arch/x86/kvm/Kconfig | 2 ++
arch/x86/kvm/Makefile | 3 +++
2 files changed, 5 insertions(+)
diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig
index d8a1d56..c951d44 100644
--- a/arch/x86/kvm/Kconfig
+++ b/arch/x86/kvm/Kconfig
@@ -3,6 +3,7 @@
#
source "virt/kvm/Kconfig"
+source "virt/lib/Kconfig"
menuconfig VIRTUALIZATION
bool "Virtualization"
@@ -28,6 +29,7 @@ config KVM
select ANON_INODES
select HAVE_KVM_IRQCHIP
select HAVE_KVM_IRQFD
+ select IRQ_BYPASS_MANAGER
select HAVE_KVM_IRQ_ROUTING
select HAVE_KVM_EVENTFD
select KVM_APIC_ARCHITECTURE
diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile
index 67d215c..05cc2d7 100644
--- a/arch/x86/kvm/Makefile
+++ b/arch/x86/kvm/Makefile
@@ -6,6 +6,9 @@ CFLAGS_svm.o := -I.
CFLAGS_vmx.o := -I.
KVM := ../../../virt/kvm
+LIB := ../../../virt/lib
+
+obj-$(CONFIG_IRQ_BYPASS_MANAGER) += $(LIB)/
kvm-y += $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o \
$(KVM)/eventfd.o $(KVM)/irqchip.o $(KVM)/vfio.o
--
2.1.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [v3 2/5] KVM: arm/arm64: select IRQ_BYPASS_MANAGER
2015-07-29 8:46 [v3 0/5] KVM: irqfd consumer based on IRQ bypass manager Feng Wu
2015-07-29 8:46 ` [v3 1/5] KVM: x86: select IRQ_BYPASS_MANAGER Feng Wu
@ 2015-07-29 8:47 ` Feng Wu
2015-07-29 8:47 ` [v3 3/5] KVM: create kvm_irqfd.h Feng Wu
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Feng Wu @ 2015-07-29 8:47 UTC (permalink / raw)
To: linux-kernel, kvm; +Cc: pbonzini, alex.williamson, joro, eric.auger, feng.wu
From: Eric Auger <eric.auger@linaro.org>
Select IRQ_BYPASS_MANAGER when CONFIG_KVM is set
v2 -> v3:
- Correct a typo in 'arch/arm64/kvm/Kconfig'
v1 -> v2:
- also set IRQ_BYPASS_MANAGER for arm64
Signed-off-by: Eric Auger <eric.auger@linaro.org>
Signed-off-by: Feng Wu <feng.wu@intel.com>
---
arch/arm/kvm/Kconfig | 1 +
arch/arm64/kvm/Kconfig | 1 +
2 files changed, 2 insertions(+)
diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig
index bfb915d..7d38d25 100644
--- a/arch/arm/kvm/Kconfig
+++ b/arch/arm/kvm/Kconfig
@@ -31,6 +31,7 @@ config KVM
select KVM_VFIO
select HAVE_KVM_EVENTFD
select HAVE_KVM_IRQFD
+ select IRQ_BYPASS_MANAGER
depends on ARM_VIRT_EXT && ARM_LPAE && ARM_ARCH_TIMER
---help---
Support hosting virtualized guest machines.
diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
index bfffe8f..dfaca85 100644
--- a/arch/arm64/kvm/Kconfig
+++ b/arch/arm64/kvm/Kconfig
@@ -31,6 +31,7 @@ config KVM
select KVM_VFIO
select HAVE_KVM_EVENTFD
select HAVE_KVM_IRQFD
+ select IRQ_BYPASS_MANAGER
---help---
Support hosting virtualized guest machines.
--
2.1.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [v3 3/5] KVM: create kvm_irqfd.h
2015-07-29 8:46 [v3 0/5] KVM: irqfd consumer based on IRQ bypass manager Feng Wu
2015-07-29 8:46 ` [v3 1/5] KVM: x86: select IRQ_BYPASS_MANAGER Feng Wu
2015-07-29 8:47 ` [v3 2/5] KVM: arm/arm64: " Feng Wu
@ 2015-07-29 8:47 ` Feng Wu
2015-07-29 8:47 ` [v3 4/5] KVM: introduce kvm_arch functions for IRQ bypass Feng Wu
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Feng Wu @ 2015-07-29 8:47 UTC (permalink / raw)
To: linux-kernel, kvm; +Cc: pbonzini, alex.williamson, joro, eric.auger, feng.wu
From: Eric Auger <eric.auger@linaro.org>
Move _irqfd_resampler and _irqfd struct declarations in a new
public header: kvm_irqfd.h. They are respectively renamed into
kvm_kernel_irqfd_resampler and kvm_kernel_irqfd. Those datatypes
will be used by architecture specific code, in the context of
IRQ bypass manager integration.
Signed-off-by: Eric Auger <eric.auger@linaro.org>
---
include/linux/kvm_irqfd.h | 69 ++++++++++++++++++++++++++++++++++
virt/kvm/eventfd.c | 95 ++++++++++++-----------------------------------
2 files changed, 92 insertions(+), 72 deletions(-)
create mode 100644 include/linux/kvm_irqfd.h
diff --git a/include/linux/kvm_irqfd.h b/include/linux/kvm_irqfd.h
new file mode 100644
index 0000000..f926b39
--- /dev/null
+++ b/include/linux/kvm_irqfd.h
@@ -0,0 +1,69 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * irqfd: Allows an fd to be used to inject an interrupt to the guest
+ * Credit goes to Avi Kivity for the original idea.
+ */
+
+#ifndef __LINUX_KVM_IRQFD_H
+#define __LINUX_KVM_IRQFD_H
+
+#include <linux/kvm_host.h>
+#include <linux/poll.h>
+
+/*
+ * Resampling irqfds are a special variety of irqfds used to emulate
+ * level triggered interrupts. The interrupt is asserted on eventfd
+ * trigger. On acknowledgment through the irq ack notifier, the
+ * interrupt is de-asserted and userspace is notified through the
+ * resamplefd. All resamplers on the same gsi are de-asserted
+ * together, so we don't need to track the state of each individual
+ * user. We can also therefore share the same irq source ID.
+ */
+struct kvm_kernel_irqfd_resampler {
+ struct kvm *kvm;
+ /*
+ * List of resampling struct _irqfd objects sharing this gsi.
+ * RCU list modified under kvm->irqfds.resampler_lock
+ */
+ struct list_head list;
+ struct kvm_irq_ack_notifier notifier;
+ /*
+ * Entry in list of kvm->irqfd.resampler_list. Use for sharing
+ * resamplers among irqfds on the same gsi.
+ * Accessed and modified under kvm->irqfds.resampler_lock
+ */
+ struct list_head link;
+};
+
+struct kvm_kernel_irqfd {
+ /* Used for MSI fast-path */
+ struct kvm *kvm;
+ wait_queue_t wait;
+ /* Update side is protected by irqfds.lock */
+ struct kvm_kernel_irq_routing_entry irq_entry;
+ seqcount_t irq_entry_sc;
+ /* Used for level IRQ fast-path */
+ int gsi;
+ struct work_struct inject;
+ /* The resampler used by this irqfd (resampler-only) */
+ struct kvm_kernel_irqfd_resampler *resampler;
+ /* Eventfd notified on resample (resampler-only) */
+ struct eventfd_ctx *resamplefd;
+ /* Entry in list of irqfds for a resampler (resampler-only) */
+ struct list_head resampler_link;
+ /* Used for setup/shutdown */
+ struct eventfd_ctx *eventfd;
+ struct list_head list;
+ poll_table pt;
+ struct work_struct shutdown;
+};
+
+#endif /* __LINUX_KVM_IRQFD_H */
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 9ff4193..647ffb8 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -23,6 +23,7 @@
#include <linux/kvm_host.h>
#include <linux/kvm.h>
+#include <linux/kvm_irqfd.h>
#include <linux/workqueue.h>
#include <linux/syscalls.h>
#include <linux/wait.h>
@@ -39,68 +40,14 @@
#include <kvm/iodev.h>
#ifdef CONFIG_HAVE_KVM_IRQFD
-/*
- * --------------------------------------------------------------------
- * irqfd: Allows an fd to be used to inject an interrupt to the guest
- *
- * Credit goes to Avi Kivity for the original idea.
- * --------------------------------------------------------------------
- */
-
-/*
- * Resampling irqfds are a special variety of irqfds used to emulate
- * level triggered interrupts. The interrupt is asserted on eventfd
- * trigger. On acknowledgement through the irq ack notifier, the
- * interrupt is de-asserted and userspace is notified through the
- * resamplefd. All resamplers on the same gsi are de-asserted
- * together, so we don't need to track the state of each individual
- * user. We can also therefore share the same irq source ID.
- */
-struct _irqfd_resampler {
- struct kvm *kvm;
- /*
- * List of resampling struct _irqfd objects sharing this gsi.
- * RCU list modified under kvm->irqfds.resampler_lock
- */
- struct list_head list;
- struct kvm_irq_ack_notifier notifier;
- /*
- * Entry in list of kvm->irqfd.resampler_list. Use for sharing
- * resamplers among irqfds on the same gsi.
- * Accessed and modified under kvm->irqfds.resampler_lock
- */
- struct list_head link;
-};
-
-struct _irqfd {
- /* Used for MSI fast-path */
- struct kvm *kvm;
- wait_queue_t wait;
- /* Update side is protected by irqfds.lock */
- struct kvm_kernel_irq_routing_entry irq_entry;
- seqcount_t irq_entry_sc;
- /* Used for level IRQ fast-path */
- int gsi;
- struct work_struct inject;
- /* The resampler used by this irqfd (resampler-only) */
- struct _irqfd_resampler *resampler;
- /* Eventfd notified on resample (resampler-only) */
- struct eventfd_ctx *resamplefd;
- /* Entry in list of irqfds for a resampler (resampler-only) */
- struct list_head resampler_link;
- /* Used for setup/shutdown */
- struct eventfd_ctx *eventfd;
- struct list_head list;
- poll_table pt;
- struct work_struct shutdown;
-};
static struct workqueue_struct *irqfd_cleanup_wq;
static void
irqfd_inject(struct work_struct *work)
{
- struct _irqfd *irqfd = container_of(work, struct _irqfd, inject);
+ struct kvm_kernel_irqfd *irqfd =
+ container_of(work, struct kvm_kernel_irqfd, inject);
struct kvm *kvm = irqfd->kvm;
if (!irqfd->resampler) {
@@ -121,12 +68,13 @@ irqfd_inject(struct work_struct *work)
static void
irqfd_resampler_ack(struct kvm_irq_ack_notifier *kian)
{
- struct _irqfd_resampler *resampler;
+ struct kvm_kernel_irqfd_resampler *resampler;
struct kvm *kvm;
- struct _irqfd *irqfd;
+ struct kvm_kernel_irqfd *irqfd;
int idx;
- resampler = container_of(kian, struct _irqfd_resampler, notifier);
+ resampler = container_of(kian,
+ struct kvm_kernel_irqfd_resampler, notifier);
kvm = resampler->kvm;
kvm_set_irq(kvm, KVM_IRQFD_RESAMPLE_IRQ_SOURCE_ID,
@@ -141,9 +89,9 @@ irqfd_resampler_ack(struct kvm_irq_ack_notifier *kian)
}
static void
-irqfd_resampler_shutdown(struct _irqfd *irqfd)
+irqfd_resampler_shutdown(struct kvm_kernel_irqfd *irqfd)
{
- struct _irqfd_resampler *resampler = irqfd->resampler;
+ struct kvm_kernel_irqfd_resampler *resampler = irqfd->resampler;
struct kvm *kvm = resampler->kvm;
mutex_lock(&kvm->irqfds.resampler_lock);
@@ -168,7 +116,8 @@ irqfd_resampler_shutdown(struct _irqfd *irqfd)
static void
irqfd_shutdown(struct work_struct *work)
{
- struct _irqfd *irqfd = container_of(work, struct _irqfd, shutdown);
+ struct kvm_kernel_irqfd *irqfd =
+ container_of(work, struct kvm_kernel_irqfd, shutdown);
u64 cnt;
/*
@@ -198,7 +147,7 @@ irqfd_shutdown(struct work_struct *work)
/* assumes kvm->irqfds.lock is held */
static bool
-irqfd_is_active(struct _irqfd *irqfd)
+irqfd_is_active(struct kvm_kernel_irqfd *irqfd)
{
return list_empty(&irqfd->list) ? false : true;
}
@@ -209,7 +158,7 @@ irqfd_is_active(struct _irqfd *irqfd)
* assumes kvm->irqfds.lock is held
*/
static void
-irqfd_deactivate(struct _irqfd *irqfd)
+irqfd_deactivate(struct kvm_kernel_irqfd *irqfd)
{
BUG_ON(!irqfd_is_active(irqfd));
@@ -224,7 +173,8 @@ irqfd_deactivate(struct _irqfd *irqfd)
static int
irqfd_wakeup(wait_queue_t *wait, unsigned mode, int sync, void *key)
{
- struct _irqfd *irqfd = container_of(wait, struct _irqfd, wait);
+ struct kvm_kernel_irqfd *irqfd =
+ container_of(wait, struct kvm_kernel_irqfd, wait);
unsigned long flags = (unsigned long)key;
struct kvm_kernel_irq_routing_entry irq;
struct kvm *kvm = irqfd->kvm;
@@ -274,12 +224,13 @@ static void
irqfd_ptable_queue_proc(struct file *file, wait_queue_head_t *wqh,
poll_table *pt)
{
- struct _irqfd *irqfd = container_of(pt, struct _irqfd, pt);
+ struct kvm_kernel_irqfd *irqfd =
+ container_of(pt, struct kvm_kernel_irqfd, pt);
add_wait_queue(wqh, &irqfd->wait);
}
/* Must be called under irqfds.lock */
-static void irqfd_update(struct kvm *kvm, struct _irqfd *irqfd)
+static void irqfd_update(struct kvm *kvm, struct kvm_kernel_irqfd *irqfd)
{
struct kvm_kernel_irq_routing_entry *e;
struct kvm_kernel_irq_routing_entry entries[KVM_NR_IRQCHIPS];
@@ -304,7 +255,7 @@ static void irqfd_update(struct kvm *kvm, struct _irqfd *irqfd)
static int
kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
{
- struct _irqfd *irqfd, *tmp;
+ struct kvm_kernel_irqfd *irqfd, *tmp;
struct fd f;
struct eventfd_ctx *eventfd = NULL, *resamplefd = NULL;
int ret;
@@ -340,7 +291,7 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
irqfd->eventfd = eventfd;
if (args->flags & KVM_IRQFD_FLAG_RESAMPLE) {
- struct _irqfd_resampler *resampler;
+ struct kvm_kernel_irqfd_resampler *resampler;
resamplefd = eventfd_ctx_fdget(args->resamplefd);
if (IS_ERR(resamplefd)) {
@@ -525,7 +476,7 @@ kvm_eventfd_init(struct kvm *kvm)
static int
kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd *args)
{
- struct _irqfd *irqfd, *tmp;
+ struct kvm_kernel_irqfd *irqfd, *tmp;
struct eventfd_ctx *eventfd;
eventfd = eventfd_ctx_fdget(args->fd);
@@ -581,7 +532,7 @@ kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args)
void
kvm_irqfd_release(struct kvm *kvm)
{
- struct _irqfd *irqfd, *tmp;
+ struct kvm_kernel_irqfd *irqfd, *tmp;
spin_lock_irq(&kvm->irqfds.lock);
@@ -604,7 +555,7 @@ kvm_irqfd_release(struct kvm *kvm)
*/
void kvm_irq_routing_update(struct kvm *kvm)
{
- struct _irqfd *irqfd;
+ struct kvm_kernel_irqfd *irqfd;
spin_lock_irq(&kvm->irqfds.lock);
--
2.1.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [v3 4/5] KVM: introduce kvm_arch functions for IRQ bypass
2015-07-29 8:46 [v3 0/5] KVM: irqfd consumer based on IRQ bypass manager Feng Wu
` (2 preceding siblings ...)
2015-07-29 8:47 ` [v3 3/5] KVM: create kvm_irqfd.h Feng Wu
@ 2015-07-29 8:47 ` Feng Wu
2015-07-29 8:47 ` [v3 5/5] KVM: eventfd: add irq bypass consumer management Feng Wu
2015-08-03 16:41 ` [v3 0/5] KVM: irqfd consumer based on IRQ bypass manager Eric Auger
5 siblings, 0 replies; 7+ messages in thread
From: Feng Wu @ 2015-07-29 8:47 UTC (permalink / raw)
To: linux-kernel, kvm; +Cc: pbonzini, alex.williamson, joro, eric.auger, feng.wu
From: Eric Auger <eric.auger@linaro.org>
This patch introduces
- kvm_arch_irq_bypass_add_producer
- kvm_arch_irq_bypass_del_producer
- kvm_arch_irq_bypass_stop
- kvm_arch_irq_bypass_start
They make possible to specialize the KVM IRQ bypass consumer in
case CONFIG_KVM_HAVE_IRQ_BYPASS is set.
v2 -> v3:
- use 'kvm_arch_irq_bypass_start' instead of 'kvm_arch_irq_bypass_resume'
- Remove 'kvm_arch_irq_bypass_update', which is not needed to be
a irqbypass callback per Alex's comments.
- Make kvm_arch_irq_bypass_add_producer return 'int'
v1 -> v2:
- use CONFIG_KVM_HAVE_IRQ_BYPASS instead CONFIG_IRQ_BYPASS_MANAGER
- rename all functions according to Paolo's proposal
- add kvm_arch_irq_bypass_update according to Feng's need
Signed-off-by: Eric Auger <eric.auger@linaro.org>
Signed-off-by: Feng Wu <feng.wu@intel.com>
---
include/linux/kvm_host.h | 33 +++++++++++++++++++++++++++++++++
virt/kvm/Kconfig | 3 +++
2 files changed, 36 insertions(+)
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 05e99b8..84b5feb 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -24,6 +24,7 @@
#include <linux/err.h>
#include <linux/irqflags.h>
#include <linux/context_tracking.h>
+#include <linux/irqbypass.h>
#include <asm/signal.h>
#include <linux/kvm.h>
@@ -1151,5 +1152,37 @@ static inline void kvm_vcpu_set_dy_eligible(struct kvm_vcpu *vcpu, bool val)
{
}
#endif /* CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT */
+
+#ifdef CONFIG_HAVE_KVM_IRQ_BYPASS
+
+int kvm_arch_irq_bypass_add_producer(struct irq_bypass_consumer *,
+ struct irq_bypass_producer *);
+void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *,
+ struct irq_bypass_producer *);
+void kvm_arch_irq_bypass_stop(struct irq_bypass_consumer *);
+void kvm_arch_irq_bypass_start(struct irq_bypass_consumer *);
+
+#else
+
+static inline int kvm_arch_irq_bypass_add_producer(
+ struct irq_bypass_consumer *cons,
+ struct irq_bypass_producer *prod)
+{
+ return -1;
+}
+static inline void kvm_arch_irq_bypass_del_producer(
+ struct irq_bypass_consumer *cons,
+ struct irq_bypass_producer *prod)
+{
+}
+static inline void kvm_arch_irq_bypass_stop(
+ struct irq_bypass_consumer *cons)
+{
+}
+static inline void kvm_arch_irq_bypass_start(
+ struct irq_bypass_consumer *cons)
+{
+}
+#endif /* CONFIG_HAVE_KVM_IRQ_BYPASS */
#endif
diff --git a/virt/kvm/Kconfig b/virt/kvm/Kconfig
index e2c876d..9f8014d 100644
--- a/virt/kvm/Kconfig
+++ b/virt/kvm/Kconfig
@@ -47,3 +47,6 @@ config KVM_GENERIC_DIRTYLOG_READ_PROTECT
config KVM_COMPAT
def_bool y
depends on COMPAT && !S390
+
+config HAVE_KVM_IRQ_BYPASS
+ bool
--
2.1.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [v3 5/5] KVM: eventfd: add irq bypass consumer management
2015-07-29 8:46 [v3 0/5] KVM: irqfd consumer based on IRQ bypass manager Feng Wu
` (3 preceding siblings ...)
2015-07-29 8:47 ` [v3 4/5] KVM: introduce kvm_arch functions for IRQ bypass Feng Wu
@ 2015-07-29 8:47 ` Feng Wu
2015-08-03 16:41 ` [v3 0/5] KVM: irqfd consumer based on IRQ bypass manager Eric Auger
5 siblings, 0 replies; 7+ messages in thread
From: Feng Wu @ 2015-07-29 8:47 UTC (permalink / raw)
To: linux-kernel, kvm; +Cc: pbonzini, alex.williamson, joro, eric.auger, feng.wu
From: Eric Auger <eric.auger@linaro.org>
This patch adds the registration/unregistration of an
irq_bypass_consumer on irqfd assignment/deassignment.
v2 -> v3:
- Use kvm_arch_irq_bypass_start
- Remove kvm_arch_irq_bypass_update
- Add member 'struct irq_bypass_producer *producer' in
'struct kvm_kernel_irqfd', it is needed by posted interrupt.
- Remove 'irq_bypass_unregister_consumer' in kvm_irqfd_deassign()
v1 -> v2:
- populate of kvm and gsi removed
- unregister the consumer on irqfd_shutdown
Signed-off-by: Eric Auger <eric.auger@linaro.org>
Signed-off-by: Feng Wu <feng.wu@intel.com>
---
include/linux/kvm_irqfd.h | 2 ++
virt/kvm/eventfd.c | 10 ++++++++++
2 files changed, 12 insertions(+)
diff --git a/include/linux/kvm_irqfd.h b/include/linux/kvm_irqfd.h
index f926b39..0c1de05 100644
--- a/include/linux/kvm_irqfd.h
+++ b/include/linux/kvm_irqfd.h
@@ -64,6 +64,8 @@ struct kvm_kernel_irqfd {
struct list_head list;
poll_table pt;
struct work_struct shutdown;
+ struct irq_bypass_consumer consumer;
+ struct irq_bypass_producer *producer;
};
#endif /* __LINUX_KVM_IRQFD_H */
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 647ffb8..08855de 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -35,6 +35,7 @@
#include <linux/srcu.h>
#include <linux/slab.h>
#include <linux/seqlock.h>
+#include <linux/irqbypass.h>
#include <trace/events/kvm.h>
#include <kvm/iodev.h>
@@ -140,6 +141,7 @@ irqfd_shutdown(struct work_struct *work)
/*
* It is now safe to release the object's resources
*/
+ irq_bypass_unregister_consumer(&irqfd->consumer);
eventfd_ctx_put(irqfd->eventfd);
kfree(irqfd);
}
@@ -380,6 +382,14 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
*/
fdput(f);
+ irqfd->consumer.token = (void *)irqfd->eventfd;
+ irqfd->consumer.add_producer = kvm_arch_irq_bypass_add_producer;
+ irqfd->consumer.del_producer = kvm_arch_irq_bypass_del_producer;
+ irqfd->consumer.stop = kvm_arch_irq_bypass_stop;
+ irqfd->consumer.start = kvm_arch_irq_bypass_start;
+ ret = irq_bypass_register_consumer(&irqfd->consumer);
+ WARN_ON(ret);
+
return 0;
fail:
--
2.1.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [v3 0/5] KVM: irqfd consumer based on IRQ bypass manager
2015-07-29 8:46 [v3 0/5] KVM: irqfd consumer based on IRQ bypass manager Feng Wu
` (4 preceding siblings ...)
2015-07-29 8:47 ` [v3 5/5] KVM: eventfd: add irq bypass consumer management Feng Wu
@ 2015-08-03 16:41 ` Eric Auger
5 siblings, 0 replies; 7+ messages in thread
From: Eric Auger @ 2015-08-03 16:41 UTC (permalink / raw)
To: Feng Wu, linux-kernel, kvm; +Cc: pbonzini, alex.williamson, joro
Hi Feng,
On 07/29/2015 10:46 AM, Feng Wu wrote:
> This series is based on Eric's "https://lkml.org/lkml/2015/7/6/291".
> Basically, I made the following chagnes:
> - Some changes based on Alex's irq bypass manager
> v2: https://lkml.org/lkml/2015/7/16/810
> - Correct some minor erros and typo
> - Add something needed for posted-interrupts
>
> Since this series contain the common part of posted-interrupts and
> forwarded irq, we can go forward only when this series are finalized,
> ,it is in the critical path. Seems Eric is on vacations these days,
> to speed up the process, I send out this new version, Eric, hope you
> are not mind of this. :) If I made any mistakes, please correct me.
Sorry for the delay and thanks for the upgrade.
I am going to send a v4 to add the compilation of virt/lib/irqbypass.c.
which is missing for arm/arm64. I will rearrange the signoffs vs history
in some patch files too.
Otherwise the changes look good to me.
Thanks
Eric
> Thank you!
>
> My new version of posted-interrupts patches work well based on this
> series.
>
> Eric Auger (4):
> KVM: arm/arm64: select IRQ_BYPASS_MANAGER
> KVM: create kvm_irqfd.h
> KVM: introduce kvm_arch functions for IRQ bypass
> KVM: eventfd: add irq bypass consumer management
>
> Feng Wu (1):
> KVM: x86: select IRQ_BYPASS_MANAGER
>
> arch/arm/kvm/Kconfig | 1 +
> arch/arm64/kvm/Kconfig | 1 +
> arch/x86/kvm/Kconfig | 2 +
> arch/x86/kvm/Makefile | 3 ++
> include/linux/kvm_host.h | 33 +++++++++++++++
> include/linux/kvm_irqfd.h | 71 +++++++++++++++++++++++++++++++
> virt/kvm/Kconfig | 3 ++
> virt/kvm/eventfd.c | 105 +++++++++++++++-------------------------------
> 8 files changed, 147 insertions(+), 72 deletions(-)
> create mode 100644 include/linux/kvm_irqfd.h
>
^ permalink raw reply [flat|nested] 7+ messages in thread