DPDK patches and discussions
 help / color / mirror / Atom feed
From: Nikita Kalyazin <n.kalyazin@samsung.com>
To: dev@dpdk.org
Cc: Dyasly Sergey <s.dyasly@samsung.com>
Subject: [dpdk-dev] [PATCH] vhost: call write barrier before used index update
Date: Tue, 20 Oct 2015 17:07:46 +0300	[thread overview]
Message-ID: <1445350066-31818-1-git-send-email-n.kalyazin@samsung.com> (raw)

Descriptors that have been put into the used vring must be observable by
guest earlier than the new used index value.
Although compiler barrier serves well for Intel architectue here, the
proper cross-platform solution is to use write barrier before the used
index is updated.

Signed-off-by: Nikita Kalyazin <n.kalyazin@samsung.com>
---
 lib/librte_vhost/vhost_rxtx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
index 7026bfa..d955287 100644
--- a/lib/librte_vhost/vhost_rxtx.c
+++ b/lib/librte_vhost/vhost_rxtx.c
@@ -216,7 +216,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,
 		}
 	}
 
-	rte_compiler_barrier();
+	rte_wmb();
 
 	/* Wait until it's our turn to add our buffer to the used ring. */
 	while (unlikely(vq->last_used_idx != res_base_idx))
@@ -512,7 +512,7 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t queue_id,
 		entry_success = copy_from_mbuf_to_vring(dev, res_base_idx,
 			res_cur_idx, pkts[pkt_idx]);
 
-		rte_compiler_barrier();
+		rte_wmb();
 
 		/*
 		 * Wait until it's our turn to add our buffer
@@ -751,7 +751,7 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,
 		entry_success++;
 	}
 
-	rte_compiler_barrier();
+	rte_wmb();
 	vq->used->idx += entry_success;
 	/* Kick guest if required. */
 	if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT))
-- 
2.5.3

             reply	other threads:[~2015-10-20 14:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-20 14:07 Nikita Kalyazin [this message]
2015-10-20 14:29 ` Bruce Richardson
2015-10-21 15:42   ` Nikita Kalyazin
2015-10-21 15:47     ` Bruce Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1445350066-31818-1-git-send-email-n.kalyazin@samsung.com \
    --to=n.kalyazin@samsung.com \
    --cc=dev@dpdk.org \
    --cc=s.dyasly@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).