From: Peter Lieven <pl@kamp.de>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, famz@redhat.com, kwolf@redhat.com,
stefanha@redhat.com, mreitz@redhat.com, Peter Lieven <pl@kamp.de>
Subject: [Qemu-devel] [PATCH] block/io: optimize bdrv_co_pwritev for small requests
Date: Tue, 24 May 2016 15:39:11 +0200 [thread overview]
Message-ID: <1464097151-19479-1-git-send-email-pl@kamp.de> (raw)
in a read-modify-write cycle a small request might cause
head and tail to fall into the same alignment. Currently
QEMU reads the same block twice in this case which is
not necessary.
Signed-off-by: Peter Lieven <pl@kamp.de>
---
block/io.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/block/io.c b/block/io.c
index 60a6bd8..fa40121 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1430,6 +1430,18 @@ int coroutine_fn bdrv_co_pwritev(BlockDriverState *bs,
bytes += offset & (align - 1);
offset = offset & ~(align - 1);
+
+ /* if head and tail fall into the same alignment
+ * we can omit the second read as it would read
+ * the same block again */
+ if ((offset + bytes) & (align - 1) &&
+ offset / align == (offset + bytes) / align) {
+ size_t tail_offs;
+ tail_offs = (offset + bytes) & (align - 1);
+ qemu_iovec_add(&local_qiov, head_buf + tail_offs,
+ align - tail_offs);
+ bytes += align - tail_offs;
+ }
}
if ((offset + bytes) & (align - 1)) {
--
1.9.1
next reply other threads:[~2016-05-24 13:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-24 13:39 Peter Lieven [this message]
2016-05-24 13:59 ` [Qemu-devel] [PATCH] block/io: optimize bdrv_co_pwritev for small requests Paolo Bonzini
2016-05-24 14:07 ` Peter Lieven
2016-05-24 14:20 ` Paolo Bonzini
2016-05-24 14:22 ` Kevin Wolf
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=1464097151-19479-1-git-send-email-pl@kamp.de \
--to=pl@kamp.de \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.