From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] buffer alignment for block backends
Date: Thu, 09 Apr 2009 11:07:28 +0100 [thread overview]
Message-ID: <49DDC8E0.50900@eu.citrix.com> (raw)
In-Reply-To: <49DCF2C0.9070704@codemonkey.ws>
Anthony Liguori wrote:
>> If you do not want to do that, another possible solution is to create a
>> new function called "qemu_blockalign" that would be implemented as
>> qemu_memalign(512, size);
>
> This is fine, but this is purely an optimization, it cannot be relied
> upon in the general case.
>
If you are OK with this, a simple patch like the following is
acceptable, or do you prefer a more formal approach involving a new
function in the BlockDriver interface?
---
diff --git a/block.c b/block.c
index 74d19ad..1fdcfef 100644
--- a/block.c
+++ b/block.c
@@ -1376,7 +1376,7 @@ static BlockDriverAIOCB *bdrv_aio_rw_vector(BlockDriverState *bs,
acb = qemu_aio_get(bs, cb, opaque);
acb->is_write = is_write;
acb->qiov = qiov;
- acb->bounce = qemu_memalign(512, qiov->size);
+ acb->bounce = qemu_blockalign(qiov->size);
if (!acb->bh)
acb->bh = qemu_bh_new(bdrv_aio_bh_cb, acb);
@@ -1626,3 +1626,9 @@ BlockDriverAIOCB *bdrv_aio_ioctl(BlockDriverState *bs,
return drv->bdrv_aio_ioctl(bs, req, buf, cb, opaque);
return NULL;
}
+
+void *qemu_blockalign(size_t size)
+{
+ return qemu_memalign(512, size);
+}
+
diff --git a/block.h b/block.h
index ca672a1..dba9f9d 100644
--- a/block.h
+++ b/block.h
@@ -176,4 +176,6 @@ int bdrv_put_buffer(BlockDriverState *bs, const uint8_t *buf,
int bdrv_get_buffer(BlockDriverState *bs, uint8_t *buf, int64_t pos, int size);
+void *qemu_blockalign(size_t size);
+
#endif
diff --git a/hw/ide.c b/hw/ide.c
index f187546..93b90b8 100644
--- a/hw/ide.c
+++ b/hw/ide.c
@@ -2788,7 +2788,7 @@ static void ide_init2(IDEState *ide_state,
for(i = 0; i < 2; i++) {
s = ide_state + i;
- s->io_buffer = qemu_memalign(512, IDE_DMA_BUF_SECTORS*512 + 4);
+ s->io_buffer = qemu_blockalign(IDE_DMA_BUF_SECTORS*512 + 4);
if (i == 0)
s->bs = hd0;
else
next prev parent reply other threads:[~2009-04-09 10:07 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-08 13:35 [Qemu-devel] buffer alignment for block backends Stefano Stabellini
2009-04-08 18:53 ` Anthony Liguori
2009-04-09 9:57 ` Stefano Stabellini
2009-04-09 13:11 ` Anthony Liguori
2009-04-09 13:30 ` Stefano Stabellini
2009-04-09 13:54 ` Gerd Hoffmann
2009-04-09 15:21 ` Samuel Thibault
2009-04-09 15:46 ` Stefano Stabellini
2009-04-09 15:50 ` Gerd Hoffmann
2009-04-09 16:11 ` Stefano Stabellini
2009-04-09 16:13 ` Samuel Thibault
2009-04-09 16:28 ` Anthony Liguori
2009-04-09 15:55 ` Jamie Lokier
2009-04-09 16:15 ` Samuel Thibault
2009-04-09 17:29 ` Lennart Sorensen
2009-04-09 13:33 ` Stefano Stabellini
2009-04-09 15:19 ` Samuel Thibault
2009-04-09 15:38 ` Paul Brook
2009-04-09 15:40 ` Samuel Thibault
2009-04-09 15:56 ` Anthony Liguori
2009-04-09 16:19 ` Samuel Thibault
2009-04-09 10:07 ` Stefano Stabellini [this message]
2009-04-09 13:14 ` Anthony Liguori
2009-04-09 13:30 ` Stefano Stabellini
2009-04-09 13:19 ` Christoph Hellwig
2009-04-09 13:30 ` Stefano Stabellini
2009-04-09 15:31 ` Christoph Hellwig
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=49DDC8E0.50900@eu.citrix.com \
--to=stefano.stabellini@eu.citrix.com \
--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).