qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL for-2.1 0/3] Block patches
@ 2014-07-15 13:55 Stefan Hajnoczi
  2014-07-15 13:55 ` [Qemu-devel] [PULL for-2.1 1/3] linux-aio: Fix laio resource leak Stefan Hajnoczi
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2014-07-15 13:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

The following changes since commit 7a6d04e73fdd571234e05dcad96895fafb3f22f0:

  Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2014-07-14 13:09:29 +0100)

are available in the git repository at:


  git://github.com/stefanha/qemu.git tags/block-pull-request

for you to fetch changes up to 5b2ffbe4d99843fd8305c573a100047a8c962327:

  virtio-blk: dataplane: notify guest as a batch (2014-07-15 15:34:13 +0200)

----------------------------------------------------------------
Block pull request

----------------------------------------------------------------
Gonglei (1):
      linux-aio: Fix laio resource leak

Ming Lei (2):
      virtio-blk: data-plane: fix save/set .complete_request in start
      virtio-blk: dataplane: notify guest as a batch

 block/linux-aio.c               |  5 +++++
 hw/block/dataplane/virtio-blk.c | 27 +++++++++++++++++++++++----
 2 files changed, 28 insertions(+), 4 deletions(-)

-- 
1.9.3

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

* [Qemu-devel] [PULL for-2.1 1/3] linux-aio: Fix laio resource leak
  2014-07-15 13:55 [Qemu-devel] [PULL for-2.1 0/3] Block patches Stefan Hajnoczi
@ 2014-07-15 13:55 ` Stefan Hajnoczi
  2014-07-15 13:55 ` [Qemu-devel] [PULL for-2.1 2/3] virtio-blk: data-plane: fix save/set .complete_request in start Stefan Hajnoczi
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2014-07-15 13:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

From: Gonglei <arei.gonglei@huawei.com>

when hotplug virtio-scsi disks using laio, the aio_nr will
increase in laio_init() by io_setup(), we can see the number by
  # cat /proc/sys/fs/aio-nr
  128
if the aio_nr attach the maxnum, which found from
  # cat /proc/sys/fs/aio-max-nr
  65536
the hotplug process will fail because of aio context leak.

Fix it by io_destroy in laio_cleanup().

Reported-by: daifulai <daifulai@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 block/linux-aio.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/block/linux-aio.c b/block/linux-aio.c
index 4867369..7ac7e8c 100644
--- a/block/linux-aio.c
+++ b/block/linux-aio.c
@@ -310,5 +310,10 @@ void laio_cleanup(void *s_)
     struct qemu_laio_state *s = s_;
 
     event_notifier_cleanup(&s->e);
+
+    if (io_destroy(s->ctx) != 0) {
+        fprintf(stderr, "%s: destroy AIO context %p failed\n",
+                        __func__, &s->ctx);
+    }
     g_free(s);
 }
-- 
1.9.3

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

* [Qemu-devel] [PULL for-2.1 2/3] virtio-blk: data-plane: fix save/set .complete_request in start
  2014-07-15 13:55 [Qemu-devel] [PULL for-2.1 0/3] Block patches Stefan Hajnoczi
  2014-07-15 13:55 ` [Qemu-devel] [PULL for-2.1 1/3] linux-aio: Fix laio resource leak Stefan Hajnoczi
