From: Ming Lei <ming.lei@canonical.com>
To: Peter Maydell <peter.maydell@linaro.org>,
qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>, Ming Lei <ming.lei@canonical.com>,
Fam Zheng <famz@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: [Qemu-devel] [PATCH 2/2] virtio-blk: dataplane: notify guest as a batch
Date: Fri, 4 Jul 2014 20:27:34 +0800 [thread overview]
Message-ID: <1404476854-23773-3-git-send-email-ming.lei@canonical.com> (raw)
In-Reply-To: <1404476854-23773-1-git-send-email-ming.lei@canonical.com>
Now requests are submitted as a batch, so it is natural
to notify guest as a batch too.
This may supress interrupt notification to VM:
- in my test, decreased by ~13K/sec
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
hw/block/dataplane/virtio-blk.c | 13 ++++++++++++-
hw/block/virtio-blk.c | 1 +
include/hw/virtio/virtio-blk.h | 1 +
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index e88862d..9d36659 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -45,6 +45,8 @@ struct VirtIOBlockDataPlane {
AioContext *ctx;
EventNotifier host_notifier; /* doorbell */
+ VirtIOBlockReq *last_submit;
+
/* Operation blocker on BDS */
Error *blocker;
void (*saved_complete_request)(struct VirtIOBlockReq *req,
@@ -67,7 +69,10 @@ 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);
+
+ if (req->last) {
+ notify_guest(req->dev->dataplane);
+ }
}
static void handle_notify(EventNotifier *e)
@@ -101,6 +106,8 @@ static void handle_notify(EventNotifier *e)
req->elem.index);
virtio_blk_handle_request(req, &mrb);
+
+ s->last_submit = req;
}
virtio_submit_multiwrite(s->blk->conf.bs, &mrb);
@@ -116,6 +123,10 @@ static void handle_notify(EventNotifier *e)
break;
}
}
+
+ if (s->last_submit) {
+ s->last_submit->last = true;
+ }
bdrv_io_unplug(s->blk->conf.bs);
}
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 02cd6b0..86b37f7 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -35,6 +35,7 @@ VirtIOBlockReq *virtio_blk_alloc_request(VirtIOBlock *s)
req->dev = s;
req->qiov.size = 0;
req->next = NULL;
+ req->last = false;
return req;
}
diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h
index 992da26..07659c3 100644
--- a/include/hw/virtio/virtio-blk.h
+++ b/include/hw/virtio/virtio-blk.h
@@ -150,6 +150,7 @@ typedef struct VirtIOBlockReq {
QEMUIOVector qiov;
struct VirtIOBlockReq *next;
BlockAcctCookie acct;
+ bool last;
} VirtIOBlockReq;
#define DEFINE_VIRTIO_BLK_FEATURES(_state, _field) \
--
1.7.9.5
next prev parent reply other threads:[~2014-07-04 12:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-04 12:27 [Qemu-devel] [PATCH 0/2] virtio-blk: dataplane: one fix plus one optimization Ming Lei
2014-07-04 12:27 ` [Qemu-devel] [PATCH 1/2] virtio-blk: data-plane: fix save/set .complete_request in start Ming Lei
2014-07-04 12:27 ` Ming Lei [this message]
2014-07-04 12:55 ` [Qemu-devel] [PATCH 2/2] virtio-blk: dataplane: notify guest as a batch Paolo Bonzini
2014-07-04 14:52 ` Ming Lei
2014-07-04 15:48 ` Paolo Bonzini
2014-07-04 15:57 ` Ming Lei
2014-07-04 16:09 ` Paolo Bonzini
2014-07-05 4:21 ` Ming Lei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1404476854-23773-3-git-send-email-ming.lei@canonical.com \
--to=ming.lei@canonical.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).