vhost: relax full barriers for used idx
authorJoyce Kong <joyce.kong@arm.com>
Mon, 21 Dec 2020 15:50:31 +0000 (23:50 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 8 Jan 2021 17:07:55 +0000 (18:07 +0100)
Used idx can be synchronized by one-way barrier instead of full
write barrier for split vring.

Signed-off-by: Joyce Kong <joyce.kong@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
lib/librte_vhost/vdpa.c

index ae6fdd2..99a926a 100644 (file)
@@ -217,8 +217,8 @@ rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m)
                idx++;
        }
 
-       rte_smp_wmb();
-       vq->used->idx = idx_m;
+       /* used idx is the synchronization point for the split vring */
+       __atomic_store_n(&vq->used->idx, idx_m, __ATOMIC_RELEASE);
 
        if (dev->features & (1ULL << VIRTIO_RING_F_EVENT_IDX))
                vring_used_event(s_vring) = idx_m;