qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/4] virtio-blk: fix issues with unified virtio-blk request handling
@ 2014-07-01 15:25 Stefan Hajnoczi
  2014-07-01 15:25 ` [Qemu-devel] [PATCH v2 1/4] virtio-blk: avoid dataplane VirtIOBlockReq early free Stefan Hajnoczi
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2014-07-01 15:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Paolo Bonzini, ming.lei, Fam Zheng, Stefan Hajnoczi

This series fixes issues recently introduced when unifying virtio-blk
dataplane's request handling with non-dataplane virtio-blk.

The problems include broken memory allocation for dataplane requests and a
performance regression for non-dataplane.  See the patches for details.

Stefan Hajnoczi (4):
  virtio-blk: avoid dataplane VirtIOBlockReq early free
  dataplane: do not free VirtQueueElement in vring_push()
  virtio-blk: avoid g_slice_new0() for VirtIOBlockReq and
    VirtQueueElement
  virtio-blk: embed VirtQueueElement in VirtIOBlockReq

 hw/block/dataplane/virtio-blk.c     | 30 +++++++++++-----------
 hw/block/virtio-blk.c               | 50 ++++++++++++++++++-------------------
 hw/virtio/dataplane/vring.c         | 22 ++++++----------
 include/hw/virtio/dataplane/vring.h |  3 +--
 include/hw/virtio/virtio-blk.h      |  6 ++++-
 5 files changed, 53 insertions(+), 58 deletions(-)

-- 
1.9.3

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

* [Qemu-devel] [PATCH v2 1/4] virtio-blk: avoid dataplane VirtIOBlockReq early free
  2014-07-01 15:25 [Qemu-devel] [PATCH v2 0/4] virtio-blk: fix issues with unified virtio-blk request handling Stefan Hajnoczi
@ 2014-07-01 15:25 ` Stefan Hajnoczi
  2014-07-01 15:25 ` [Qemu-devel] [PATCH v2 2/4] dataplane: do not free VirtQueueElement in vring_push() Stefan Hajnoczi
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2014-07-01 15:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Paolo Bonzini, ming.lei, Fam Zheng, Stefan Hajnoczi

VirtIOBlockReq is freed later by virtio_blk_free_request() in
hw/block/virtio-blk.c.  Remove this extraneous g_slice_free().

This patch fixes the following segfault:

  0x00005555556373af in virtio_blk_rw_complete (opaque=0x5555565ff5e0, ret=0) at hw/block/virtio-blk.c:99
  99          bdrv_acct_done(req->dev->bs, &req->acct);
  (gdb) print req
  $1 = (VirtIOBlockReq *) 0x5555565ff5e0
  (gdb) print req->dev
  $2 = (VirtIOBlock *) 0x0
  (gdb) bt
  #0  0x00005555556373af in virtio_blk_rw_complete (opaque=0x5555565ff5e0, ret=0) at hw/block/virtio-blk.c:99
  #1  0x0000555555840ebe in bdrv_co_em_bh (opaque=0x5555566152d0) at block.c:4675
  #2  0x000055555583de77 in aio_bh_poll (ctx=ctx@entry=0x5555563a8150) at async.c:81
  #3  0x000055555584b7a7 in aio_poll (ctx=0x5555563a8150, blocking=blocking@entry=true) at aio-posix.c:188
  #4  0x00005555556e520e in iothread_run (opaque=0x5555563a7fd8) at iothread.c:41
  #5  0x00007ffff42ba124 in start_thread () from /usr/lib/libpthread.so.0
  #6  0x00007ffff16d14bd in clone () from /usr/lib/libc.so.6

Reported-by: Max Reitz <mreitz@redhat.com>
Cc: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/block/dataplane/virtio-blk.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 4c5ba18..6cd75f6 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -68,7 +68,6 @@ static void complete_request_vring(VirtIOBlockReq *req, unsigned char status)
     vring_push(&req->dev->dataplane->vring, req->elem,
                req->qiov.size + sizeof(*req->in));
     notify_guest(req->dev->dataplane);
-    g_slice_free(VirtIOBlockReq, req);
 }
 
 static void handle_notify(EventNotifier *e)
-- 
1.9.3

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

* [Qemu-devel] [PATCH v2 2/4] dataplane: do not free VirtQueueElement in vring_push()
  2014-07-01 15:25 [Qemu-devel] [PATCH v2 0/4] virtio-blk: fix issues with unified virtio-blk request handling Stefan Hajnoczi
  2014-07-01 15:25 ` [Qemu-devel] [PATCH v2 1/4] virtio-blk: avoid dataplane VirtIOBlockReq early free Stefan Hajnoczi
