From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
maxime.coquelin@redhat.com, alvaro.karsz@solid-run.com,
eperezma@redhat.com
Subject: Re: [PATCH 2/4] virtio_ring: switch to use BAD_RING()
Date: Tue, 27 Dec 2022 02:21:30 -0500 [thread overview]
Message-ID: <20221227022023-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CACGkMEuv9+o4anxnE8xewEaFj5Sc+bn4OFDrHYR6jyxb+3ApGw@mail.gmail.com>
On Tue, Dec 27, 2022 at 11:51:02AM +0800, Jason Wang wrote:
> On Tue, Dec 27, 2022 at 7:36 AM Michael S. Tsirkin <mst@redhat.com> wrote:
> >
> > On Mon, Dec 26, 2022 at 03:49:06PM +0800, Jason Wang wrote:
> > > Switch to reuse BAD_RING() to allow common logic to be implemented in
> > > BAD_RING().
> > >
> > > Signed-off-by: Jason Wang <jasowang@redhat.com>
> > > ---
> > > Changes since V1:
> > > - switch to use BAD_RING in virtio_break_device()
> > > ---
> > > drivers/virtio/virtio_ring.c | 8 ++++----
> > > 1 file changed, 4 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> > > index 2e7689bb933b..5cfb2fa8abee 100644
> > > --- a/drivers/virtio/virtio_ring.c
> > > +++ b/drivers/virtio/virtio_ring.c
> > > @@ -58,7 +58,8 @@
> > > do { \
> > > dev_err(&_vq->vq.vdev->dev, \
> > > "%s:"fmt, (_vq)->vq.name, ##args); \
> > > - (_vq)->broken = true; \
> > > + /* Pairs with READ_ONCE() in virtqueue_is_broken(). */ \
> >
> > I don't think WRITE_ONCE/READ_ONCE pair as such. Can you point
> > me at documentation of such pairing?
>
> Introduced by:
>
> commit 60f0779862e4ab943810187752c462e85f5fa371
> Author: Parav Pandit <parav@nvidia.com>
> Date: Wed Jul 21 17:26:45 2021 +0300
>
> virtio: Improve vq->broken access to avoid any compiler optimization
>
> I think it might still apply here since virtqueue_is_broken() is still
> put into a loop inside wait_event().
>
> Thanks
Oh I see. Maybe it's a response to some discussion we had at the time,
at this point I can no longer say what it meant.
But you are doing right not changing it here of course.
> >
> > > + WRITE_ONCE((_vq)->broken, true); \
> > > } while (0)
> > > #define START_USE(vq)
> > > #define END_USE(vq)
> > > @@ -2237,7 +2238,7 @@ bool virtqueue_notify(struct virtqueue *_vq)
> > >
> > > /* Prod other side to tell it about changes. */
> > > if (!vq->notify(_vq)) {
> > > - vq->broken = true;
> > > + BAD_RING(vq, "vq %d is broken\n", vq->vq.index);
> > > return false;
> > > }
> > > return true;
> > > @@ -2786,8 +2787,7 @@ void virtio_break_device(struct virtio_device *dev)
> > > list_for_each_entry(_vq, &dev->vqs, list) {
> > > struct vring_virtqueue *vq = to_vvq(_vq);
> > >
> > > - /* Pairs with READ_ONCE() in virtqueue_is_broken(). */
> > > - WRITE_ONCE(vq->broken, true);
> > > + BAD_RING(vq, "Device break vq %d", _vq->index);
> > > }
> > > spin_unlock(&dev->vqs_list_lock);
> > > }
> > > --
> > > 2.25.1
> >
next prev parent reply other threads:[~2022-12-27 7:22 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-26 7:49 [PATCH 0/4] virtio-net: don't busy poll for cvq command Jason Wang
2022-12-26 7:49 ` [PATCH 1/4] virtio-net: convert rx mode setting to use workqueue Jason Wang
2022-12-27 7:39 ` Michael S. Tsirkin
2022-12-27 9:06 ` Jason Wang
2022-12-30 2:51 ` Jakub Kicinski
2022-12-30 3:40 ` Jason Wang
2022-12-26 7:49 ` [PATCH 2/4] virtio_ring: switch to use BAD_RING() Jason Wang
2022-12-26 23:36 ` Michael S. Tsirkin
2022-12-27 3:51 ` Jason Wang
2022-12-27 7:21 ` Michael S. Tsirkin [this message]
2022-12-26 7:49 ` [PATCH 3/4] virtio_ring: introduce a per virtqueue waitqueue Jason Wang
2022-12-26 23:34 ` Michael S. Tsirkin
2022-12-27 3:47 ` Jason Wang
2022-12-27 7:19 ` Michael S. Tsirkin
2022-12-27 9:09 ` Jason Wang
2022-12-26 23:38 ` Michael S. Tsirkin
2022-12-27 4:30 ` Jason Wang
2022-12-27 7:33 ` Michael S. Tsirkin
2022-12-27 9:12 ` Jason Wang
2022-12-27 9:38 ` Michael S. Tsirkin
2022-12-28 6:34 ` Jason Wang
2022-12-28 11:53 ` Jason Wang
2022-12-29 7:07 ` Michael S. Tsirkin
2022-12-29 8:04 ` Jason Wang
2022-12-29 8:10 ` Michael S. Tsirkin
2022-12-30 3:43 ` Jason Wang
2023-01-27 10:35 ` Michael S. Tsirkin
2023-01-29 5:48 ` Jason Wang
2023-01-29 7:30 ` Michael S. Tsirkin
2023-01-30 2:53 ` Jason Wang
2023-01-30 5:43 ` Michael S. Tsirkin
2023-01-30 7:44 ` Jason Wang
2023-01-30 11:18 ` Michael S. Tsirkin
2023-01-31 3:24 ` Jason Wang
2023-01-31 7:32 ` Michael S. Tsirkin
[not found] ` <20230129073713.5236-1-hdanton@sina.com>
2023-01-30 3:58 ` Jason Wang
2022-12-26 7:49 ` [PATCH 4/4] virtio-net: sleep instead of busy waiting for cvq command Jason Wang
2022-12-27 2:19 ` Xuan Zhuo
2022-12-27 4:33 ` Jason Wang
2022-12-27 6:58 ` Michael S. Tsirkin
2022-12-27 9:17 ` Jason Wang
2022-12-27 9:31 ` Michael S. Tsirkin
2022-12-28 6:35 ` Jason Wang
2022-12-28 8:31 ` Xuan Zhuo
2022-12-28 11:41 ` Jason Wang
2022-12-29 2:09 ` Xuan Zhuo
2022-12-29 3:22 ` Jason Wang
2022-12-29 3:41 ` Xuan Zhuo
2022-12-29 4:08 ` Jason Wang
2022-12-29 6:13 ` Xuan Zhuo
2022-12-28 8:39 ` Xuan Zhuo
2022-12-28 11:43 ` Jason Wang
2022-12-29 2:01 ` Xuan Zhuo
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=20221227022023-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=alvaro.karsz@solid-run.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime.coquelin@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=virtualization@lists.linux-foundation.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).