OSDN Git Service

vdpa: Avoid compiler to squash reads to used idx
authorEugenio Pérez <eperezma@redhat.com>
Wed, 20 Jul 2022 06:59:29 +0000 (08:59 +0200)
committerJason Wang <jasowang@redhat.com>
Wed, 20 Jul 2022 08:58:08 +0000 (16:58 +0800)
commitc381abc37f0aba42ed2e3b41cdace8f8438829e4
tree7a73dc1b35f5601acfd5ea1c4b6928dc54226182
parent640b8a1c588b56349b3307d88459ea1cd86181fb
vdpa: Avoid compiler to squash reads to used idx

In the next patch we will allow busypolling of this value. The compiler
have a running path where shadow_used_idx, last_used_idx, and vring used
idx are not modified within the same thread busypolling.

This was not an issue before since we always cleared device event
notifier before checking it, and that could act as memory barrier.
However, the busypoll needs something similar to kernel READ_ONCE.

Let's add it here, sepparated from the polling.

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
hw/virtio/vhost-shadow-virtqueue.c