diff mbox

[dpdk-dev,v2,4/6] vhost: add desc prefetch

Message ID 1471501991-37257-5-git-send-email-zhihong.wang@intel.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Zhihong Wang Aug. 18, 2016, 6:33 a.m. UTC
This patch adds descriptor prefetch to hide cache access latency.

Signed-off-by: Zhihong Wang <zhihong.wang@intel.com>
---
 lib/librte_vhost/vhost_rxtx.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox

Patch

diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
index 939957d..7db83d0 100644
--- a/lib/librte_vhost/vhost_rxtx.c
+++ b/lib/librte_vhost/vhost_rxtx.c
@@ -131,6 +131,11 @@  loop_check(struct vhost_virtqueue *vq, uint16_t avail_idx, uint32_t pkt_left)
 	if (pkt_left == 0 || avail_idx == vq->last_used_idx)
 		return 1;
 
+	/* prefetch the next desc */
+	if (pkt_left > 1 && avail_idx != vq->last_used_idx + 1)
+		rte_prefetch0(&vq->desc[vq->avail->ring[
+				(vq->last_used_idx + 1) & (vq->size - 1)]]);
+
 	return 0;
 }