qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-devel@nongnu.org, "Michal Privoznik" <mprivozn@redhat.com>,
	"Hanna Reitz" <hreitz@redhat.com>,
	qemu-block@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Michael Roth" <michael.roth@amd.com>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Eric Blake" <eblake@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [PATCH v4 4/4] virtio-blk: add iothread-vq-mapping parameter
Date: Fri, 19 Jan 2024 08:41:22 -0500	[thread overview]
Message-ID: <20240119134122.GA65300@fedora> (raw)
In-Reply-To: <ZYRAQ3izSH-QWuGp@redhat.com>

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

On Thu, Dec 21, 2023 at 02:40:19PM +0100, Kevin Wolf wrote:
> Am 20.12.2023 um 14:47 hat Stefan Hajnoczi geschrieben:
> > Add the iothread-vq-mapping parameter to assign virtqueues to IOThreads.
> > Store the vq:AioContext mapping in the new struct
> > VirtIOBlockDataPlane->vq_aio_context[] field and refactor the code to
> > use the per-vq AioContext instead of the BlockDriverState's AioContext.
> > 
> > Reimplement --device virtio-blk-pci,iothread= and non-IOThread mode by
> > assigning all virtqueues to the IOThread and main loop's AioContext in
> > vq_aio_context[], respectively.
> > 
> > The comment in struct VirtIOBlockDataPlane about EventNotifiers is
> > stale. Remove it.
> > 
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> 
> > @@ -177,19 +238,13 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)
> >  
> >      trace_virtio_blk_data_plane_start(s);
> >  
> > -    r = blk_set_aio_context(s->conf->conf.blk, s->ctx, &local_err);
> > +    r = blk_set_aio_context(s->conf->conf.blk, s->vq_aio_context[0],
> > +                            &local_err);
> >      if (r < 0) {
> >          error_report_err(local_err);
> >          goto fail_aio_context;
> >      }
> 
> This doesn't really have to be an error any more, we'll just submit I/O
> from any thread we want no matter what the home AioContext of the
> BlockBackend is.
> 
> So the only effect the blk_set_aio_context() has is that other users of
> the image try to submit their requests from the same iothread as the
> first virtqueue in the hope that this performs a bit better (maybe less
> lock contention or whatever the idea was?)

Yes, I'll change this.

> > -    /* Kick right away to begin processing requests already in vring */
> > -    for (i = 0; i < nvqs; i++) {
> > -        VirtQueue *vq = virtio_get_queue(s->vdev, i);
> > -
> > -        event_notifier_set(virtio_queue_get_host_notifier(vq));
> > -    }
> > -
> >      /*
> >       * These fields must be visible to the IOThread when it processes the
> >       * virtqueue, otherwise it will think dataplane has not started yet.
> > @@ -206,8 +261,12 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)
> >      if (!blk_in_drain(s->conf->conf.blk)) {
> >          for (i = 0; i < nvqs; i++) {
> >              VirtQueue *vq = virtio_get_queue(s->vdev, i);
> > +            AioContext *ctx = s->vq_aio_context[i];
> >  
> > -            virtio_queue_aio_attach_host_notifier(vq, s->ctx);
> > +            /* Kick right away to begin processing requests already in vring */
> > +            event_notifier_set(virtio_queue_get_host_notifier(vq));
> 
> The old code did this also for blk_in_drain() == true. Why don't we need
> it there any more? Should the 'if' move inside the loop just around
> attaching the notifier?

The answer is I'm not 100% sure. Your suggestion is safer, I'll do that.

Stefan

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

  reply	other threads:[~2024-01-19 13:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-20 13:47 [PATCH v4 0/4] virtio-blk: add iothread-vq-mapping parameter Stefan Hajnoczi
2023-12-20 13:47 ` [PATCH v4 1/4] qdev-properties: alias all object class properties Stefan Hajnoczi
2023-12-21 12:39   ` Kevin Wolf
2023-12-21 15:47     ` Stefan Hajnoczi
2023-12-20 13:47 ` [PATCH v4 2/4] string-output-visitor: show structs as "<omitted>" Stefan Hajnoczi
2023-12-20 13:47 ` [PATCH v4 3/4] qdev: add IOThreadVirtQueueMappingList property type Stefan Hajnoczi
2023-12-20 13:47 ` [PATCH v4 4/4] virtio-blk: add iothread-vq-mapping parameter Stefan Hajnoczi
2023-12-21 13:10   ` Kevin Wolf
2024-01-18 21:28     ` Stefan Hajnoczi
2023-12-21 13:40   ` Kevin Wolf
2024-01-19 13:41     ` Stefan Hajnoczi [this message]
2023-12-21 21:07 ` [PATCH v4 0/4] " 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=20240119134122.GA65300@fedora \
    --to=stefanha@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=eblake@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=mprivozn@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.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).