All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	qemu-devel@nongnu.org, sgarzare@redhat.com, kwolf@redhat.com,
	Emanuele Giuseppe Esposito <eesposit@redhat.com>,
	Fam Zheng <fam@euphon.net>, Qing Wang <qinwang@redhat.com>
Subject: Re: [PATCH] virtio-scsi: fix race in virtio_scsi_dataplane_start()
Date: Mon, 8 Aug 2022 12:01:12 -0400	[thread overview]
Message-ID: <YvEzSAtrKSDvoUqX@fedora> (raw)
In-Reply-To: <837dc213-70cf-f677-2f22-fa731031ee77@redhat.com>

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

On Fri, Aug 05, 2022 at 11:41:27AM +0200, Paolo Bonzini wrote:
> On 8/5/22 09:04, Michael S. Tsirkin wrote:
> > > 
> > > Buglink:https://bugzilla.redhat.com/show_bug.cgi?id=2099541
> > > Reported-by: Qing Wang<qinwang@redhat.com>
> > > Signed-off-by: Stefan Hajnoczi<stefanha@redhat.com>
> > A scsi thing that tree seems more appropriate.
> > 
> > Reviewed-by: Michael S. Tsirkin<mst@redhat.com>
> > 
> > 
> > 
> 
> Since the same thing has to be done in virtio-blk, any of the
> block/misc/virtio tree will do.

I don't think virtio-blk changes are required because it's already safe.

On the store side:

  s->starting = false;
  vblk->dataplane_started = true;
  trace_virtio_blk_data_plane_start(s);

  ...

  /* Get this show started by hooking up our callbacks */
  aio_context_acquire(s->ctx);
  ^^^ implicit memory barrier ^^^
  for (i = 0; i < nvqs; i++) {
      VirtQueue *vq = virtio_get_queue(s->vdev, i);

      virtio_queue_aio_attach_host_notifier(vq, s->ctx);
  }
  aio_context_release(s->ctx);

On the load side:

  void aio_notify_accept(AioContext *ctx)
  {
      qatomic_set(&ctx->notified, false);

      /*
       * Write ctx->notified before reading e.g. bh->flags.  Pairs with smp_wmb
       * in aio_notify.
       */
      smp_mb();
      ^^^^^^^^^
  }

vblk->dataplane_started will be visible to the IOThread.

Stefan

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

  reply	other threads:[~2022-08-08 16:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-03 16:28 [PATCH] virtio-scsi: fix race in virtio_scsi_dataplane_start() Stefan Hajnoczi
2022-08-04  7:48 ` Stefano Garzarella
2022-08-04 18:56 ` [PATCH 7.1] " Stefan Hajnoczi
2022-08-05  7:03   ` Michael S. Tsirkin
2022-08-05  7:04 ` [PATCH] " Michael S. Tsirkin
2022-08-05  9:41   ` Paolo Bonzini
2022-08-08 16:01     ` Stefan Hajnoczi [this message]
2022-08-05  8:31 ` Emanuele Giuseppe Esposito
2022-08-05  9:40 ` Paolo Bonzini
2022-08-05 10:49   ` 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=YvEzSAtrKSDvoUqX@fedora \
    --to=stefanha@redhat.com \
    --cc=eesposit@redhat.com \
    --cc=fam@euphon.net \
    --cc=kwolf@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qinwang@redhat.com \
    --cc=sgarzare@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.