qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: "Fam Zheng" <fam@euphon.net>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Thomas Huth" <thuth@redhat.com>,
	"Vladimir Sementsov-Ogievskiy" <v.sementsov-og@mail.ru>,
	qemu-block@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Eric Blake" <eblake@redhat.com>,
	qemu-devel@nongnu.org, "Alberto Faria" <afaria@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Yanan Wang" <wangyanan55@huawei.com>,
	"Hanna Reitz" <hreitz@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"John Snow" <jsnow@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	sgarzare@redhat.com
Subject: Re: [RFC v2 1/8] blkio: add io_uring block driver using libblkio
Date: Thu, 7 Apr 2022 10:34:07 +0200	[thread overview]
Message-ID: <Yk6h/0vXTcTByXO+@redhat.com> (raw)
In-Reply-To: <Yk6f8K0yOVp0QoPu@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 3629 bytes --]

Am 07.04.2022 um 10:25 hat Kevin Wolf geschrieben:
> Am 07.04.2022 um 09:22 hat Stefan Hajnoczi geschrieben:
> > On Wed, Apr 06, 2022 at 07:32:04PM +0200, Kevin Wolf wrote:
> > > Am 05.04.2022 um 17:33 hat Stefan Hajnoczi geschrieben:
> > > > libblkio (https://gitlab.com/libblkio/libblkio/) is a library for
> > > > high-performance disk I/O. It currently supports io_uring with
> > > > additional drivers planned.
> > > > 
> > > > One of the reasons for developing libblkio is that other applications
> > > > besides QEMU can use it. This will be particularly useful for
> > > > vhost-user-blk which applications may wish to use for connecting to
> > > > qemu-storage-daemon.
> > > > 
> > > > libblkio also gives us an opportunity to develop in Rust behind a C API
> > > > that is easy to consume from QEMU.
> > > > 
> > > > This commit adds an io_uring BlockDriver to QEMU using libblkio. For now
> > > > I/O buffers are copied through bounce buffers if the libblkio driver
> > > > requires it. Later commits add an optimization for pre-registering guest
> > > > RAM to avoid bounce buffers. It will be easy to add other libblkio
> > > > drivers since they will share the majority of code.
> > > > 
> > > > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > > 
> > > > +static BlockDriver bdrv_io_uring = {
> > > > +    .format_name                = "io_uring",
> > > > +    .protocol_name              = "io_uring",
> > > > +    .instance_size              = sizeof(BDRVBlkioState),
> > > > +    .bdrv_needs_filename        = true,
> > > > +    .bdrv_parse_filename        = blkio_parse_filename_io_uring,
> > > > +    .bdrv_file_open             = blkio_file_open,
> > > > +    .bdrv_close                 = blkio_close,
> > > > +    .bdrv_getlength             = blkio_getlength,
> > > > +    .has_variable_length        = true,
> > > 
> > > This one is a bad idea. It means that every request will call
> > > blkio_getlength() first, which looks up the "capacity" property in
> > > libblkio and then calls lseek() for the io_uring backend.
> > 
> > Thanks for pointing this out. I didn't think this through. More below on
> > what I was trying to do.
> > 
> > > For other backends like the vhost_user one (where I just copied your
> > > definition and then noticed this behaviour), it involve a message over
> > > the vhost socket, which is even worse.
> > 
> > (A vhost-user-blk driver could cache the capacity field and update it
> > when a Configuration Change Notification is received. There is no need
> > to send a vhost-user protocol message every time.)
> 
> In theory we could cache in libblkio, but then we would need a mechanism
> to invalidate the cache so we can support resizing an image (similar to
> what block_resize does in QEMU, except that it wouldn't set the new
> size from a parameter, but just get the new value from the backend).

Oh, sorry, I misread. VHOST_USER_SLAVE_CONFIG_CHANGE_MSG is probably
what you mean, so that the backend triggers the update. It exists in the
spec, but neither libvhost-user nor rust-vmm seem to support it
currently. We also don't set up the backchannel yet where this message
could even be passed.

So it's an option, but probably only for later because it involves
extending several places.

> I think it's simpler to leave caching to the application - and QEMU
> already does this automatically if we don't set .has_variable_length =
> true.

I still think the application shouldn't query the capacity more often
than necessary, so optimising it is probably not very important.

Kevin

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-04-07  8:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-05 15:33 [RFC v2 0/8] blkio: add libblkio BlockDriver Stefan Hajnoczi
2022-04-05 15:33 ` [RFC v2 1/8] blkio: add io_uring block driver using libblkio Stefan Hajnoczi
2022-04-06 17:32   ` Kevin Wolf
2022-04-07  7:22     ` Stefan Hajnoczi
2022-04-07  8:25       ` Kevin Wolf
2022-04-07  8:34         ` Kevin Wolf [this message]
2022-04-12  8:43           ` Stefan Hajnoczi
2022-04-05 15:33 ` [RFC v2 2/8] numa: call ->ram_block_removed() in ram_block_notifer_remove() Stefan Hajnoczi
2022-04-05 15:33 ` [RFC v2 3/8] block: pass size to bdrv_unregister_buf() Stefan Hajnoczi
2022-04-05 15:33 ` [RFC v2 4/8] block: add BDRV_REQ_REGISTERED_BUF request flag Stefan Hajnoczi
2022-04-05 15:33 ` [RFC v2 5/8] block: add BlockRAMRegistrar Stefan Hajnoczi
2022-04-05 15:33 ` [RFC v2 6/8] stubs: add memory_region_from_host() and memory_region_get_fd() Stefan Hajnoczi
2022-04-05 15:33 ` [RFC v2 7/8] blkio: implement BDRV_REQ_REGISTERED_BUF optimization Stefan Hajnoczi
2022-04-05 15:33 ` [RFC v2 8/8] virtio-blk: use BDRV_REQ_REGISTERED_BUF optimization hint Stefan Hajnoczi

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=Yk6h/0vXTcTByXO+@redhat.com \
    --to=kwolf@redhat.com \
    --cc=afaria@redhat.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=f4bug@amsat.org \
    --cc=fam@euphon.net \
    --cc=hreitz@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    --cc=v.sementsov-og@mail.ru \
    --cc=wangyanan55@huawei.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).