All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] busy polling support for vhost-kernel
@ 2016-03-21  5:25 Jason Wang
  2016-03-21  5:25 ` [Qemu-devel] [PATCH 1/2] update linux headers to 4.5.0-rc5+ Jason Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Jason Wang @ 2016-03-21  5:25 UTC (permalink / raw)
  To: mst, qemu-devel; +Cc: Jason Wang

Hi:

This series enable vhost-kernel busy polling support. It's done
through introducing a new property for tap backend - 'vhost_poll_us'
which is the maximum number of us could be spent for busy polling.

Please reivew.

Thanks

Jason Wang (2):
  update linux headers to 4.5.0-rc5+
  tap: vhost busy polling support

 hw/net/vhost_net.c                              |  2 +-
 hw/scsi/vhost-scsi.c                            |  2 +-
 hw/virtio/vhost-backend.c                       |  8 +++
 hw/virtio/vhost.c                               | 40 ++++++++++-
 include/hw/virtio/vhost-backend.h               |  3 +
 include/hw/virtio/vhost.h                       |  3 +-
 include/net/vhost_net.h                         |  1 +
 include/standard-headers/asm-x86/hyperv.h       |  4 +-
 include/standard-headers/linux/input.h          |  1 +
 include/standard-headers/linux/types.h          |  5 +-
 include/standard-headers/linux/virtio_balloon.h |  2 +-
 include/standard-headers/linux/virtio_blk.h     |  6 +-
 linux-headers/asm-arm64/kvm.h                   |  6 ++
 linux-headers/asm-powerpc/epapr_hcalls.h        |  4 +-
 linux-headers/asm-powerpc/kvm.h                 |  9 +++
 linux-headers/asm-x86/unistd_32.h               |  2 +
 linux-headers/asm-x86/unistd_64.h               |  2 +
 linux-headers/linux/kvm.h                       | 11 +++
 linux-headers/linux/userfaultfd.h               |  2 +-
 linux-headers/linux/vfio.h                      | 92 ++++++++++++++++++++++++-
 linux-headers/linux/vhost.h                     |  6 ++
 net/tap.c                                       | 10 ++-
 net/vhost-user.c                                |  1 +
 qapi-schema.json                                |  3 +-
 24 files changed, 206 insertions(+), 19 deletions(-)

-- 
2.5.0

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH 1/2] update linux headers to 4.5.0-rc5+
  2016-03-21  5:25 [Qemu-devel] [PATCH 0/2] busy polling support for vhost-kernel Jason Wang
@ 2016-03-21  5:25 ` Jason Wang
  2016-03-21  5:25 ` [Qemu-devel] [PATCH 2/2] tap: vhost busy polling support Jason Wang
  2016-04-05 15:54 ` [Qemu-devel] [PATCH 0/2] busy polling support for vhost-kernel Greg Kurz
  2 siblings, 0 replies; 11+ messages in thread
From: Jason Wang @ 2016-03-21  5:25 UTC (permalink / raw)
  To: mst, qemu-devel; +Cc: Jason Wang

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 include/standard-headers/asm-x86/hyperv.h       |  4 +-
 include/standard-headers/linux/input.h          |  1 +
 include/standard-headers/linux/types.h          |  5 +-
 include/standard-headers/linux/virtio_balloon.h |  2 +-
 include/standard-headers/linux/virtio_blk.h     |  6 +-
 linux-headers/asm-arm64/kvm.h                   |  6 ++
 linux-headers/asm-powerpc/epapr_hcalls.h        |  4 +-
 linux-headers/asm-powerpc/kvm.h                 |  9 +++
 linux-headers/asm-x86/unistd_32.h               |  2 +
 linux-headers/asm-x86/unistd_64.h               |  2 +
 linux-headers/linux/kvm.h                       | 11 +++
 linux-headers/linux/userfaultfd.h               |  2 +-
 linux-headers/linux/vfio.h                      | 92 ++++++++++++++++++++++++-
 linux-headers/linux/vhost.h                     |  6 ++
 14 files changed, 140 insertions(+), 12 deletions(-)

diff --git a/include/standard-headers/asm-x86/hyperv.h b/include/standard-headers/asm-x86/hyperv.h
index acb119d..47b38fb 100644
--- a/include/standard-headers/asm-x86/hyperv.h
+++ b/include/standard-headers/asm-x86/hyperv.h
@@ -226,7 +226,9 @@
 		(~((1ull << HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT) - 1))
 
 /* Declare the various hypercall operations. */
-#define HV_X64_HV_NOTIFY_LONG_SPIN_WAIT		0x0008
+#define HVCALL_NOTIFY_LONG_SPIN_WAIT		0x0008
+#define HVCALL_POST_MESSAGE			0x005c
+#define HVCALL_SIGNAL_EVENT			0x005d
 
 #define HV_X64_MSR_APIC_ASSIST_PAGE_ENABLE		0x00000001
 #define HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_SHIFT	12
