[dpdk-dev] [PATCH v3 3/5] vhost: add desc prefetch

Zhihong Wang zhihong.wang at intel.com
Fri Aug 19 07:43:48 CEST 2016


This patch adds descriptor prefetch to hide cache access latency.

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

diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
index b09a9c3..7523b2d 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;
 }
 
-- 
2.7.4



More information about the dev mailing list