@ 2014-07-01 15:25 ` Stefan Hajnoczi
  2014-07-01 15:25 ` [Qemu-devel] [PATCH v2 3/4] virtio-blk: avoid g_slice_new0() for VirtIOBlockReq and VirtQueueElement Stefan Hajnoczi
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2014-07-01 15:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Paolo Bonzini, ming.lei, Fam Zheng, Stefan Hajnoczi

VirtQueueElement is allocated in vring_pop() so it seems to make sense
that vring_push() should free it.  Alas, virtio-blk frees
VirtQueueElement itself in virtio_blk_free_request().

This patch solves a double-free assertion in glib's g_slice_free().

Rename vring_free_element() to vring_unmap_element() since it no longer
frees the VirtQueueElement.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/virtio/dataplane/vring.c         | 9 ++++-----
 include/hw/virtio/dataplane/vring.h | 1 -
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/hw/virtio/dataplane/vring.c b/hw/virtio/dataplane/vring.c
index 665a1ff..5d17d39 100644
--- a/hw/virtio/dataplane/vring.c
+++ b/hw/virtio/dataplane/vring.c
@@ -272,7 +272,7 @@ static int get_indirect(Vring *vring, VirtQueueElement *elem,
     return 0;
 }
 
-void vring_free_element(VirtQueueElement *elem)
+static void vring_unmap_element(VirtQueueElement *elem)
 {
     int i;
 
@@ -287,8 +287,6 @@ void vring_free_element(VirtQueueElement *elem)
     for (i = 0; i < elem->in_num; i++) {
         vring_unmap(elem->in_sg[i].iov_base, true);
     }
-
-    g_slice_free(VirtQueueElement, elem);
 }
 
 /* This looks in the virtqueue and for the first available buffer, and converts
@@ -402,7 +400,8 @@ out:
         vring->broken = true;
     }
     if (elem) {
-        vring_free_element(elem);
+        vring_unmap_element(elem);
+        g_slice_free(VirtQueueElement, elem);
     }
     *p_elem = NULL;
     return ret;
@@ -418,7 +417,7 @@ void vring_push(Vring *vring, VirtQueueElement *elem, int len)
     unsigned int head = elem->index;
     uint16_t new;
 
-    vring_free_element(elem);
+    vring_unmap_element(elem);
 
     /* Don't touch vring if a fatal error occurred */
     if (vring->broken) {
diff --git a/include/hw/virtio/dataplane/vring.h b/include/hw/virtio/dataplane/vring.h
index 63e7bf4..b23edd2 100644
--- a/include/hw/virtio/dataplane/vring.h
+++ b/include/hw/virtio/dataplane/vring.h
@@ -55,6 +55,5 @@ bool vring_enable_notification(VirtIODevice *vdev, Vring *vring);
 bool vring_should_notify(VirtIODevice *vdev, Vring *vring);
 int vring_pop(VirtIODevice *vdev, Vring *vring, VirtQueueElement **elem);
 void vring_push(Vring *vring, VirtQueueElement *elem, int len);
-void vring_free_element(VirtQueueElement *elem);
 
 #endif /* VRING_H */
-- 
1.9.3

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

* [Qemu-devel] [PATCH v2 3/4] virtio-blk: avoid g_slice_new0() for VirtIOBlockReq and VirtQueueElement
  2014-07-01 15:25 [Qemu-devel] [PATCH v2 0/4] virtio-blk: fix issues with unified virtio-blk request handling Stefan Hajnoczi
  2014-07-01 15:25 ` [Qemu-devel] [PATCH v2 1/4] virtio-blk: avoid dataplane VirtIOBlockReq early free Stefan Hajnoczi
  2014-07-01 15:25 ` [Qemu-devel] [PATCH v2 2/4] dataplane: do not free VirtQueueElement in vring_push() Stefan Hajnoczi
@ 2014-07-01 15:25 ` Stefan Hajnoczi
  2014-07-01 15:25 ` [Qemu-devel] [PATCH v2 4/4] virtio-blk: embed VirtQueueElement in VirtIOBlockReq Stefan Hajnoczi
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2014-07-01 15:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Paolo Bonzini, ming.lei, Fam Zheng, Stefan Hajnoczi

In commit de6c8042ec55da18702fa51f09072fcaa315edc3 ("virtio-blk: Avoid
zeroing every request structure") we avoided the 40 KB memset when
allocating VirtIOBlockReq.

The memset was reintroduced in commit
671ec3f056559f22a2531a91dce3a258b9b5eb8a ("virtio-blk: Convert
VirtIOBlockReq.elem to pointer").

It must be fixed again to avoid a performance regression.

Cc: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/block/virtio-blk.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index aec3146..b06a56d 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -31,9 +31,11 @@
 
 static VirtIOBlockReq *virtio_blk_alloc_request(VirtIOBlock *s)
 {
-    VirtIOBlockReq *req = g_slice_new0(VirtIOBlockReq);
+    VirtIOBlockReq *req = g_slice_new(VirtIOBlockReq);
     req->dev = s;
-    req->elem = g_slice_new0(VirtQueueElement);
+    req->qiov.size = 0;
+    req->next = NULL;
+    req->elem = g_slice_new(VirtQueueElement);
     return req;
 }
 
-- 
1.9.3

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

* [Qemu-devel] [PATCH v2 4/4] virtio-blk: embed VirtQueueElement in VirtIOBlockReq
  2014-07-01 15:25 [Qemu-devel] [PATCH v2 0/4] virtio-blk: fix issues with unified virtio-blk request handling Stefan Hajnoczi
                   ` (2 preceding siblings ...)
  2014-07-01 15:25 ` [Qemu-devel] [PATCH v2 3/4] virtio-blk: avoid g_slice_new0() for VirtIOBlockReq and VirtQueueElement Stefan Hajnoczi
@ 2014-07-01 15:25 ` Stefan Hajnoczi
  2014-07-02  8:25 ` [Qemu-devel] [PATCH v2 0/4] virtio-blk: fix issues with unified virtio-blk request handling Christian Borntraeger
  2014-07-08 14:43 ` Stefan Hajnoczi
  5 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2014-07-01 15:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Paolo Bonzini, ming.lei, Fam Zheng, Stefan Hajnoczi

The memory allocation between hw/block/virtio-blk.c,
hw/block/dataplane/virtio-blk.c, and hw/virtio/dataplane/vring.c is
messy.  Structs are allocated in different files than they are freed in.
This is risky and makes memory leaks easier.

Embed VirtQueueElement in VirtIOBlockReq to reduce the amount of memory
allocation we need to juggle.  This also makes vring.c and virtio.c
slightly more similar.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/block/dataplane/virtio-blk.c     | 29 +++++++++++------------
 hw/block/virtio-blk.c               | 46 ++++++++++++++++++-------------------
 hw/virtio/dataplane/vring.c         | 17 +++++---------
 include/hw/virtio/dataplane/vring.h |  2 +-
 include/hw/virtio/virtio-blk.h      |  6 ++++-
 5 files changed, 48 insertions(+), 52 deletions(-)

diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 6cd75f6..20f12c7 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -65,7 +65,7 @@ static void complete_request_vring(VirtIOBlockReq *req, unsigned char status)
 {
     stb_p(&req->in->status, status);
 
-    vring_push(&req->dev->dataplane->vring, req->elem,
+    vring_push(&req->dev->dataplane->vring, &req->elem,
                req->qiov.size + sizeof(*req->in));
     notify_guest(req->dev->dataplane);
 }
@@ -74,32 +74,31 @@ static void handle_notify(EventNotifier *e)
 {
     VirtIOBlockDataPlane *s = container_of(e, VirtIOBlockDataPlane,
                                            host_notifier);
-
-    VirtQueueElement *elem;
-    VirtIOBlockReq *req;
-    int ret;
-    MultiReqBuffer mrb = {
-        .num_writes = 0,
-    };
+    VirtIOBlock *vblk = VIRTIO_BLK(s->vdev);
 
     event_notifier_test_and_clear(&s->host_notifier);
     for (;;) {
+        MultiReqBuffer mrb = {
+            .num_writes = 0,
+        };
+        int ret;
+
         /* Disable guest->host notifies to avoid unnecessary vmexits */
         vring_disable_notification(s->vdev, &s->vring);
 
         for (;;) {
-            ret = vring_pop(s->vdev, &s->vring, &elem);
+            VirtIOBlockReq *req = virtio_blk_alloc_request(vblk);
+
+            ret = vring_pop(s->vdev, &s->vring, &req->elem);
             if (ret < 0) {
-                assert(elem == NULL);
+                virtio_blk_free_request(req);
                 break; /* no more requests */
             }
 
-            trace_virtio_blk_data_plane_process_request(s, elem->out_num,
-                                                        elem->in_num, elem->index);
+            trace_virtio_blk_data_plane_process_request(s, req->elem.out_num,
+                                                        req->elem.in_num,
+                                                        req->elem.index);
 
-            req = g_slice_new(VirtIOBlockReq);
-            req->dev = VIRTIO_BLK(s->vdev);
-            req->elem = elem;
             virtio_blk_handle_request(req, &mrb);
         }
 
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index b06a56d..02cd6b0 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -29,20 +29,18 @@
 #include "hw/virtio/virtio-bus.h"
 #include "hw/virtio/virtio-access.h"
 
-static VirtIOBlockReq *virtio_blk_alloc_request(VirtIOBlock *s)
+VirtIOBlockReq *virtio_blk_alloc_request(VirtIOBlock *s)
 {
     VirtIOBlockReq *req = g_slice_new(VirtIOBlockReq);
     req->dev = s;
     req->qiov.size = 0;
     req->next = NULL;
-    req->elem = g_slice_new(VirtQueueElement);
     return req;
 }
 
-static void virtio_blk_free_request(VirtIOBlockReq *req)
+void virtio_blk_free_request(VirtIOBlockReq *req)
 {
     if (req) {
-        g_slice_free(VirtQueueElement, req->elem);
         g_slice_free(VirtIOBlockReq, req);
     }
 }
@@ -56,7 +54,7 @@ static void virtio_blk_complete_request(VirtIOBlockReq *req,
     trace_virtio_blk_req_complete(req, status);
 
     stb_p(&req->in->status, status);
-    virtqueue_push(s->vq, req->elem, req->qiov.size + sizeof(*req->in));
+    virtqueue_push(s->vq, &req->elem, req->qiov.size + sizeof(*req->in));
     virtio_notify(vdev, s->vq);
 }
 
@@ -121,7 +119,7 @@ static VirtIOBlockReq *virtio_blk_get_request(VirtIOBlock *s)
 {
     VirtIOBlockReq *req = virtio_blk_alloc_request(s);
 
-    if (!virtqueue_pop(s->vq, req->elem)) {
+    if (!virtqueue_pop(s->vq, &req->elem)) {
         virtio_blk_free_request(req);
         return NULL;
     }
@@ -254,7 +252,7 @@ static void virtio_blk_handle_scsi(VirtIOBlockReq *req)
 {
     int status;
 
-    status = virtio_blk_handle_scsi_req(req->dev, req->elem);
+    status = virtio_blk_handle_scsi_req(req->dev, &req->elem);
     virtio_blk_req_complete(req, status);
     virtio_blk_free_request(req);
 }
@@ -351,12 +349,12 @@ static void virtio_blk_handle_read(VirtIOBlockReq *req)
 void virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb)
 {
     uint32_t type;
-    struct iovec *in_iov = req->elem->in_sg;
-    struct iovec *iov = req->elem->out_sg;
-    unsigned in_num = req->elem->in_num;
-    unsigned out_num = req->elem->out_num;
+    struct iovec *in_iov = req->elem.in_sg;
+    struct iovec *iov = req->elem.out_sg;
+    unsigned in_num = req->elem.in_num;
+    unsigned out_num = req->elem.out_num;
 
-    if (req->elem->out_num < 1 || req->elem->in_num < 1) {
+    if (req->elem.out_num < 1 || req->elem.in_num < 1) {
         error_report("virtio-blk missing headers");
         exit(1);
     }
@@ -393,19 +391,19 @@ void virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb)
          * NB: per existing s/n string convention the string is
          * terminated by '\0' only when shorter than buffer.
          */
-        strncpy(req->elem->in_sg[0].iov_base,
+        strncpy(req->elem.in_sg[0].iov_base,
                 s->blk.serial ? s->blk.serial : "",
-                MIN(req->elem->in_sg[0].iov_len, VIRTIO_BLK_ID_BYTES));
+                MIN(req->elem.in_sg[0].iov_len, VIRTIO_BLK_ID_BYTES));
         virtio_blk_req_complete(req, VIRTIO_BLK_S_OK);
         virtio_blk_free_request(req);
     } else if (type & VIRTIO_BLK_T_OUT) {
-        qemu_iovec_init_external(&req->qiov, &req->elem->out_sg[1],
-                                 req->elem->out_num - 1);
+        qemu_iovec_init_external(&req->qiov, &req->elem.out_sg[1],
+                                 req->elem.out_num - 1);
         virtio_blk_handle_write(req, mrb);
     } else if (type == VIRTIO_BLK_T_IN || type == VIRTIO_BLK_T_BARRIER) {
         /* VIRTIO_BLK_T_IN is 0, so we can't just & it. */
-        qemu_iovec_init_external(&req->qiov, &req->elem->in_sg[0],
-                                 req->elem->in_num - 1);
+        qemu_iovec_init_external(&req->qiov, &req->elem.in_sg[0],
+                                 req->elem.in_num - 1);
         virtio_blk_handle_read(req);
     } else {
         virtio_blk_req_complete(req, VIRTIO_BLK_S_UNSUPP);
@@ -629,7 +627,7 @@ static void virtio_blk_save_device(VirtIODevice *vdev, QEMUFile *f)
 
     while (req) {
         qemu_put_sbyte(f, 1);
-        qemu_put_buffer(f, (unsigned char *)req->elem,
+        qemu_put_buffer(f, (unsigned char *)&req->elem,
                         sizeof(VirtQueueElement));
         req = req->next;
     }
@@ -654,15 +652,15 @@ static int virtio_blk_load_device(VirtIODevice *vdev, QEMUFile *f,
 
     while (qemu_get_sbyte(f)) {
         VirtIOBlockReq *req = virtio_blk_alloc_request(s);
-        qemu_get_buffer(f, (unsigned char *)req->elem,
+        qemu_get_buffer(f, (unsigned char *)&req->elem,
                         sizeof(VirtQueueElement));
         req->next = s->rq;
         s->rq = req;
 
-        virtqueue_map_sg(req->elem->in_sg, req->elem->in_addr,
-            req->elem->in_num, 1);
-        virtqueue_map_sg(req->elem->out_sg, req->elem->out_addr,
-            req->elem->out_num, 0);
+        virtqueue_map_sg(req->elem.in_sg, req->elem.in_addr,
+            req->elem.in_num, 1);
+        virtqueue_map_sg(req->elem.out_sg, req->elem.out_addr,
+            req->elem.out_num, 0);
     }
 
     return 0;
diff --git a/hw/virtio/dataplane/vring.c b/hw/virtio/dataplane/vring.c
index 5d17d39..67cb2b8 100644
--- a/hw/virtio/dataplane/vring.c
+++ b/hw/virtio/dataplane/vring.c
@@ -301,14 +301,16 @@ static void vring_unmap_element(VirtQueueElement *elem)
  * Stolen from linux/drivers/vhost/vhost.c.
  */
 int vring_pop(VirtIODevice *vdev, Vring *vring,
-              VirtQueueElement **p_elem)
+              VirtQueueElement *elem)
 {
     struct vring_desc desc;
     unsigned int i, head, found = 0, num = vring->vr.num;
     uint16_t avail_idx, last_avail_idx;
-    VirtQueueElement *elem = NULL;
     int ret;
 
+    /* Initialize elem so it can be safely unmapped */
+    elem->in_num = elem->out_num = 0;
+
     /* If there was a fatal error then refuse operation */
     if (vring->broken) {
         ret = -EFAULT;
@@ -340,10 +342,8 @@ int vring_pop(VirtIODevice *vdev, Vring *vring,
      * the index we've seen. */
     head = vring->vr.avail->ring[last_avail_idx % num];
 
-    elem = g_slice_new(VirtQueueElement);
     elem->index = head;
-    elem->in_num = elem->out_num = 0;
-    
+
     /* If their number is silly, that's an error. */
     if (unlikely(head >= num)) {
         error_report("Guest says index %u > %u is available", head, num);
@@ -391,7 +391,6 @@ int vring_pop(VirtIODevice *vdev, Vring *vring,
 
     /* On success, increment avail index. */
     vring->last_avail_idx++;
-    *p_elem = elem;
     return head;
 
 out:
@@ -399,11 +398,7 @@ out:
     if (ret == -EFAULT) {
         vring->broken = true;
     }
-    if (elem) {
-        vring_unmap_element(elem);
-        g_slice_free(VirtQueueElement, elem);
-    }
-    *p_elem = NULL;
+    vring_unmap_element(elem);
     return ret;
 }
 
diff --git a/include/hw/virtio/dataplane/vring.h b/include/hw/virtio/dataplane/vring.h
index b23edd2..af73ee2 100644
--- a/include/hw/virtio/dataplane/vring.h
+++ b/include/hw/virtio/dataplane/vring.h
@@ -53,7 +53,7 @@ void vring_teardown(Vring *vring, VirtIODevice *vdev, int n);
 void vring_disable_notification(VirtIODevice *vdev, Vring *vring);
 bool vring_enable_notification(VirtIODevice *vdev, Vring *vring);
 bool vring_should_notify(VirtIODevice *vdev, Vring *vring);
-int vring_pop(VirtIODevice *vdev, Vring *vring, VirtQueueElement **elem);
+int vring_pop(VirtIODevice *vdev, Vring *vring, VirtQueueElement *elem);
 void vring_push(Vring *vring, VirtQueueElement *elem, int len);
 
 #endif /* VRING_H */
diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h
index 223530e..992da26 100644
--- a/include/hw/virtio/virtio-blk.h
+++ b/include/hw/virtio/virtio-blk.h
@@ -144,7 +144,7 @@ typedef struct MultiReqBuffer {
 
 typedef struct VirtIOBlockReq {
     VirtIOBlock *dev;
-    VirtQueueElement *elem;
+    VirtQueueElement elem;
     struct virtio_blk_inhdr *in;
     struct virtio_blk_outhdr out;
     QEMUIOVector qiov;
@@ -155,6 +155,10 @@ typedef struct VirtIOBlockReq {
 #define DEFINE_VIRTIO_BLK_FEATURES(_state, _field) \
         DEFINE_VIRTIO_COMMON_FEATURES(_state, _field)
 
+VirtIOBlockReq *virtio_blk_alloc_request(VirtIOBlock *s);
+
+void virtio_blk_free_request(VirtIOBlockReq *req);
+
 int virtio_blk_handle_scsi_req(VirtIOBlock *blk,
                                VirtQueueElement *elem);
 
-- 
1.9.3

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

* Re: [Qemu-devel] [PATCH v2 0/4] virtio-blk: fix issues with unified virtio-blk request handling
  2014-07-01 15:25 [Qemu-devel] [PATCH v2 0/4] virtio-blk: fix issues with unified virtio-blk request handling Stefan Hajnoczi
                   ` (3 preceding siblings ...)
  2014-07-01 15:25 ` [Qemu-devel] [PATCH v2 4/4] virtio-blk: embed VirtQueueElement in VirtIOBlockReq Stefan Hajnoczi
@ 2014-07-02  8:25 ` Christian Borntraeger
  2014-07-03 15:41   ` Stefan Hajnoczi
  2014-07-08 14:43 ` Stefan Hajnoczi
  5 siblings, 1 reply; 10+ messages in thread
From: Christian Borntraeger @ 2014-07-02  8:25 UTC (permalink / raw)
  To: Stefan Hajnoczi, qemu-devel
  Cc: Kevin Wolf, Paolo Bonzini, ming.lei, Fam Zheng

On 01/07/14 17:25, Stefan Hajnoczi wrote:
> This series fixes issues recently introduced when unifying virtio-blk
> dataplane's request handling with non-dataplane virtio-blk.
> 
> The problems include broken memory allocation for dataplane requests and a
> performance regression for non-dataplane.  See the patches for details.
> 
> Stefan Hajnoczi (4):
>   virtio-blk: avoid dataplane VirtIOBlockReq early free
>   dataplane: do not free VirtQueueElement in vring_push()
>   virtio-blk: avoid g_slice_new0() for VirtIOBlockReq and
>     VirtQueueElement
>   virtio-blk: embed VirtQueueElement in VirtIOBlockReq
> 
>  hw/block/dataplane/virtio-blk.c     | 30 +++++++++++-----------
>  hw/block/virtio-blk.c               | 50 ++++++++++++++++++-------------------
>  hw/virtio/dataplane/vring.c         | 22 ++++++----------
>  include/hw/virtio/dataplane/vring.h |  3 +--
>  include/hw/virtio/virtio-blk.h      |  6 ++++-
>  5 files changed, 53 insertions(+), 58 deletions(-)
> 

I need patches 1 and 2 to make dataplane work.
For both patches
Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>

Would be good to see both patches in master soon. (no opinion about 3 and 4).

Christian

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

* Re: [Qemu-devel] [PATCH v2 0/4] virtio-blk: fix issues with unified virtio-blk request handling
  2014-07-02  8:25 ` [Qemu-devel] [PATCH v2 0/4] virtio-blk: fix issues with unified virtio-blk request handling Christian Borntraeger
@ 2014-07-03 15:41   ` Stefan Hajnoczi
  0 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2014-07-03 15:41 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: Kevin Wolf, Fam Zheng, Ming Lei, qemu-devel, Stefan Hajnoczi,
	Paolo Bonzini

On Wed, Jul 2, 2014 at 10:25 AM, Christian Borntraeger
<borntraeger@de.ibm.com> wrote:
> On 01/07/14 17:25, Stefan Hajnoczi wrote:
>> This series fixes issues recently introduced when unifying virtio-blk
>> dataplane's request handling with non-dataplane virtio-blk.
>>
>> The problems include broken memory allocation for dataplane requests and a
>> performance regression for non-dataplane.  See the patches for details.
>>
>> Stefan Hajnoczi (4):
>>   virtio-blk: avoid dataplane VirtIOBlockReq early free
>>   dataplane: do not free VirtQueueElement in vring_push()
>>   virtio-blk: avoid g_slice_new0() for VirtIOBlockReq and
>>     VirtQueueElement
>>   virtio-blk: embed VirtQueueElement in VirtIOBlockReq
>>
>>  hw/block/dataplane/virtio-blk.c     | 30 +++++++++++-----------
>>  hw/block/virtio-blk.c               | 50 ++++++++++++++++++-------------------
>>  hw/virtio/dataplane/vring.c         | 22 ++++++----------
>>  include/hw/virtio/dataplane/vring.h |  3 +--
>>  include/hw/virtio/virtio-blk.h      |  6 ++++-
>>  5 files changed, 53 insertions(+), 58 deletions(-)
>>
>
> I need patches 1 and 2 to make dataplane work.
> For both patches
> Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
>
> Would be good to see both patches in master soon. (no opinion about 3 and 4).

These patches are for QEMU 2.1, I'd like to get them applied for -rc1
because they fix critical bugs and a performance regression.

Stefan

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

* Re: [Qemu-devel] [PATCH v2 0/4] virtio-blk: fix issues with unified virtio-blk request handling
  2014-07-01 15:25 [Qemu-devel] [PATCH v2 0/4] virtio-blk: fix issues with unified virtio-blk request handling Stefan Hajnoczi
                   ` (4 preceding siblings ...)
  2014-07-02  8:25 ` [Qemu-devel] [PATCH v2 0/4] virtio-blk: fix issues with unified virtio-blk request handling Christian Borntraeger
@ 2014-07-08 14:43 ` Stefan Hajnoczi
  2014-07-08 15:14   ` Kevin Wolf
  5 siblings, 1 reply; 10+ messages in thread
From: Stefan Hajnoczi @ 2014-07-08 14:43 UTC (permalink / raw)
  To: Kevin Wolf
  Cc: Paolo Bonzini, Ming Lei, Fam Zheng, qemu-devel, Stefan Hajnoczi

On Tue, Jul 1, 2014 at 5:25 PM, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> This series fixes issues recently introduced when unifying virtio-blk
> dataplane's request handling with non-dataplane virtio-blk.
>
> The problems include broken memory allocation for dataplane requests and a
> performance regression for non-dataplane.  See the patches for details.
>
> Stefan Hajnoczi (4):
>   virtio-blk: avoid dataplane VirtIOBlockReq early free
>   dataplane: do not free VirtQueueElement in vring_push()
>   virtio-blk: avoid g_slice_new0() for VirtIOBlockReq and
>     VirtQueueElement
>   virtio-blk: embed VirtQueueElement in VirtIOBlockReq
>
>  hw/block/dataplane/virtio-blk.c     | 30 +++++++++++-----------
>  hw/block/virtio-blk.c               | 50 ++++++++++++++++++-------------------
>  hw/virtio/dataplane/vring.c         | 22 ++++++----------
>  include/hw/virtio/dataplane/vring.h |  3 +--
>  include/hw/virtio/virtio-blk.h      |  6 ++++-
>  5 files changed, 53 insertions(+), 58 deletions(-)

Hi Kevin,
Please include this series in your block pull request.  I missed it
last week and it's needed to fix dataplane in QEMU 2.1.

Thanks,
Stefan

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

* Re: [Qemu-devel] [PATCH v2 0/4] virtio-blk: fix issues with unified virtio-blk request handling
  2014-07-08 14:43 ` Stefan Hajnoczi
@ 2014-07-08 15:14   ` Kevin Wolf
  2014-07-09  7:56     ` Stefan Hajnoczi
  0 siblings, 1 reply; 10+ messages in thread
From: Kevin Wolf @ 2014-07-08 15:14 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: Paolo Bonzini, Ming Lei, Fam Zheng, qemu-devel, Stefan Hajnoczi

Am 08.07.2014 um 16:43 hat Stefan Hajnoczi geschrieben:
> On Tue, Jul 1, 2014 at 5:25 PM, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> > This series fixes issues recently introduced when unifying virtio-blk
> > dataplane's request handling with non-dataplane virtio-blk.
> >
> > The problems include broken memory allocation for dataplane requests and a
> > performance regression for non-dataplane.  See the patches for details.
> >
> > Stefan Hajnoczi (4):
> >   virtio-blk: avoid dataplane VirtIOBlockReq early free
> >   dataplane: do not free VirtQueueElement in vring_push()
> >   virtio-blk: avoid g_slice_new0() for VirtIOBlockReq and
> >     VirtQueueElement
> >   virtio-blk: embed VirtQueueElement in VirtIOBlockReq
> >
> >  hw/block/dataplane/virtio-blk.c     | 30 +++++++++++-----------
> >  hw/block/virtio-blk.c               | 50 ++++++++++++++++++-------------------
> >  hw/virtio/dataplane/vring.c         | 22 ++++++----------
> >  include/hw/virtio/dataplane/vring.h |  3 +--
> >  include/hw/virtio/virtio-blk.h      |  6 ++++-
> >  5 files changed, 53 insertions(+), 58 deletions(-)
> 
> Hi Kevin,
> Please include this series in your block pull request.  I missed it
> last week and it's needed to fix dataplane in QEMU 2.1.

Patch 4 doesn't seem to apply any more. Can you rebase (and include the
Tested-by tags of Christian)?

Kevin

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

* Re: [Qemu-devel] [PATCH v2 0/4] virtio-blk: fix issues with unified virtio-blk request handling
  2014-07-08 15:14   ` Kevin Wolf
@ 2014-07-09  7:56     ` Stefan Hajnoczi
  0 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2014-07-09  7:56 UTC (permalink / raw)
  To: Kevin Wolf
  Cc: Paolo Bonzini, Ming Lei, Fam Zheng, qemu-devel, Stefan Hajnoczi

On Tue, Jul 8, 2014 at 5:14 PM, Kevin Wolf <kwolf@redhat.com> wrote:
> Am 08.07.2014 um 16:43 hat Stefan Hajnoczi geschrieben:
>> On Tue, Jul 1, 2014 at 5:25 PM, Stefan Hajnoczi <stefanha@redhat.com> wrote:
>> > This series fixes issues recently introduced when unifying virtio-blk
>> > dataplane's request handling with non-dataplane virtio-blk.
>> >
>> > The problems include broken memory allocation for dataplane requests and a
>> > performance regression for non-dataplane.  See the patches for details.
>> >
>> > Stefan Hajnoczi (4):
>> >   virtio-blk: avoid dataplane VirtIOBlockReq early free
>> >   dataplane: do not free VirtQueueElement in vring_push()
>> >   virtio-blk: avoid g_slice_new0() for VirtIOBlockReq and
>> >     VirtQueueElement
>> >   virtio-blk: embed VirtQueueElement in VirtIOBlockReq
>> >
>> >  hw/block/dataplane/virtio-blk.c     | 30 +++++++++++-----------
>> >  hw/block/virtio-blk.c               | 50 ++++++++++++++++++-------------------
>> >  hw/virtio/dataplane/vring.c         | 22 ++++++----------
>> >  include/hw/virtio/dataplane/vring.h |  3 +--
>> >  include/hw/virtio/virtio-blk.h      |  6 ++++-
>> >  5 files changed, 53 insertions(+), 58 deletions(-)
>>
>> Hi Kevin,
>> Please include this series in your block pull request.  I missed it
>> last week and it's needed to fix dataplane in QEMU 2.1.
>
> Patch 4 doesn't seem to apply any more. Can you rebase (and include the
> Tested-by tags of Christian)?

Ok.

Stefan

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

end of thread, other threads:[~2014-07-09  7:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-01 15:25 [Qemu-devel] [PATCH v2 0/4] virtio-blk: fix issues with unified virtio-blk request handling Stefan Hajnoczi
2014-07-01 15:25 ` [Qemu-devel] [PATCH v2 1/4] virtio-blk: avoid dataplane VirtIOBlockReq early free Stefan Hajnoczi
2014-07-01 15:25 ` [Qemu-devel] [PATCH v2 2/4] dataplane: do not free VirtQueueElement in vring_push() Stefan Hajnoczi
2014-07-01 15:25 ` [Qemu-devel] [PATCH v2 3/4] virtio-blk: avoid g_slice_new0() for VirtIOBlockReq and VirtQueueElement Stefan Hajnoczi
2014-07-01 15:25 ` [Qemu-devel] [PATCH v2 4/4] virtio-blk: embed VirtQueueElement in VirtIOBlockReq Stefan Hajnoczi
2014-07-02  8:25 ` [Qemu-devel] [PATCH v2 0/4] virtio-blk: fix issues with unified virtio-blk request handling Christian Borntraeger
2014-07-03 15:41   ` Stefan Hajnoczi
2014-07-08 14:43 ` Stefan Hajnoczi
2014-07-08 15:14   ` Kevin Wolf
2014-07-09  7:56     ` Stefan Hajnoczi

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).