qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Saul Tamari <stamari@gmail.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: [Qemu-devel] Re: [PATCH] qemu-kvm: clear only essential parts of VirtIOBlockReq on object allocation - RESUBMIT
Date: Wed, 18 Nov 2009 16:41:22 +0200	[thread overview]
Message-ID: <20091118144122.GC19099@localhost.localdomain> (raw)
In-Reply-To: <4B02FBE4.2060409@codemonkey.ws>

[-- Attachment #1: patch0.patch --]
[-- Type: text/plain, Size: 1797 bytes --]

ok,
Below is the patch. This time resent with mutt and hopefully without whitespace changes.
--------------------------------------------------------------------

This patch reduces the amount of memory being cleared on every virtio-blk IO operation.

Improve number of IOPS when using avirtio-blk device.

On every virtio-blk IO command passed to QEMU, virtio_blk_alloc_request()
allocates and clears (with qemu_mallocz()) a VirtIOBlockReq object.
The sizeof(VirtIOBlockReq) equals 41040 bytes on my x86-64 machine.
By moving the 'elem' variable to the end of VirtIOBlockReq and
clearing only upto the address of the 'elem.in_addr' field, the
memset() call now clears only 80 bytes.


Signed-off-by: Saul Tamari <stamari@gmail.com>
-------------------------------------------------
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 2630b99..de74b00 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -79,12 +79,13 @@ static inline void virtio_identify_template(struct virtio_blk_config *bc)
 typedef struct VirtIOBlockReq
 {
     VirtIOBlock *dev;
-    VirtQueueElement elem;
     struct virtio_blk_inhdr *in;
     struct virtio_blk_outhdr *out;
     struct virtio_scsi_inhdr *scsi;
     QEMUIOVector qiov;
     struct VirtIOBlockReq *next;
+    /* Members that need clearing, must be added prior to elem */
+    VirtQueueElement elem;
 } VirtIOBlockReq;
 
 static void virtio_blk_req_complete(VirtIOBlockReq *req, int status)
@@ -139,7 +140,8 @@ static void virtio_blk_flush_complete(void *opaque, int ret)
 
 static VirtIOBlockReq *virtio_blk_alloc_request(VirtIOBlock *s)
 {
-    VirtIOBlockReq *req = qemu_mallocz(sizeof(*req));
+    VirtIOBlockReq *req = qemu_malloc(sizeof(*req));
+    memset(req, 0, offsetof(VirtIOBlockReq, elem.in_addr[0]));
     req->dev = s;
     return req;
 }

      reply	other threads:[~2009-11-18 14:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-09 18:04 [Qemu-devel] [PATCH] qemu-kvm: clear only essential parts of VirtIOBlockReq on object allocation - RESUBMIT Saul Tamari
2009-11-17 19:39 ` [Qemu-devel] " Anthony Liguori
2009-11-18 14:41   ` Saul Tamari [this message]

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=20091118144122.GC19099@localhost.localdomain \
    --to=stamari@gmail.com \
    --cc=anthony@codemonkey.ws \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    /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).