qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] buffer alignment for block backends
Date: Thu, 09 Apr 2009 08:11:27 -0500	[thread overview]
Message-ID: <49DDF3FF.8050706@codemonkey.ws> (raw)
In-Reply-To: <49DDC66F.2000404@eu.citrix.com>

Stefano Stabellini wrote:
> 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.
>>     
>
>
>
> well, there aren't many places that allocate buffers for the block
> backends, I can count only the following for dma operations:
>
> - block.c:bdrv_aio_rw_vector
>   

This bounces a scatter/gather list into a single linear buffer since not 
all backends handle scatter/gather lists today.

> and this one for other ide read and write operations:
>
> - ide.c:ide_init2
>   

This buffer is only used when not doing DMA.  When doing DMA, we are 
able to do zero-copy IO so the alignment of the request depends on how 
the guest aligned the request.  I suspect you'll find a lot of guests 
that, in practice, do not align requests at 4k boundaries.  I don't know 
what the requirements are for IDE but I would be surprised if it was 4k.

> I think it would be important at least for dma operations.
>   

We have a lot of places with explicit memalign's because the block raw 
backend code degrades into synchronous IO when performing non-aligned IO 
with cache=off.  I've never liked this much personally.

That's not saying that I think we shouldn't try to align DMA buffers 
when we're allocating them in QEMU.  A block level function to do this 
would be pretty nice in fact.

>>>  so we don't have to write 512 bytes everywhere
>>> but only in one place, thus making life easier to people like me that
>>> have to change the value for a special case.
>>>
>>> Thanks in advance for your sympathy :)
>>>   
>>>       
>> Why does your backend requirement page alignment and who's notion of page?
>>
>>     
>
> my backend (block-vbd) needs page aligned buffers because blkfront needs
> page aligned buffers. I could allocate a new page aligned buffer every
> time and the memcpy but it is just a waste.
>   

You'll need to check the alignment of the request and bounce it if 
necessary.  In the case that you have zero-copy requests coming from the 
guest that aren't page aligned, someone has to bounce the thing to make 
it page aligned.

So I presume you're implementing blkfront in userspace?  Does minios 
provide a userspace interface for grant tables that looks similar to the 
interfaces on Linux?  Were you planning on submitting this for inclusion 
in upstream QEMU?

I think it's a reasonable thing to include provided it's relatively 
self-contained.

Regards,

Anthony Liguori

  reply	other threads:[~2009-04-09 13:11 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 [this message]
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
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=49DDF3FF.8050706@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --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).