From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 763F158FE for ; Fri, 5 May 2017 15:57:29 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C39E23D944; Fri, 5 May 2017 13:57:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C39E23D944 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jfreiman@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C39E23D944 Received: from virtlab417.ml3.eng.bos.redhat.com (virtlab417.ml3.eng.bos.redhat.com [10.19.176.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D882785E5; Fri, 5 May 2017 13:57:28 +0000 (UTC) From: Jens Freimann To: yuanhan.liu@linux.intel.com Cc: dev@dpdk.org Date: Fri, 5 May 2017 09:57:21 -0400 Message-Id: <1493992642-52756-11-git-send-email-jfreiman@redhat.com> In-Reply-To: <1493992642-52756-1-git-send-email-jfreiman@redhat.com> References: <1493992642-52756-1-git-send-email-jfreiman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 05 May 2017 13:57:28 +0000 (UTC) Subject: [dpdk-dev] [RFC PATCH 10/11] vhost: prefetch desc X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 May 2017 13:57:30 -0000 From: Yuanhan Liu Signed-off-by: Yuanhan Liu --- lib/librte_vhost/virtio_net.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index c9e466f..b4d9031 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -974,10 +974,10 @@ static inline bool __attribute__((always_inline)) return true; } -static inline uint16_t +static inline uint16_t __attribute__((always_inline)) dequeue_desc(struct virtio_net *dev, struct vhost_virtqueue *vq, struct rte_mempool *mbuf_pool, struct rte_mbuf *m, - struct vring_desc_1_1 *descs) + struct vring_desc_1_1 *descs, uint16_t *desc_idx) { struct vring_desc_1_1 *desc; uint64_t desc_addr; @@ -986,7 +986,7 @@ static inline bool __attribute__((always_inline)) uint32_t cpy_len; struct rte_mbuf *cur = m, *prev = m; struct virtio_net_hdr *hdr = NULL; - uint16_t head_idx = vq->last_used_idx; + uint16_t head_idx = *desc_idx; desc = &descs[(head_idx++) & (vq->size - 1)]; if (unlikely((desc->len < dev->vhost_hlen)) || @@ -1114,7 +1114,7 @@ static inline bool __attribute__((always_inline)) if (hdr) vhost_dequeue_offload(hdr, m); - vq->last_used_idx = head_idx; + *desc_idx = head_idx; return 0; } @@ -1128,11 +1128,32 @@ static inline bool __attribute__((always_inline)) uint16_t idx; struct vring_desc_1_1 *desc = vq->desc_1_1; uint16_t head_idx = vq->last_used_idx; + struct vring_desc_1_1 desc_cached[64]; + uint16_t desc_idx = 0; + + idx = vq->last_used_idx & (vq->size - 1); + if (!(desc[idx].flags & DESC_HW)) + return 0; count = RTE_MIN(MAX_PKT_BURST, count); + + { + uint16_t size = vq->size - idx; + if (size >= 64) + rte_memcpy(&desc_cached[0], &desc[idx], 64 * sizeof(struct vring_desc_1_1)); + else { + rte_memcpy(&desc_cached[0], &desc[idx], size * sizeof(struct vring_desc_1_1)); + rte_memcpy(&desc_cached[size], &desc[0], (64 - size) * sizeof(struct vring_desc_1_1)); + } + } + + //for (i = 0; i < 64; i++) { + // idx = (vq->last_used_idx + i) & (vq->size - 1); + // desc_cached[i] = desc[idx]; + //} + for (i = 0; i < count; i++) { - idx = vq->last_used_idx & (vq->size - 1); - if (!(desc[idx].flags & DESC_HW)) + if (!(desc_cached[desc_idx].flags & DESC_HW)) break; pkts[i] = rte_pktmbuf_alloc(mbuf_pool); @@ -1142,9 +1163,10 @@ static inline bool __attribute__((always_inline)) break; } - dequeue_desc(dev, vq, mbuf_pool, pkts[i], desc); + dequeue_desc(dev, vq, mbuf_pool, pkts[i], desc_cached, &desc_idx); } + vq->last_used_idx += desc_idx; if (likely(i)) { for (idx = 1; idx < (uint16_t)(vq->last_used_idx - head_idx); idx++) { desc[(idx + head_idx) & (vq->size - 1)].flags = 0; -- 1.8.3.1