[dpdk-dev,RFC,07/11] vhost: mark desc being used

Message ID 1493992642-52756-8-git-send-email-jfreiman@redhat.com (mailing list archive)
State Not Applicable, archived
Delegated to: Yuanhan Liu
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Jens Freimann May 5, 2017, 1:57 p.m. UTC
  From: Yuanhan Liu <yuanhan.liu@linux.intel.com>

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
 lib/librte_vhost/virtio_net.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
  

Patch

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index fd6f200..df88e31 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -1009,6 +1009,7 @@  static inline bool __attribute__((always_inline))
 	 */
 	if (likely((desc->len == dev->vhost_hlen) &&
 		   (desc->flags & VRING_DESC_F_NEXT) != 0)) {
+		rte_smp_wmb();
 		desc->flags = 0;
 
 		desc = &descs[(head_idx++) & (vq->size - 1)];
@@ -1068,11 +1069,11 @@  static inline bool __attribute__((always_inline))
 
 		/* This desc reaches to its end, get the next one */
 		if (desc_avail == 0) {
-			desc->flags = 0;
-
 			if ((desc->flags & VRING_DESC_F_NEXT) == 0)
 				break;
 
+			rte_smp_wmb();
+			desc->flags = 0;
 			desc = &descs[(head_idx++) & (vq->size - 1)];
 			if (unlikely(desc->flags & VRING_DESC_F_INDIRECT))
 				return -1;
@@ -1111,6 +1112,7 @@  static inline bool __attribute__((always_inline))
 			mbuf_avail  = cur->buf_len - RTE_PKTMBUF_HEADROOM;
 		}
 	}
+	rte_smp_wmb();
 	desc->flags = 0;
 
 	prev->data_len = mbuf_offset;