[v1,6/8] vhost: relax full barriers for used idx

Message ID 20201221155033.6771-7-joyce.kong@arm.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series replace smp barriers in vhost with C11 atomic |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Joyce Kong Dec. 21, 2020, 3:50 p.m. UTC
  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>
---
 lib/librte_vhost/vdpa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Maxime Coquelin Jan. 7, 2021, 4:46 p.m. UTC | #1
On 12/21/20 4:50 PM, Joyce Kong wrote:
> 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>
> ---
>  lib/librte_vhost/vdpa.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  

Patch

diff --git a/lib/librte_vhost/vdpa.c b/lib/librte_vhost/vdpa.c
index ae6fdd24e..99a926a77 100644
--- a/lib/librte_vhost/vdpa.c
+++ b/lib/librte_vhost/vdpa.c
@@ -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;