examples/vhost_blk: replace SMP barrier with thread fence
authorJoyce Kong <joyce.kong@arm.com>
Mon, 21 Dec 2020 15:50:27 +0000 (23:50 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 8 Jan 2021 17:07:55 +0000 (18:07 +0100)
Simply replace the rte_smp_mb barriers with SEQ_CST atomic thread fence,
if there is no load/store operations.

Signed-off-by: Joyce Kong <joyce.kong@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
examples/vhost_blk/vhost_blk.c

index bb293d4..7ea6086 100644 (file)
@@ -86,9 +86,9 @@ enqueue_task(struct vhost_blk_task *task)
         */
        used->ring[used->idx & (vq->vring.size - 1)].id = task->req_idx;
        used->ring[used->idx & (vq->vring.size - 1)].len = task->data_len;
-       rte_smp_mb();
+       rte_atomic_thread_fence(__ATOMIC_SEQ_CST);
        used->idx++;
-       rte_smp_mb();
+       rte_atomic_thread_fence(__ATOMIC_SEQ_CST);
 
        rte_vhost_clr_inflight_desc_split(task->ctrlr->vid,
                vq->id, used->idx, task->req_idx);
@@ -112,12 +112,12 @@ enqueue_task_packed(struct vhost_blk_task *task)
        desc->id = task->buffer_id;
        desc->addr = 0;
 
-       rte_smp_mb();
+       rte_atomic_thread_fence(__ATOMIC_SEQ_CST);
        if (vq->used_wrap_counter)
                desc->flags |= VIRTQ_DESC_F_AVAIL | VIRTQ_DESC_F_USED;
        else
                desc->flags &= ~(VIRTQ_DESC_F_AVAIL | VIRTQ_DESC_F_USED);
-       rte_smp_mb();
+       rte_atomic_thread_fence(__ATOMIC_SEQ_CST);
 
        rte_vhost_clr_inflight_desc_packed(task->ctrlr->vid, vq->id,
                                           task->inflight_idx);