Skip to content

Commit

Permalink
virtio: remove unnecessary thread fence while reading next descriptor
Browse files Browse the repository at this point in the history
It was supposed to be a compiler barrier and it was a compiler barrier
initially called 'wmb' when virtio core support was introduced.
Later all the instances of 'wmb' were switched to smp_wmb to fix memory
ordering issues on non-x86 platforms.  However, this one doesn't need
to be an actual barrier, as its only purpose was to ensure that the
value is not read twice.

And since commit aa570d6 ("virtio: combine the read of a descriptor")
there is no need for a barrier at all, since we're no longer reading
guest memory here, but accessing a local structure.

Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Message-Id: <20230927140016.2317404-2-i.maximets@ovn.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
igsilya authored and mstsirkin committed Oct 4, 2023
1 parent 6bc83c6 commit 517ad87
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions hw/virtio/virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1060,8 +1060,6 @@ static int virtqueue_split_read_next_desc(VirtIODevice *vdev, VRingDesc *desc,

/* Check they're not leading us off end of descriptors. */
*next = desc->next;
/* Make sure compiler knows to grab that: we don't want it changing! */
smp_wmb();

if (*next >= max) {
virtio_error(vdev, "Desc next is %u", *next);
Expand Down

0 comments on commit 517ad87

Please sign in to comment.