* [PATCH 1/4] tools/virtio: fix build after 4.2 changes
[not found] <1441869802-15847-1-git-send-email-mst@redhat.com>
@ 2015-09-10 7:23 ` Michael S. Tsirkin
2015-09-10 7:23 ` [PATCH 2/4] vhost: move features to core Michael S. Tsirkin
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2015-09-10 7:23 UTC (permalink / raw)
To: linux-kernel; +Cc: Xie, Huawei, virtualization
more stubs, mostly
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
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
diff --git a/tools/virtio/asm/barrier.h b/tools/virtio/asm/barrier.h
index aff61e1..26b7926 100644
--- a/tools/virtio/asm/barrier.h
+++ b/tools/virtio/asm/barrier.h
@@ -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 */
diff --git a/tools/virtio/linux/export.h b/tools/virtio/linux/export.h
new file mode 100644
index 0000000..416875e
--- /dev/null
+++ b/tools/virtio/linux/export.h
@@ -0,0 +1,3 @@
+#define EXPORT_SYMBOL_GPL(sym) extern typeof(sym) sym
+#define EXPORT_SYMBOL(sym) extern typeof(sym) sym
+
diff --git a/tools/virtio/linux/kernel.h b/tools/virtio/linux/kernel.h
index 1e8ce69..0a3da64 100644
--- a/tools/virtio/linux/kernel.h
+++ b/tools/virtio/linux/kernel.h
@@ -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)
{
--
MST
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] vhost: move features to core
[not found] <1441869802-15847-1-git-send-email-mst@redhat.com>
2015-09-10 7:23 ` [PATCH 1/4] tools/virtio: fix build after 4.2 changes Michael S. Tsirkin
@ 2015-09-10 7:23 ` Michael S. Tsirkin
2015-09-10 19:15 ` Sergei Shtylyov
2015-09-10 7:23 ` [PATCH 3/4] tools/virtio: propagate V=X to kernel build Michael S. Tsirkin
2015-09-10 7:23 ` [PATCH 4/4] virtio: introduce avail cache Michael S. Tsirkin
3 siblings, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2015-09-10 7:23 UTC (permalink / raw)
To: linux-kernel; +Cc: netdev, Xie, Huawei, kvm, virtualization
virtio 1 and any layout are core features, move them
there. This fixes vhost test.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
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(-)
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index ce6f6da..4772862 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -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)
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 7d137a4..fa68bc9 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -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 {
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index dfcc02c..0321fc4 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -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
diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c
index d9c501e..f2882ac 100644
--- a/drivers/vhost/test.c
+++ b/drivers/vhost/test.c
@@ -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);
--
MST
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] tools/virtio: propagate V=X to kernel build
[not found] <1441869802-15847-1-git-send-email-mst@redhat.com>
2015-09-10 7:23 ` [PATCH 1/4] tools/virtio: fix build after 4.2 changes Michael S. Tsirkin
2015-09-10 7:23 ` [PATCH 2/4] vhost: move features to core Michael S. Tsirkin
@ 2015-09-10 7:23 ` Michael S. Tsirkin
2015-09-10 7:23 ` [PATCH 4/4] virtio: introduce avail cache Michael S. Tsirkin
3 siblings, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2015-09-10 7:23 UTC (permalink / raw)
To: linux-kernel; +Cc: Xie, Huawei, virtualization
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tools/virtio/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/virtio/Makefile b/tools/virtio/Makefile
index 505ad51..39c89a5 100644
--- a/tools/virtio/Makefile
+++ b/tools/virtio/Makefile
@@ -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 \
--
MST
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] virtio: introduce avail cache
[not found] <1441869802-15847-1-git-send-email-mst@redhat.com>
` (2 preceding siblings ...)
2015-09-10 7:23 ` [PATCH 3/4] tools/virtio: propagate V=X to kernel build Michael S. Tsirkin
@ 2015-09-10 7:23 ` Michael S. Tsirkin
3 siblings, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2015-09-10 7:23 UTC (permalink / raw)
To: linux-kernel; +Cc: Xie, Huawei, virtualization
This allows skipping avail ring writes when they
don't need to change. Good for cache locality.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
drivers/virtio/virtio_ring.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 096b857..14e7ce9 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -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;
--
MST
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/4] vhost: move features to core
2015-09-10 7:23 ` [PATCH 2/4] vhost: move features to core Michael S. Tsirkin
@ 2015-09-10 19:15 ` Sergei Shtylyov
0 siblings, 0 replies; 5+ messages in thread
From: Sergei Shtylyov @ 2015-09-10 19:15 UTC (permalink / raw)
To: Michael S. Tsirkin, linux-kernel; +Cc: netdev, Xie, Huawei, kvm, virtualization
Hello.
On 09/10/2015 10:23 AM, Michael S. Tsirkin wrote:
> virtio 1 and any layout are core features, move them
> there. This fixes vhost test.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
[...]
> diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c
> index d9c501e..f2882ac 100644
> --- a/drivers/vhost/test.c
> +++ b/drivers/vhost/test.c
> @@ -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);
Debugging printk's remained?
MBR, Sergei
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-09-10 19:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1441869802-15847-1-git-send-email-mst@redhat.com>
2015-09-10 7:23 ` [PATCH 1/4] tools/virtio: fix build after 4.2 changes Michael S. Tsirkin
2015-09-10 7:23 ` [PATCH 2/4] vhost: move features to core Michael S. Tsirkin
2015-09-10 19:15 ` Sergei Shtylyov
2015-09-10 7:23 ` [PATCH 3/4] tools/virtio: propagate V=X to kernel build Michael S. Tsirkin
2015-09-10 7:23 ` [PATCH 4/4] virtio: introduce avail cache Michael S. Tsirkin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).