diff --git a/include/standard-headers/linux/input.h b/include/standard-headers/linux/input.h
index 8b2c928..a52b202 100644
--- a/include/standard-headers/linux/input.h
+++ b/include/standard-headers/linux/input.h
@@ -243,6 +243,7 @@ struct input_mask {
 #define BUS_GSC			0x1A
 #define BUS_ATARI		0x1B
 #define BUS_SPI			0x1C
+#define BUS_RMI			0x1D
 
 /*
  * MT_TOOL types
diff --git a/include/standard-headers/linux/types.h b/include/standard-headers/linux/types.h
index 0526c2b..9dbbc73 100644
--- a/include/standard-headers/linux/types.h
+++ b/include/standard-headers/linux/types.h
@@ -1,2 +1,3 @@
-#include <stdint.h>
-#include "qemu/compiler.h"
+/* For QEMU all types are already defined via osdep.h, so this
+ * header does not need to do anything.
+ */
diff --git a/include/standard-headers/linux/virtio_balloon.h b/include/standard-headers/linux/virtio_balloon.h
index 0df7c2e..9d06ccd 100644
--- a/include/standard-headers/linux/virtio_balloon.h
+++ b/include/standard-headers/linux/virtio_balloon.h
@@ -51,7 +51,7 @@ struct virtio_balloon_config {
 #define VIRTIO_BALLOON_S_MINFLT   3   /* Number of minor faults */
 #define VIRTIO_BALLOON_S_MEMFREE  4   /* Total amount of free memory */
 #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */
-#define VIRTIO_BALLOON_S_AVAIL    6   /* Amount of available memory in guest */
+#define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */
 #define VIRTIO_BALLOON_S_NR       7
 
 /*
diff --git a/include/standard-headers/linux/virtio_blk.h b/include/standard-headers/linux/virtio_blk.h
index cd601f4..ab16ec5 100644
--- a/include/standard-headers/linux/virtio_blk.h
+++ b/include/standard-headers/linux/virtio_blk.h
@@ -43,10 +43,10 @@
 #ifndef VIRTIO_BLK_NO_LEGACY
 #define VIRTIO_BLK_F_BARRIER	0	/* Does host support barriers? */
 #define VIRTIO_BLK_F_SCSI	7	/* Supports scsi command passthru */
-#define VIRTIO_BLK_F_WCE	9	/* Writeback mode enabled after reset */
+#define VIRTIO_BLK_F_FLUSH	9	/* Flush command supported */
 #define VIRTIO_BLK_F_CONFIG_WCE	11	/* Writeback mode available in config */
-/* Old (deprecated) name for VIRTIO_BLK_F_WCE. */
-#define VIRTIO_BLK_F_FLUSH VIRTIO_BLK_F_WCE
+/* Old (deprecated) name for VIRTIO_BLK_F_FLUSH. */
+#define VIRTIO_BLK_F_WCE VIRTIO_BLK_F_FLUSH
 #endif /* !VIRTIO_BLK_NO_LEGACY */
 
 #define VIRTIO_BLK_ID_BYTES	20	/* ID string length */
diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h
index a2fd4d9..7d82d1f 100644
--- a/linux-headers/asm-arm64/kvm.h
+++ b/linux-headers/asm-arm64/kvm.h
@@ -94,6 +94,7 @@ struct kvm_regs {
 #define KVM_ARM_VCPU_POWER_OFF		0 /* CPU is started in OFF state */
 #define KVM_ARM_VCPU_EL1_32BIT		1 /* CPU running a 32bit VM */
 #define KVM_ARM_VCPU_PSCI_0_2		2 /* CPU uses PSCI v0.2 */
+#define KVM_ARM_VCPU_PMU_V3		3 /* Support guest PMUv3 */
 
 struct kvm_vcpu_init {
 	__u32 target;
@@ -204,6 +205,11 @@ struct kvm_arch_memory_slot {
 #define KVM_DEV_ARM_VGIC_GRP_CTRL	4
 #define   KVM_DEV_ARM_VGIC_CTRL_INIT	0
 
+/* Device Control API on vcpu fd */
+#define KVM_ARM_VCPU_PMU_V3_CTRL	0
+#define   KVM_ARM_VCPU_PMU_V3_IRQ	0
+#define   KVM_ARM_VCPU_PMU_V3_INIT	1
+
 /* KVM_IRQ_LINE irq field index values */
 #define KVM_ARM_IRQ_TYPE_SHIFT		24
 #define KVM_ARM_IRQ_TYPE_MASK		0xff
diff --git a/linux-headers/asm-powerpc/epapr_hcalls.h b/linux-headers/asm-powerpc/epapr_hcalls.h
index 06f7247..33b3f89 100644
--- a/linux-headers/asm-powerpc/epapr_hcalls.h
+++ b/linux-headers/asm-powerpc/epapr_hcalls.h
@@ -78,7 +78,7 @@
 #define EV_SUCCESS		0
 #define EV_EPERM		1	/* Operation not permitted */
 #define EV_ENOENT		2	/*  Entry Not Found */
-#define EV_EIO			3	/* I/O error occured */
+#define EV_EIO			3	/* I/O error occurred */
 #define EV_EAGAIN		4	/* The operation had insufficient
 					 * resources to complete and should be
 					 * retried
@@ -89,7 +89,7 @@
 #define EV_ENODEV		7	/* No such device */
 #define EV_EINVAL		8	/* An argument supplied to the hcall
 					   was out of range or invalid */
-#define EV_INTERNAL		9	/* An internal error occured */
+#define EV_INTERNAL		9	/* An internal error occurred */
 #define EV_CONFIG		10	/* A configuration error was detected */
 #define EV_INVALID_STATE	11	/* The object is in an invalid state */
 #define EV_UNIMPLEMENTED	12	/* Unimplemented hypercall */
diff --git a/linux-headers/asm-powerpc/kvm.h b/linux-headers/asm-powerpc/kvm.h
index ab4d473..c93cf35 100644
--- a/linux-headers/asm-powerpc/kvm.h
+++ b/linux-headers/asm-powerpc/kvm.h
@@ -333,6 +333,15 @@ struct kvm_create_spapr_tce {
 	__u32 window_size;
 };
 
+/* for KVM_CAP_SPAPR_TCE_64 */
+struct kvm_create_spapr_tce_64 {
+	__u64 liobn;
+	__u32 page_shift;
+	__u32 flags;
+	__u64 offset;	/* in pages */
+	__u64 size;	/* in pages */
+};
+
 /* for KVM_ALLOCATE_RMA */
 struct kvm_allocate_rma {
 	__u64 rma_size;
diff --git a/linux-headers/asm-x86/unistd_32.h b/linux-headers/asm-x86/unistd_32.h
index a152542..abeaf40 100644
--- a/linux-headers/asm-x86/unistd_32.h
+++ b/linux-headers/asm-x86/unistd_32.h
@@ -375,5 +375,7 @@
 #define __NR_membarrier 375
 #define __NR_mlock2 376
 #define __NR_copy_file_range 377
+#define __NR_preadv2 378
+#define __NR_pwritev2 379
 
 #endif /* _ASM_X86_UNISTD_32_H */
diff --git a/linux-headers/asm-x86/unistd_64.h b/linux-headers/asm-x86/unistd_64.h
index 4f67c54..73c3d1f 100644
--- a/linux-headers/asm-x86/unistd_64.h
+++ b/linux-headers/asm-x86/unistd_64.h
@@ -328,5 +328,7 @@
 #define __NR_membarrier 324
 #define __NR_mlock2 325
 #define __NR_copy_file_range 326
+#define __NR_preadv2 327
+#define __NR_pwritev2 328
 
 #endif /* _ASM_X86_UNISTD_64_H */
diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
index 4a56b9e..3bae71a 100644
--- a/linux-headers/linux/kvm.h
+++ b/linux-headers/linux/kvm.h
@@ -157,6 +157,7 @@ struct kvm_s390_skeys {
 
 struct kvm_hyperv_exit {
 #define KVM_EXIT_HYPERV_SYNIC          1
+#define KVM_EXIT_HYPERV_HCALL          2
 	__u32 type;
 	union {
 		struct {
@@ -165,6 +166,11 @@ struct kvm_hyperv_exit {
 			__u64 evt_page;
 			__u64 msg_page;
 		} synic;
+		struct {
+			__u64 input;
+			__u64 result;
+			__u64 params[2];
+		} hcall;
 	} u;
 };
 
@@ -856,6 +862,9 @@ struct kvm_ppc_smmu_info {
 #define KVM_CAP_IOEVENTFD_ANY_LENGTH 122
 #define KVM_CAP_HYPERV_SYNIC 123
 #define KVM_CAP_S390_RI 124
+#define KVM_CAP_SPAPR_TCE_64 125
+#define KVM_CAP_ARM_PMU_V3 126
+#define KVM_CAP_VCPU_ATTRIBUTES 127
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
@@ -1148,6 +1157,8 @@ struct kvm_s390_ucas_mapping {
 /* Available with KVM_CAP_PPC_ALLOC_HTAB */
 #define KVM_PPC_ALLOCATE_HTAB	  _IOWR(KVMIO, 0xa7, __u32)
 #define KVM_CREATE_SPAPR_TCE	  _IOW(KVMIO,  0xa8, struct kvm_create_spapr_tce)
+#define KVM_CREATE_SPAPR_TCE_64	  _IOW(KVMIO,  0xa8, \
+				       struct kvm_create_spapr_tce_64)
 /* Available with KVM_CAP_RMA */
 #define KVM_ALLOCATE_RMA	  _IOR(KVMIO,  0xa9, struct kvm_allocate_rma)
 /* Available with KVM_CAP_PPC_HTAB_FD */
diff --git a/linux-headers/linux/userfaultfd.h b/linux-headers/linux/userfaultfd.h
index 9057d7a..19e8453 100644
--- a/linux-headers/linux/userfaultfd.h
+++ b/linux-headers/linux/userfaultfd.h
@@ -78,7 +78,7 @@ struct uffd_msg {
 			__u64	reserved3;
 		} reserved;
 	} arg;
-} __packed;
+} __attribute__((packed));
 
 /*
  * Start at 0x12 and not at 0 to be more strict against bugs.
diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h
index 15e096c..759b850 100644
--- a/linux-headers/linux/vfio.h
+++ b/linux-headers/linux/vfio.h
@@ -59,6 +59,33 @@
 #define VFIO_TYPE	(';')
 #define VFIO_BASE	100
 
+/*
+ * For extension of INFO ioctls, VFIO makes use of a capability chain
+ * designed after PCI/e capabilities.  A flag bit indicates whether
+ * this capability chain is supported and a field defined in the fixed
+ * structure defines the offset of the first capability in the chain.
+ * This field is only valid when the corresponding bit in the flags
+ * bitmap is set.  This offset field is relative to the start of the
+ * INFO buffer, as is the next field within each capability header.
+ * The id within the header is a shared address space per INFO ioctl,
+ * while the version field is specific to the capability id.  The
+ * contents following the header are specific to the capability id.
+ */
+struct vfio_info_cap_header {
+	__u16	id;		/* Identifies capability */
+	__u16	version;	/* Version specific to the capability ID */
+	__u32	next;		/* Offset of next capability */
+};
+
+/*
+ * Callers of INFO ioctls passing insufficiently sized buffers will see
+ * the capability chain flag bit set, a zero value for the first capability
+ * offset (if available within the provided argsz), and argsz will be
+ * updated to report the necessary buffer size.  For compatibility, the
+ * INFO ioctl will not report error in this case, but the capability chain
+ * will not be available.
+ */
+
 /* -------- IOCTLs for VFIO file descriptor (/dev/vfio/vfio) -------- */
 
 /**
@@ -194,13 +221,73 @@ struct vfio_region_info {
 #define VFIO_REGION_INFO_FLAG_READ	(1 << 0) /* Region supports read */
 #define VFIO_REGION_INFO_FLAG_WRITE	(1 << 1) /* Region supports write */
 #define VFIO_REGION_INFO_FLAG_MMAP	(1 << 2) /* Region supports mmap */
+#define VFIO_REGION_INFO_FLAG_CAPS	(1 << 3) /* Info supports caps */
 	__u32	index;		/* Region index */
-	__u32	resv;		/* Reserved for alignment */
+	__u32	cap_offset;	/* Offset within info struct of first cap */
 	__u64	size;		/* Region size (bytes) */
 	__u64	offset;		/* Region offset from start of device fd */
 };
 #define VFIO_DEVICE_GET_REGION_INFO	_IO(VFIO_TYPE, VFIO_BASE + 8)
 
+/*
+ * The sparse mmap capability allows finer granularity of specifying areas
+ * within a region with mmap support.  When specified, the user should only
+ * mmap the offset ranges specified by the areas array.  mmaps outside of the
+ * areas specified may fail (such as the range covering a PCI MSI-X table) or
+ * may result in improper device behavior.
+ *
+ * The structures below define version 1 of this capability.
+ */
+#define VFIO_REGION_INFO_CAP_SPARSE_MMAP	1
+
+struct vfio_region_sparse_mmap_area {
+	__u64	offset;	/* Offset of mmap'able area within region */
+	__u64	size;	/* Size of mmap'able area */
+};
+
+struct vfio_region_info_cap_sparse_mmap {
+	struct vfio_info_cap_header header;
+	__u32	nr_areas;
+	__u32	reserved;
+	struct vfio_region_sparse_mmap_area areas[];
+};
+
+/*
+ * The device specific type capability allows regions unique to a specific
+ * device or class of devices to be exposed.  This helps solve the problem for
+ * vfio bus drivers of defining which region indexes correspond to which region
+ * on the device, without needing to resort to static indexes, as done by
+ * vfio-pci.  For instance, if we were to go back in time, we might remove
+ * VFIO_PCI_VGA_REGION_INDEX and let vfio-pci simply define that all indexes
+ * greater than or equal to VFIO_PCI_NUM_REGIONS are device specific and we'd
+ * make a "VGA" device specific type to describe the VGA access space.  This
+ * means that non-VGA devices wouldn't need to waste this index, and thus the
+ * address space associated with it due to implementation of device file
+ * descriptor offsets in vfio-pci.
+ *
+ * The current implementation is now part of the user ABI, so we can't use this
+ * for VGA, but there are other upcoming use cases, such as opregions for Intel
+ * IGD devices and framebuffers for vGPU devices.  We missed VGA, but we'll
+ * use this for future additions.
+ *
+ * The structure below defines version 1 of this capability.
+ */
+#define VFIO_REGION_INFO_CAP_TYPE	2
+
+struct vfio_region_info_cap_type {
+	struct vfio_info_cap_header header;
+	__u32 type;	/* global per bus driver */
+	__u32 subtype;	/* type specific */
+};
+
+#define VFIO_REGION_TYPE_PCI_VENDOR_TYPE	(1 << 31)
+#define VFIO_REGION_TYPE_PCI_VENDOR_MASK	(0xffff)
+
+/* 8086 Vendor sub-types */
+#define VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION	(1)
+#define VFIO_REGION_SUBTYPE_INTEL_IGD_HOST_CFG	(2)
+#define VFIO_REGION_SUBTYPE_INTEL_IGD_LPC_CFG	(3)
+
 /**
  * VFIO_DEVICE_GET_IRQ_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 9,
  *				    struct vfio_irq_info)
@@ -336,7 +423,8 @@ enum {
 	 * between described ranges are unimplemented.
 	 */
 	VFIO_PCI_VGA_REGION_INDEX,
-	VFIO_PCI_NUM_REGIONS
+	VFIO_PCI_NUM_REGIONS = 9 /* Fixed user ABI, region indexes >=9 use */
+				 /* device specific cap to define content. */
 };
 
 enum {
diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h
index ead86db..571294c 100644
--- a/linux-headers/linux/vhost.h
+++ b/linux-headers/linux/vhost.h
@@ -126,6 +126,12 @@ struct vhost_memory {
 #define VHOST_SET_VRING_CALL _IOW(VHOST_VIRTIO, 0x21, struct vhost_vring_file)
 /* Set eventfd to signal an error */
 #define VHOST_SET_VRING_ERR _IOW(VHOST_VIRTIO, 0x22, struct vhost_vring_file)
+/* Set busy loop timeout (in us) */
+#define VHOST_SET_VRING_BUSYLOOP_TIMEOUT _IOW(VHOST_VIRTIO, 0x23,	\
+					 struct vhost_vring_state)
+/* Get busy loop timeout (in us) */
+#define VHOST_GET_VRING_BUSYLOOP_TIMEOUT _IOW(VHOST_VIRTIO, 0x24,	\
+					 struct vhost_vring_state)
 
 /* VHOST_NET specific defines */
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH 2/2] tap: vhost busy polling support
  2016-03-21  5:25 [Qemu-devel] [PATCH 0/2] busy polling support for vhost-kernel Jason Wang
  2016-03-21  5:25 ` [Qemu-devel] [PATCH 1/2] update linux headers to 4.5.0-rc5+ Jason Wang
@ 2016-03-21  5:25 ` Jason Wang
  2016-03-21  7:26   ` Fam Zheng
  2016-03-24 20:34   ` Eric Blake
  2016-04-05 15:54 ` [Qemu-devel] [PATCH 0/2] busy polling support for vhost-kernel Greg Kurz
  2 siblings, 2 replies; 11+ messages in thread
From: Jason Wang @ 2016-03-21  5:25 UTC (permalink / raw)
  To: mst, qemu-devel; +Cc: Jason Wang

This patch add the capability of basic vhost net busy polling which is
supported by recent kernel. User could configure the maximum number of
us that could be spent on busy polling through a new property of tap
"vhost_poll_us".

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/net/vhost_net.c                |  2 +-
 hw/scsi/vhost-scsi.c              |  2 +-
 hw/virtio/vhost-backend.c         |  8 ++++++++
 hw/virtio/vhost.c                 | 40 ++++++++++++++++++++++++++++++++++++++-
 include/hw/virtio/vhost-backend.h |  3 +++
 include/hw/virtio/vhost.h         |  3 ++-
 include/net/vhost_net.h           |  1 +
 net/tap.c                         | 10 ++++++++--
 net/vhost-user.c                  |  1 +
 qapi-schema.json                  |  3 ++-
 10 files changed, 66 insertions(+), 7 deletions(-)

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 6e1032f..1840c73 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -166,7 +166,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
     }
 
     r = vhost_dev_init(&net->dev, options->opaque,
-                       options->backend_type);
+                       options->backend_type, options->busyloop_timeout);
     if (r < 0) {
         goto fail;
     }
diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index c86622c..f61483a 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -246,7 +246,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
     s->dev.backend_features = 0;
 
     ret = vhost_dev_init(&s->dev, (void *)(uintptr_t)vhostfd,
-                         VHOST_BACKEND_TYPE_KERNEL);
+                         VHOST_BACKEND_TYPE_KERNEL, 0);
     if (ret < 0) {
         error_setg(errp, "vhost-scsi: vhost initialization failed: %s",
                    strerror(-ret));
diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
index b358902..d62372e 100644
--- a/hw/virtio/vhost-backend.c
+++ b/hw/virtio/vhost-backend.c
@@ -138,6 +138,12 @@ static int vhost_kernel_set_vring_call(struct vhost_dev *dev,
     return vhost_kernel_call(dev, VHOST_SET_VRING_CALL, file);
 }
 
+static int vhost_kernel_set_vring_busyloop_timeout(struct vhost_dev *dev,
+                                                   struct vhost_vring_state *s)
+{
+    return vhost_kernel_call(dev, VHOST_SET_VRING_BUSYLOOP_TIMEOUT, s);
+}
+
 static int vhost_kernel_set_features(struct vhost_dev *dev,
                                      uint64_t features)
 {
@@ -185,6 +191,8 @@ static const VhostOps kernel_ops = {
         .vhost_get_vring_base = vhost_kernel_get_vring_base,
         .vhost_set_vring_kick = vhost_kernel_set_vring_kick,
         .vhost_set_vring_call = vhost_kernel_set_vring_call,
+        .vhost_set_vring_busyloop_timeout =
+                                vhost_kernel_set_vring_busyloop_timeout,
         .vhost_set_features = vhost_kernel_set_features,
         .vhost_get_features = vhost_kernel_get_features,
         .vhost_set_owner = vhost_kernel_set_owner,
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 392d848..6a3e82f 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -963,6 +963,28 @@ static void vhost_eventfd_del(MemoryListener *listener,
 {
 }
 
+static int vhost_virtqueue_set_busyloop_timeout(struct vhost_dev *dev,
+                                                int n, uint32_t timeout)
+{
+    int vhost_vq_index = dev->vhost_ops->vhost_get_vq_index(dev, n);
+    struct vhost_vring_state state = {
+        .index = vhost_vq_index,
+        .num = timeout,
+    };
+    int r;
+
+    if (!dev->vhost_ops->vhost_set_vring_busyloop_timeout) {
+        return -EINVAL;
+    }
+
+    r = dev->vhost_ops->vhost_set_vring_busyloop_timeout(dev, &state);
+    if (r) {
+        return r;
+    }
+
+    return 0;
+}
+
 static int vhost_virtqueue_init(struct vhost_dev *dev,
                                 struct vhost_virtqueue *vq, int n)
 {
@@ -993,7 +1015,7 @@ static void vhost_virtqueue_cleanup(struct vhost_virtqueue *vq)
 }
 
 int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
-                   VhostBackendType backend_type)
+                   VhostBackendType backend_type, uint32_t busyloop_timeout)
 {
     uint64_t features;
     int i, r;
@@ -1034,6 +1056,17 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
             goto fail_vq;
         }
     }
+
+    if (busyloop_timeout) {
+        for (i = 0; i < hdev->nvqs; ++i) {
+            r = vhost_virtqueue_set_busyloop_timeout(hdev, hdev->vq_index + i,
+                                                     busyloop_timeout);
+            if (r < 0) {
+                goto fail_busyloop;
+            }
+        }
+    }
+
     hdev->features = features;
 
     hdev->memory_listener = (MemoryListener) {
@@ -1076,6 +1109,11 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
     hdev->memory_changed = false;
     memory_listener_register(&hdev->memory_listener, &address_space_memory);
     return 0;
+fail_busyloop:
+    while (--i >= 0) {
+        vhost_virtqueue_set_busyloop_timeout(hdev, hdev->vq_index + i, 0);
+    }
+    i = hdev->nvqs;
 fail_vq:
     while (--i >= 0) {
         vhost_virtqueue_cleanup(hdev->vqs + i);
diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
index 95fcc96..84e1cb7 100644
--- a/include/hw/virtio/vhost-backend.h
+++ b/include/hw/virtio/vhost-backend.h
@@ -57,6 +57,8 @@ typedef int (*vhost_set_vring_kick_op)(struct vhost_dev *dev,
                                        struct vhost_vring_file *file);
 typedef int (*vhost_set_vring_call_op)(struct vhost_dev *dev,
                                        struct vhost_vring_file *file);
+typedef int (*vhost_set_vring_busyloop_timeout_op)(struct vhost_dev *dev,
+                                                   struct vhost_vring_state *r);
 typedef int (*vhost_set_features_op)(struct vhost_dev *dev,
                                      uint64_t features);
 typedef int (*vhost_get_features_op)(struct vhost_dev *dev,
@@ -91,6 +93,7 @@ typedef struct VhostOps {
     vhost_get_vring_base_op vhost_get_vring_base;
     vhost_set_vring_kick_op vhost_set_vring_kick;
     vhost_set_vring_call_op vhost_set_vring_call;
+    vhost_set_vring_busyloop_timeout_op vhost_set_vring_busyloop_timeout;
     vhost_set_features_op vhost_set_features;
     vhost_get_features_op vhost_get_features;
     vhost_set_owner_op vhost_set_owner;
diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
index b60d758..2106ed8 100644
--- a/include/hw/virtio/vhost.h
+++ b/include/hw/virtio/vhost.h
@@ -64,7 +64,8 @@ struct vhost_dev {
 };
 
 int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
-                   VhostBackendType backend_type);
+                   VhostBackendType backend_type,
+                   uint32_t busyloop_timeout);
 void vhost_dev_cleanup(struct vhost_dev *hdev);
 int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev);
 void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev);
diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h
index 3389b41..8354b98 100644
--- a/include/net/vhost_net.h
+++ b/include/net/vhost_net.h
@@ -10,6 +10,7 @@ typedef struct vhost_net VHostNetState;
 typedef struct VhostNetOptions {
     VhostBackendType backend_type;
     NetClientState *net_backend;
+    uint32_t busyloop_timeout;
     void *opaque;
 } VhostNetOptions;
 
diff --git a/net/tap.c b/net/tap.c
index 8f790d1..90f12c7 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -661,6 +661,11 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
 
         options.backend_type = VHOST_BACKEND_TYPE_KERNEL;
         options.net_backend = &s->nc;
+        if (tap->has_vhost_poll_us) {
+            options.busyloop_timeout = tap->vhost_poll_us;
+        } else {
+            options.busyloop_timeout = 0;
+        }
 
         if (vhostfdname) {
             vhostfd = monitor_fd_param(cur_mon, vhostfdname, &err);
@@ -684,8 +689,9 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
                        "vhost-net requested but could not be initialized");
             return;
         }
-    } else if (vhostfdname) {
-        error_setg(errp, "vhostfd= is not valid without vhost");
+    } else if (vhostfdname || tap->has_vhost_poll_us) {
+        error_setg(errp, "vhostfd(s)= or vhost_poll_us= is not valid"
+                         " without vhost");
     }
 }
 
diff --git a/net/vhost-user.c b/net/vhost-user.c
index 1b9e73a..b200182 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -80,6 +80,7 @@ static int vhost_user_start(int queues, NetClientState *ncs[])
 
         options.net_backend = ncs[i];
         options.opaque      = s->chr;
+        options.busyloop_timeout = 0;
         s->vhost_net = vhost_net_init(&options);
         if (!s->vhost_net) {
             error_report("failed to init vhost_net for queue %d", i);
diff --git a/qapi-schema.json b/qapi-schema.json
index 88f9b81..ea56a01 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2532,7 +2532,8 @@
     '*vhostfd':    'str',
     '*vhostfds':   'str',
     '*vhostforce': 'bool',
-    '*queues':     'uint32'} }
+    '*queues':     'uint32',
+    '*vhost_poll_us': 'uint32'} }
 
 ##
 # @NetdevSocketOptions
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH 2/2] tap: vhost busy polling support
  2016-03-21  5:25 ` [Qemu-devel] [PATCH 2/2] tap: vhost busy polling support Jason Wang
@ 2016-03-21  7:26   ` Fam Zheng
  2016-03-25  7:45     ` Jason Wang
  2016-03-24 20:34   ` Eric Blake
  1 sibling, 1 reply; 11+ messages in thread
From: Fam Zheng @ 2016-03-21  7:26 UTC (permalink / raw)
  To: Jason Wang; +Cc: qemu-devel, mst

On Mon, 03/21 13:25, Jason Wang wrote:
> diff --git a/qapi-schema.json b/qapi-schema.json
> index 88f9b81..ea56a01 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -2532,7 +2532,8 @@
>      '*vhostfd':    'str',
>      '*vhostfds':   'str',
>      '*vhostforce': 'bool',
> -    '*queues':     'uint32'} }
> +    '*queues':     'uint32',
> +    '*vhost_poll_us': 'uint32'} }

Need to update the comment too?

Fam

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH 2/2] tap: vhost busy polling support
  2016-03-21  5:25 ` [Qemu-devel] [PATCH 2/2] tap: vhost busy polling support Jason Wang
  2016-03-21  7:26   ` Fam Zheng
@ 2016-03-24 20:34   ` Eric Blake
  2016-03-25  7:46     ` Jason Wang
  1 sibling, 1 reply; 11+ messages in thread
From: Eric Blake @ 2016-03-24 20:34 UTC (permalink / raw)
  To: Jason Wang, mst, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 901 bytes --]

On 03/20/2016 11:25 PM, Jason Wang wrote:
> This patch add the capability of basic vhost net busy polling which is
> supported by recent kernel. User could configure the maximum number of
> us that could be spent on busy polling through a new property of tap
> "vhost_poll_us".
> 
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---

> +++ b/qapi-schema.json
> @@ -2532,7 +2532,8 @@
>      '*vhostfd':    'str',
>      '*vhostfds':   'str',
>      '*vhostforce': 'bool',
> -    '*queues':     'uint32'} }
> +    '*queues':     'uint32',
> +    '*vhost_poll_us': 'uint32'} }

Missing documentation.

New interfaces should prefer '-' over '_'; but this is an existing
interface where we already have 'vnet_hdr', so intra-command consistency
makes your naming okay.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH 2/2] tap: vhost busy polling support
  2016-03-21  7:26   ` Fam Zheng
@ 2016-03-25  7:45     ` Jason Wang
  0 siblings, 0 replies; 11+ messages in thread
From: Jason Wang @ 2016-03-25  7:45 UTC (permalink / raw)
  To: Fam Zheng; +Cc: qemu-devel, mst



On 03/21/2016 03:26 PM, Fam Zheng wrote:
> On Mon, 03/21 13:25, Jason Wang wrote:
>> diff --git a/qapi-schema.json b/qapi-schema.json
>> index 88f9b81..ea56a01 100644
>> --- a/qapi-schema.json
>> +++ b/qapi-schema.json
>> @@ -2532,7 +2532,8 @@
>>      '*vhostfd':    'str',
>>      '*vhostfds':   'str',
>>      '*vhostforce': 'bool',
>> -    '*queues':     'uint32'} }
>> +    '*queues':     'uint32',
>> +    '*vhost_poll_us': 'uint32'} }
> Need to update the comment too?
>
> Fam

I thought I did, but looks not :(

Will do it in V2.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH 2/2] tap: vhost busy polling support
  2016-03-24 20:34   ` Eric Blake
@ 2016-03-25  7:46     ` Jason Wang
  0 siblings, 0 replies; 11+ messages in thread
From: Jason Wang @ 2016-03-25  7:46 UTC (permalink / raw)
  To: Eric Blake, mst, qemu-devel



On 03/25/2016 04:34 AM, Eric Blake wrote:
> On 03/20/2016 11:25 PM, Jason Wang wrote:
>> This patch add the capability of basic vhost net busy polling which is
>> supported by recent kernel. User could configure the maximum number of
>> us that could be spent on busy polling through a new property of tap
>> "vhost_poll_us".
>>
>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>> ---
>> +++ b/qapi-schema.json
>> @@ -2532,7 +2532,8 @@
>>      '*vhostfd':    'str',
>>      '*vhostfds':   'str',
>>      '*vhostforce': 'bool',
>> -    '*queues':     'uint32'} }
>> +    '*queues':     'uint32',
>> +    '*vhost_poll_us': 'uint32'} }
> Missing documentation.

Right.

>
> New interfaces should prefer '-' over '_'; but this is an existing
> interface where we already have 'vnet_hdr', so intra-command consistency
> makes your naming okay.
>

Will change to use '-'.

Thanks

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] busy polling support for vhost-kernel
  2016-03-21  5:25 [Qemu-devel] [PATCH 0/2] busy polling support for vhost-kernel Jason Wang
  2016-03-21  5:25 ` [Qemu-devel] [PATCH 1/2] update linux headers to 4.5.0-rc5+ Jason Wang
  2016-03-21  5:25 ` [Qemu-devel] [PATCH 2/2] tap: vhost busy polling support Jason Wang
@ 2016-04-05 15:54 ` Greg Kurz
  2016-04-06  1:49   ` Jason Wang
  2 siblings, 1 reply; 11+ messages in thread
From: Greg Kurz @ 2016-04-05 15:54 UTC (permalink / raw)
  To: Jason Wang; +Cc: qemu-devel, mst

On Mon, 21 Mar 2016 13:25:53 +0800
Jason Wang <jasowang@redhat.com> wrote:
> Hi:
> 
> This series enable vhost-kernel busy polling support. It's done
> through introducing a new property for tap backend - 'vhost_poll_us'
> which is the maximum number of us could be spent for busy polling.
> 
> Please reivew.
> 

Hi Jason !

Do you plan to post v2 with the missing documentation soon ?

Thanks.

--
Greg

> Thanks
> 
> Jason Wang (2):
>   update linux headers to 4.5.0-rc5+
>   tap: vhost busy polling support
> 
>  hw/net/vhost_net.c                              |  2 +-
>  hw/scsi/vhost-scsi.c                            |  2 +-
>  hw/virtio/vhost-backend.c                       |  8 +++
>  hw/virtio/vhost.c                               | 40 ++++++++++-
>  include/hw/virtio/vhost-backend.h               |  3 +
>  include/hw/virtio/vhost.h                       |  3 +-
>  include/net/vhost_net.h                         |  1 +
>  include/standard-headers/asm-x86/hyperv.h       |  4 +-
>  include/standard-headers/linux/input.h          |  1 +
>  include/standard-headers/linux/types.h          |  5 +-
>  include/standard-headers/linux/virtio_balloon.h |  2 +-
>  include/standard-headers/linux/virtio_blk.h     |  6 +-
>  linux-headers/asm-arm64/kvm.h                   |  6 ++
>  linux-headers/asm-powerpc/epapr_hcalls.h        |  4 +-
>  linux-headers/asm-powerpc/kvm.h                 |  9 +++
>  linux-headers/asm-x86/unistd_32.h               |  2 +
>  linux-headers/asm-x86/unistd_64.h               |  2 +
>  linux-headers/linux/kvm.h                       | 11 +++
>  linux-headers/linux/userfaultfd.h               |  2 +-
>  linux-headers/linux/vfio.h                      | 92 ++++++++++++++++++++++++-
>  linux-headers/linux/vhost.h                     |  6 ++
>  net/tap.c                                       | 10 ++-
>  net/vhost-user.c                                |  1 +
>  qapi-schema.json                                |  3 +-
>  24 files changed, 206 insertions(+), 19 deletions(-)
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] busy polling support for vhost-kernel
  2016-04-05 15:54 ` [Qemu-devel] [PATCH 0/2] busy polling support for vhost-kernel Greg Kurz
@ 2016-04-06  1:49   ` Jason Wang
  2016-04-06  7:11     ` Greg Kurz
  0 siblings, 1 reply; 11+ messages in thread
From: Jason Wang @ 2016-04-06  1:49 UTC (permalink / raw)
  To: Greg Kurz; +Cc: qemu-devel, mst



On 04/05/2016 11:54 PM, Greg Kurz wrote:
> On Mon, 21 Mar 2016 13:25:53 +0800
> Jason Wang <jasowang@redhat.com> wrote:
>> > Hi:
>> > 
>> > This series enable vhost-kernel busy polling support. It's done
>> > through introducing a new property for tap backend - 'vhost_poll_us'
>> > which is the maximum number of us could be spent for busy polling.
>> > 
>> > Please reivew.
>> > 
> Hi Jason !
>
> Do you plan to post v2 with the missing documentation soon ?
>
> Thanks.
>
> --
> Greg
>

Hi:

Look like it's not 2.6 material, so plan to do it after 2.6 is out. But
if you wish, I can post it soon.

Thanks

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] busy polling support for vhost-kernel
  2016-04-06  1:49   ` Jason Wang
@ 2016-04-06  7:11     ` Greg Kurz
  2016-04-06  9:16       ` Jason Wang
  0 siblings, 1 reply; 11+ messages in thread
From: Greg Kurz @ 2016-04-06  7:11 UTC (permalink / raw)
  To: Jason Wang; +Cc: qemu-devel, mst

On Wed, 6 Apr 2016 09:49:34 +0800
Jason Wang <jasowang@redhat.com> wrote:

> On 04/05/2016 11:54 PM, Greg Kurz wrote:
> > On Mon, 21 Mar 2016 13:25:53 +0800
> > Jason Wang <jasowang@redhat.com> wrote:  
> >> > Hi:
> >> > 
> >> > This series enable vhost-kernel busy polling support. It's done
> >> > through introducing a new property for tap backend - 'vhost_poll_us'
> >> > which is the maximum number of us could be spent for busy polling.
> >> > 
> >> > Please reivew.
> >> >   
> > Hi Jason !
> >
> > Do you plan to post v2 with the missing documentation soon ?
> >
> > Thanks.
> >
> > --
> > Greg
> >  
> 
> Hi:
> 
> Look like it's not 2.6 material, so plan to do it after 2.6 is out. But

Sure, it is too late for 2.6, but it looks like a promising feature for
2.7.

> if you wish, I can post it soon.
> 
> Thanks
> 

I would appreciate that if that's ok for you.

Thanks !

--
Greg

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] busy polling support for vhost-kernel
  2016-04-06  7:11     ` Greg Kurz
@ 2016-04-06  9:16       ` Jason Wang
  0 siblings, 0 replies; 11+ messages in thread
From: Jason Wang @ 2016-04-06  9:16 UTC (permalink / raw)
  To: Greg Kurz; +Cc: qemu-devel, mst



On 04/06/2016 03:11 PM, Greg Kurz wrote:
> On Wed, 6 Apr 2016 09:49:34 +0800
> Jason Wang <jasowang@redhat.com> wrote:
>
>> > On 04/05/2016 11:54 PM, Greg Kurz wrote:
>>> > > On Mon, 21 Mar 2016 13:25:53 +0800
>>> > > Jason Wang <jasowang@redhat.com> wrote:  
>>>>> > >> > Hi:
>>>>> > >> > 
>>>>> > >> > This series enable vhost-kernel busy polling support. It's done
>>>>> > >> > through introducing a new property for tap backend - 'vhost_poll_us'
>>>>> > >> > which is the maximum number of us could be spent for busy polling.
>>>>> > >> > 
>>>>> > >> > Please reivew.
>>>>> > >> >   
>>> > > Hi Jason !
>>> > >
>>> > > Do you plan to post v2 with the missing documentation soon ?
>>> > >
>>> > > Thanks.
>>> > >
>>> > > --
>>> > > Greg
>>> > >  
>> > 
>> > Hi:
>> > 
>> > Look like it's not 2.6 material, so plan to do it after 2.6 is out. But
> Sure, it is too late for 2.6, but it looks like a promising feature for
> 2.7.
>
>> > if you wish, I can post it soon.
>> > 
>> > Thanks
>> > 
> I would appreciate that if that's ok for you.
>
> Thanks !
>
> --
> Greg
>

Posted, thanks.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-04-06  9:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-21  5:25 [Qemu-devel] [PATCH 0/2] busy polling support for vhost-kernel Jason Wang
2016-03-21  5:25 ` [Qemu-devel] [PATCH 1/2] update linux headers to 4.5.0-rc5+ Jason Wang
2016-03-21  5:25 ` [Qemu-devel] [PATCH 2/2] tap: vhost busy polling support Jason Wang
2016-03-21  7:26   ` Fam Zheng
2016-03-25  7:45     ` Jason Wang
2016-03-24 20:34   ` Eric Blake
2016-03-25  7:46     ` Jason Wang
2016-04-05 15:54 ` [Qemu-devel] [PATCH 0/2] busy polling support for vhost-kernel Greg Kurz
2016-04-06  1:49   ` Jason Wang
2016-04-06  7:11     ` Greg Kurz
2016-04-06  9:16       ` Jason Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.