Skip to contentSkip to conversation

MMIO: Make coalesced mmio use a device per zone

PATCH Applied Sasha Levin 2 participants 2 messages Jul 20, 2011 – Jul 22, 2011 KVM

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 MMIO: Make coalesced mmio use a device per zone

This patch changes coalesced mmio to create one mmio device per zone instead of handling all zones in one device.

Doing so enables us to take advantage of existing locking and prevents a race condition between coalesced mmio registration/unregistration and lookups.

---
 include/linux/kvm_host.h  |    5 +-
 virt/kvm/coalesced_mmio.c |  118 ++++++++++++++++++---------------------------
 virt/kvm/coalesced_mmio.h |    7 +--
 3 files changed, 53 insertions(+), 77 deletions(-)
include/linux/kvm_host.h +3 -2
index eabb21a..ff4d406 100644
@@ -63,7 +63,7 @@ extern struct kmem_cache *kvm_vcpu_cache;
  */
 struct kvm_io_bus {
 	int                   dev_count;
-#define NR_IOBUS_DEVS 200
+#define NR_IOBUS_DEVS 300
 	struct kvm_io_device *devs[NR_IOBUS_DEVS];
 };
 
@@ -256,8 +256,9 @@ struct kvm {
 	struct kvm_arch arch;
 	atomic_t users_count;
 #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
-	struct kvm_coalesced_mmio_dev *coalesced_mmio_dev;
 	struct kvm_coalesced_mmio_ring *coalesced_mmio_ring;
+	spinlock_t ring_lock;
+	struct list_head coalesced_zones;
 #endif
 
 	struct mutex irq_lock;
virt/kvm/coalesced_mmio.c +47 -71

182 lines not on this page · raw message

virt/kvm/coalesced_mmio.h +3 -4
index 8a5959e..b280c20 100644
@@ -12,14 +12,13 @@
 
 #ifdef CONFIG_KVM_MMIO
 
-#define KVM_COALESCED_MMIO_ZONE_MAX 100
+#include <linux/list.h>
 
 struct kvm_coalesced_mmio_dev {
+	struct list_head list;
 	struct kvm_io_device dev;
 	struct kvm *kvm;
-	spinlock_t lock;
-	int nb_zones;
-	struct kvm_coalesced_mmio_zone zone[KVM_COALESCED_MMIO_ZONE_MAX];
+	struct kvm_coalesced_mmio_zone zone;
 };
 
 int kvm_coalesced_mmio_init(struct kvm *kvm);
Signature · 1 line
1.7.6
#1 lore raw
Quoted 6 lines · Sasha Levin

This patch changes coalesced mmio to create one mmio device per zone instead of handling all zones in one device.

Doing so enables us to take advantage of existing locking and prevents a race condition between coalesced mmio registration/unregistration and lookups.

Applied, thanks.