vhost test fixes
Subsystems (6)
Michael S. Tsirkin
maintainercover vhost test fixes
This fixes up virtio tests, broken by recent changes to core.
Michael S. Tsirkin (4):
tools/virtio: fix build after 4.2 changes
vhost: move features to core
tools/virtio: propagate V=X to kernel build
virtio: introduce avail cache
drivers/vhost/vhost.h | 4 +++- tools/virtio/asm/barrier.h | 2 ++ tools/virtio/linux/export.h | 3 +++ tools/virtio/linux/kernel.h | 8 ++++++++ drivers/vhost/net.c | 3 +-- drivers/vhost/scsi.c | 4 +--- drivers/vhost/test.c | 3 +++ drivers/virtio/virtio_ring.c | 11 ++++++++++- tools/virtio/Makefile | 2 +- 9 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 tools/virtio/linux/export.h
Signature · 1 line
MST
Michael S. Tsirkin
maintainerPATCH 1/4 tools/virtio: fix build after 4.2 changes
more stubs, mostly
--- tools/virtio/asm/barrier.h | 2 ++ tools/virtio/linux/export.h | 3 +++ tools/virtio/linux/kernel.h | 8 ++++++++ 3 files changed, 13 insertions(+) create mode 100644 tools/virtio/linux/export.h
tools/virtio/asm/barrier.h +2 -0
@@ -3,6 +3,8 @@#define mb () __sync_synchronize()#define smp_mb () mb() +# define dma_rmb () barrier() +# define dma_wmb () barrier()# define smp_rmb () barrier()# define smp_wmb () barrier()/* Weak barriers should be used. If not - it's a bug */
tools/virtio/linux/export.h new file +3 -0
@@ -0,0 +1,3 @@ +#define EXPORT_SYMBOL_GPL (sym) extern typeof(sym) sym +#define EXPORT_SYMBOL (sym) extern typeof(sym) sym +
tools/virtio/linux/kernel.h +8 -0
@@ -22,6 +22,7 @@typedef unsigned long long dma_addr_t ;typedef size_t __kernel_size_t ; +typedef unsigned int __wsum ;struct page {unsigned long long dummy;
@@ -47,6 +48,13 @@ static inline void *kmalloc(size_t s, gfp_t gfp)return __kmalloc_fake;return malloc (s); } +static inline void *kzalloc (size_t s,gfp_t gfp) +{ +void *p =kmalloc (s, gfp); + +memset (p,0 , s); +return p; +}static inline void kfree (void *p) {
Signature · 1 line
MST
Michael S. Tsirkin
maintainerPATCH 2/4 vhost: move features to core
In reply to Michael S. Tsirkinvirtio 1 and any layout are core features, move them there. This fixes vhost test.
--- drivers/vhost/vhost.h | 4 +++- drivers/vhost/net.c | 3 +-- drivers/vhost/scsi.c | 4 +--- drivers/vhost/test.c | 3 +++ 4 files changed, 8 insertions(+), 6 deletions(-)
drivers/vhost/vhost.h +3 -1
@@ -173,7 +173,9 @@ enum {VHOST_FEATURES = (1ULL <<VIRTIO_F_NOTIFY_ON_EMPTY ) | (1ULL <<VIRTIO_RING_F_INDIRECT_DESC ) | (1ULL <<VIRTIO_RING_F_EVENT_IDX ) | - (1ULL << VHOST_F_LOG_ALL), + (1ULL <<VHOST_F_LOG_ALL ) | + (1ULL <<VIRTIO_F_ANY_LAYOUT ) | + (1ULL << VIRTIO_F_VERSION_1) };static inline bool vhost_has_feature (struct vhost_virtqueue *vq,int bit)
drivers/vhost/net.c +1 -2
@@ -61,8 +61,7 @@ MODULE_PARM_DESC(experimental_zcopytx, "Enable Zero Copy TX;"enum {VHOST_NET_FEATURES =VHOST_FEATURES | (1ULL <<VHOST_NET_F_VIRTIO_NET_HDR ) | - (1ULL <<VIRTIO_NET_F_MRG_RXBUF ) | - (1ULL <<VIRTIO_F_VERSION_1 ), + (1ULL << VIRTIO_NET_F_MRG_RXBUF); };enum {
drivers/vhost/scsi.c +1 -3
@@ -166,9 +166,7 @@ enum {/* Note: can't set VIRTIO_F_VERSION_1 yet, since that implies ANY_LAYOUT. */ enum {VHOST_SCSI_FEATURES =VHOST_FEATURES | (1ULL <<VIRTIO_SCSI_F_HOTPLUG ) | - (1ULL <<VIRTIO_SCSI_F_T10_PI ) | - (1ULL <<VIRTIO_F_ANY_LAYOUT ) | - (1ULL <<VIRTIO_F_VERSION_1 ) + (1ULL << VIRTIO_SCSI_F_T10_PI); };#define VHOST_SCSI_MAX_TARGET 256
drivers/vhost/test.c +3 -0
@@ -277,10 +277,13 @@ static long vhost_test_ioctl(struct file *f, unsigned int ioctl,return -EFAULT ;return 0 ;case VHOST_SET_FEATURES : +printk (KERN_ERR "1\n" );if (copy_from_user (&features, featurep,sizeof features))return -EFAULT ; +printk (KERN_ERR "2\n" );if (features & ~VHOST_FEATURES )return -EOPNOTSUPP ; +printk (KERN_ERR "3\n" );return vhost_test_set_features (n, features);case VHOST_RESET_OWNER :return vhost_test_reset_owner (n);
Signature · 1 line
MST
Re: [PATCH 2/4] vhost: move features to core
Hello.
Quoted 4 lines · Michael S. Tsirkin
virtio 1 and any layout are core features, move them there. This fixes vhost test.
Signed-off-by Michael S. Tsirkin <[email protected]>
[...]
Quoted 8 lines
drivers/vhost/test.c +0
-0@@ -277,10 +277,13 @@ static long vhost_test_ioctl(struct file *f, unsigned int ioctl,return -EFAULT ;return 0 ;case VHOST_SET_FEATURES :
drivers/vhost/test.c static long vhost_test_ioctl(struct file *f, unsigned int ioctl, · line 289
Quoted 10 lines
drivers/vhost/test.c +3
-0+printk (KERN_ERR "1\n" );if (copy_from_user (&features, featurep,sizeof features))return -EFAULT ; +printk (KERN_ERR "2\n" );if (features & ~VHOST_FEATURES )return -EOPNOTSUPP ; +printk (KERN_ERR "3\n" );return vhost_test_set_features (n, features);case VHOST_RESET_OWNER :return vhost_test_reset_owner (n);
Debugging printk's remained?
MBR, Sergei
Michael S. Tsirkin
maintainerPATCH 3/4 tools/virtio: propagate V=X to kernel build
In reply to Michael S. Tsirkin--- tools/virtio/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/virtio/Makefile +1 -1
@@ -6,7 +6,7 @@ vringh_test: vringh_test.o vringh.o virtio_ring.o CFLAGS += -g -O2 -Werror -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE vpath %.c ../../drivers/virtio ../../drivers/vhost mod: - ${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test + ${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test V=${V} .PHONY: all test mod clean clean: ${RM} *.o vringh_test virtio_test vhost_test/*.o vhost_test/.*.cmd \
Signature · 1 line
MST
Michael S. Tsirkin
maintainerPATCH 3/4 tools/virtio: propagate V=X to kernel build
In reply to Michael S. Tsirkin--- tools/virtio/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/virtio/Makefile +1 -1
@@ -6,7 +6,7 @@ vringh_test: vringh_test.o vringh.o virtio_ring.o CFLAGS += -g -O2 -Werror -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE vpath %.c ../../drivers/virtio ../../drivers/vhost mod: - ${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test + ${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test V=${V} .PHONY: all test mod clean clean: ${RM} *.o vringh_test virtio_test vhost_test/*.o vhost_test/.*.cmd \
Signature · 1 line
MST
Michael S. Tsirkin
maintainerPATCH 4/4 virtio: introduce avail cache
In reply to Michael S. TsirkinThis allows skipping avail ring writes when they
don't need to change. Good for cache locality.
--- drivers/virtio/virtio_ring.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/virtio/virtio_ring.c +10 -1
@@ -91,6 +91,7 @@ struct vring_virtqueue {bool last_add_time_valid;ktime_t last_add_time;#endif +u16 *avail;/* Tokens for callbacks. */ void *data[];
@@ -236,7 +237,10 @@ static inline int virtqueue_add(struct virtqueue *_vq,/* Put entry in available array (but don't update avail->idx until they * do sync). */ avail =virtio16_to_cpu (_vq->vdev, vq->vring.avail->idx) & (vq->vring.num -1 ); - vq->vring.avail->ring[avail] =cpu_to_virtio16 (_vq->vdev, head); +if (vq->avail[avail] != head) { + vq->avail[avail] = head; + vq->vring.avail->ring[avail] =cpu_to_virtio16 (_vq->vdev, head); + }/* Descriptors and available array need to be set before we expose the * new available array entries. */
@@ -724,6 +728,11 @@ struct virtqueue *vring_new_virtqueue(unsigned int index, vq =kmalloc (sizeof (*vq) +sizeof (void *)*num,GFP_KERNEL );if (!vq)return NULL ; + vq->avail =kzalloc (sizeof (*vq->avail) * num,GFP_KERNEL ); +if (!vq->avail) { +kfree (vq); +return NULL ; + }vring_init (&vq->vring, num, pages, vring_align); vq->vq.callback = callback;
Signature · 1 line
MST
Michael S. Tsirkin
maintainerPATCH 4/4 virtio: introduce avail cache
In reply to Michael S. TsirkinThis allows skipping avail ring writes when they
don't need to change. Good for cache locality.
--- drivers/virtio/virtio_ring.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/virtio/virtio_ring.c +10 -1
@@ -91,6 +91,7 @@ struct vring_virtqueue {bool last_add_time_valid;ktime_t last_add_time;#endif +u16 *avail;/* Tokens for callbacks. */ void *data[];
@@ -236,7 +237,10 @@ static inline int virtqueue_add(struct virtqueue *_vq,/* Put entry in available array (but don't update avail->idx until they * do sync). */ avail =virtio16_to_cpu (_vq->vdev, vq->vring.avail->idx) & (vq->vring.num -1 ); - vq->vring.avail->ring[avail] =cpu_to_virtio16 (_vq->vdev, head); +if (vq->avail[avail] != head) { + vq->avail[avail] = head; + vq->vring.avail->ring[avail] =cpu_to_virtio16 (_vq->vdev, head); + }/* Descriptors and available array need to be set before we expose the * new available array entries. */
@@ -724,6 +728,11 @@ struct virtqueue *vring_new_virtqueue(unsigned int index, vq =kmalloc (sizeof (*vq) +sizeof (void *)*num,GFP_KERNEL );if (!vq)return NULL ; + vq->avail =kzalloc (sizeof (*vq->avail) * num,GFP_KERNEL ); +if (!vq->avail) { +kfree (vq); +return NULL ; + }vring_init (&vq->vring, num, pages, vring_align); vq->vq.callback = callback;
Signature · 1 line
MST