@ 2014-07-15 13:55 ` Stefan Hajnoczi
  2014-07-15 13:55 ` [Qemu-devel] [PULL for-2.1 3/3] virtio-blk: dataplane: notify guest as a batch Stefan Hajnoczi
  2014-07-15 14:50 ` [Qemu-devel] [PULL for-2.1 0/3] Block patches Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2014-07-15 13:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

From: Ming Lei <ming.lei@canonical.com>

The callback has to be saved and reset in virtio_blk_data_plane_start(),
otherwise dataplane's requests will be completed in qemu aio context.

Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/block/dataplane/virtio-blk.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 227bb15..e88862d 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -125,7 +125,6 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *blk,
                                   Error **errp)
 {
     VirtIOBlockDataPlane *s;
-    VirtIOBlock *vblk = VIRTIO_BLK(vdev);
     Error *local_err = NULL;
     BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
@@ -178,8 +177,6 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *blk,
     bdrv_op_block_all(blk->conf.bs, s->blocker);
 
     *dataplane = s;
-    s->saved_complete_request = vblk->complete_request;
-    vblk->complete_request = complete_request_vring;
 }
 
 /* Context: QEMU global mutex held */
@@ -201,6 +198,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s)
 {
     BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s->vdev)));
     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
+    VirtIOBlock *vblk = VIRTIO_BLK(s->vdev);
     VirtQueue *vq;
 
     if (s->started) {
@@ -234,6 +232,9 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s)
     }
     s->host_notifier = *virtio_queue_get_host_notifier(vq);
 
+    s->saved_complete_request = vblk->complete_request;
+    vblk->complete_request = complete_request_vring;
+
     s->starting = false;
     s->started = true;
     trace_virtio_blk_data_plane_start(s);
-- 
1.9.3

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

* [Qemu-devel] [PULL for-2.1 3/3] virtio-blk: dataplane: notify guest as a batch
  2014-07-15 13:55 [Qemu-devel] [PULL for-2.1 0/3] Block patches Stefan Hajnoczi
  2014-07-15 13:55 ` [Qemu-devel] [PULL for-2.1 1/3] linux-aio: Fix laio resource leak Stefan Hajnoczi
  2014-07-15 13:55 ` [Qemu-devel] [PULL for-2.1 2/3] virtio-blk: data-plane: fix save/set .complete_request in start Stefan Hajnoczi
@ 2014-07-15 13:55 ` Stefan Hajnoczi
  2014-07-15 14:50 ` [Qemu-devel] [PULL for-2.1 0/3] Block patches Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2014-07-15 13:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

From: Ming Lei <tom.leiming@gmail.com>

Now requests are submitted as a batch, so it is natural
to notify guest as a batch too.

This may suppress interrupt notification to VM a lot:

        - in my test, decreased by ~13K/sec

Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/block/dataplane/virtio-blk.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index e88862d..d6ba65c 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -34,6 +34,7 @@ struct VirtIOBlockDataPlane {
     VirtIODevice *vdev;
     Vring vring;                    /* virtqueue vring */
     EventNotifier *guest_notifier;  /* irq */
+    QEMUBH *bh;                     /* bh for guest notification */
 
     /* Note that these EventNotifiers are assigned by value.  This is
      * fine as long as you do not call event_notifier_cleanup on them
@@ -61,13 +62,28 @@ static void notify_guest(VirtIOBlockDataPlane *s)
     event_notifier_set(s->guest_notifier);
 }
 
+static void notify_guest_bh(void *opaque)
+{
+    VirtIOBlockDataPlane *s = opaque;
+
+    notify_guest(s);
+}
+
 static void complete_request_vring(VirtIOBlockReq *req, unsigned char status)
 {
+    VirtIOBlockDataPlane *s = req->dev->dataplane;
     stb_p(&req->in->status, status);
 
     vring_push(&req->dev->dataplane->vring, &req->elem,
                req->qiov.size + sizeof(*req->in));
-    notify_guest(req->dev->dataplane);
+
+    /* Suppress notification to guest by BH and its scheduled
+     * flag because requests are completed as a batch after io
+     * plug & unplug is introduced, and the BH can still be
+     * executed in dataplane aio context even after it is
+     * stopped, so needn't worry about notification loss with BH.
+     */
+    qemu_bh_schedule(s->bh);
 }
 
 static void handle_notify(EventNotifier *e)
@@ -172,6 +188,7 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *blk,
         s->iothread = &s->internal_iothread_obj;
     }
     s->ctx = iothread_get_aio_context(s->iothread);
+    s->bh = aio_bh_new(s->ctx, notify_guest_bh, s);
 
     error_setg(&s->blocker, "block device is in use by data plane");
     bdrv_op_block_all(blk->conf.bs, s->blocker);
@@ -190,6 +207,7 @@ void virtio_blk_data_plane_destroy(VirtIOBlockDataPlane *s)
     bdrv_op_unblock_all(s->blk->conf.bs, s->blocker);
     error_free(s->blocker);
     object_unref(OBJECT(s->iothread));
+    qemu_bh_delete(s->bh);
     g_free(s);
 }
 
-- 
1.9.3

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

* Re: [Qemu-devel] [PULL for-2.1 0/3] Block patches
  2014-07-15 13:55 [Qemu-devel] [PULL for-2.1 0/3] Block patches Stefan Hajnoczi
                   ` (2 preceding siblings ...)
  2014-07-15 13:55 ` [Qemu-devel] [PULL for-2.1 3/3] virtio-blk: dataplane: notify guest as a batch Stefan Hajnoczi
@ 2014-07-15 14:50 ` Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2014-07-15 14:50 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: QEMU Developers

On 15 July 2014 14:55, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> The following changes since commit 7a6d04e73fdd571234e05dcad96895fafb3f22f0:
>
>   Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2014-07-14 13:09:29 +0100)
>
> are available in the git repository at:
>
>
>   git://github.com/stefanha/qemu.git tags/block-pull-request
>
> for you to fetch changes up to 5b2ffbe4d99843fd8305c573a100047a8c962327:
>
>   virtio-blk: dataplane: notify guest as a batch (2014-07-15 15:34:13 +0200)
>
> ----------------------------------------------------------------
> Block pull request
>
> ----------------------------------------------------------------
> Gonglei (1):
>       linux-aio: Fix laio resource leak
>
> Ming Lei (2):
>       virtio-blk: data-plane: fix save/set .complete_request in start
>       virtio-blk: dataplane: notify guest as a batch
>
>  block/linux-aio.c               |  5 +++++
>  hw/block/dataplane/virtio-blk.c | 27 +++++++++++++++++++++++----
>  2 files changed, 28 insertions(+), 4 deletions(-)

Applied, thanks.

-- PMM

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

end of thread, other threads:[~2014-07-15 14:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-15 13:55 [Qemu-devel] [PULL for-2.1 0/3] Block patches Stefan Hajnoczi
2014-07-15 13:55 ` [Qemu-devel] [PULL for-2.1 1/3] linux-aio: Fix laio resource leak Stefan Hajnoczi
2014-07-15 13:55 ` [Qemu-devel] [PULL for-2.1 2/3] virtio-blk: data-plane: fix save/set .complete_request in start Stefan Hajnoczi
2014-07-15 13:55 ` [Qemu-devel] [PULL for-2.1 3/3] virtio-blk: dataplane: notify guest as a batch Stefan Hajnoczi
2014-07-15 14:50 ` [Qemu-devel] [PULL for-2.1 0/3] Block patches Peter Maydell

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