From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C9CBAA0500 for ; Tue, 17 Dec 2019 19:07:05 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BFEE11BECF; Tue, 17 Dec 2019 19:07:05 +0100 (CET) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 7FA7F1BEC4 for ; Tue, 17 Dec 2019 19:07:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576606024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3fr1GfYQ9Cmjx4BwPllUPtBZM420TeiAyeb37kltHJs=; b=KxJrW921fksQEP9ji6pP1listU49EQZl/w/fg3ZTmxzTfKaS15nAexXx55yMicDmUJsBZs ee1Ag/0VgdZYEvyiUozWB5fNDiIcz2bAcKXGZx2zsfggZ63UtpVokvqrblrwflQmtKgou8 fJeBOu7nE2Wv4tC6dXKBcTmdYxQ65Lc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-102-Zp4-8j25OaSKkjTBxTqStA-1; Tue, 17 Dec 2019 13:07:02 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3472D1005502; Tue, 17 Dec 2019 18:07:01 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (ovpn-117-34.ams2.redhat.com [10.36.117.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 223F47C839; Tue, 17 Dec 2019 18:06:59 +0000 (UTC) From: Adrian Moreno To: stable@dpdk.org Cc: ktraynor@redhat.com, maxime.coquelin@redhat.com, Tiwei Bie Date: Tue, 17 Dec 2019 19:06:38 +0100 Message-Id: <20191217180640.17993-6-amorenoz@redhat.com> In-Reply-To: <20191217180640.17993-1-amorenoz@redhat.com> References: <20191217180640.17993-1-amorenoz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: Zp4-8j25OaSKkjTBxTqStA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-stable] [PATCH 18.11 5/7] vhost: simplify descriptor buffer prefetching X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" From: Maxime Coquelin [ upstream commit d1134c09e37608c949b75ebfc7ea01000b134c5c ] Now that we have a single function to map the descriptors buffers, let's prefetch them there as it is the earliest place we can do it. Signed-off-by: Maxime Coquelin Reviewed-by: Tiwei Bie --- lib/librte_vhost/virtio_net.c | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 0a0b44c8b..83046cc6b 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -293,6 +293,8 @@ map_one_desc(struct virtio_net *dev, struct vhost_virtq= ueue *vq, =09=09if (unlikely(!desc_addr)) =09=09=09return -1; =20 +=09=09rte_prefetch0((void *)(uintptr_t)desc_addr); + =09=09buf_vec[vec_id].buf_iova =3D desc_iova; =09=09buf_vec[vec_id].buf_addr =3D desc_addr; =09=09buf_vec[vec_id].buf_len =3D desc_chunck_len; @@ -673,9 +675,6 @@ copy_mbuf_to_desc(struct virtio_net *dev, struct vhost_= virtqueue *vq, =09buf_iova =3D buf_vec[vec_idx].buf_iova; =09buf_len =3D buf_vec[vec_idx].buf_len; =20 -=09if (nr_vec > 1) -=09=09rte_prefetch0((void *)(uintptr_t)buf_vec[1].buf_addr); - =09if (unlikely(buf_len < dev->vhost_hlen && nr_vec <=3D 1)) { =09=09error =3D -1; =09=09goto out; @@ -718,10 +717,6 @@ copy_mbuf_to_desc(struct virtio_net *dev, struct vhost= _virtqueue *vq, =09=09=09buf_iova =3D buf_vec[vec_idx].buf_iova; =09=09=09buf_len =3D buf_vec[vec_idx].buf_len; =20 -=09=09=09/* Prefetch next buffer address. */ -=09=09=09if (vec_idx + 1 < nr_vec) -=09=09=09=09rte_prefetch0((void *)(uintptr_t) -=09=09=09=09=09=09buf_vec[vec_idx + 1].buf_addr); =09=09=09buf_offset =3D 0; =09=09=09buf_avail =3D buf_len; =09=09} @@ -818,8 +813,6 @@ virtio_dev_rx_split(struct virtio_net *dev, struct vhos= t_virtqueue *vq, =09=09=09break; =09=09} =20 -=09=09rte_prefetch0((void *)(uintptr_t)buf_vec[0].buf_addr); - =09=09VHOST_LOG_DEBUG(VHOST_DATA, "(%d) current index %d | end index %d\n"= , =09=09=09dev->vid, vq->last_avail_idx, =09=09=09vq->last_avail_idx + num_buffers); @@ -867,8 +860,6 @@ virtio_dev_rx_packed(struct virtio_net *dev, struct vho= st_virtqueue *vq, =09=09=09break; =09=09} =20 -=09=09rte_prefetch0((void *)(uintptr_t)buf_vec[0].buf_addr); - =09=09VHOST_LOG_DEBUG(VHOST_DATA, "(%d) current index %d | end index %d\n"= , =09=09=09dev->vid, vq->last_avail_idx, =09=09=09vq->last_avail_idx + num_buffers); @@ -1124,9 +1115,6 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vhos= t_virtqueue *vq, =09=09goto out; =09} =20 -=09if (likely(nr_vec > 1)) -=09=09rte_prefetch0((void *)(uintptr_t)buf_vec[1].buf_addr); - =09if (virtio_net_with_host_offload(dev)) { =09=09if (unlikely(buf_len < sizeof(struct virtio_net_hdr))) { =09=09=09/* @@ -1137,7 +1125,6 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vhos= t_virtqueue *vq, =09=09=09hdr =3D &tmp_hdr; =09=09} else { =09=09=09hdr =3D (struct virtio_net_hdr *)((uintptr_t)buf_addr); -=09=09=09rte_prefetch0(hdr); =09=09} =09} =20 @@ -1167,9 +1154,6 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vhos= t_virtqueue *vq, =09=09buf_avail =3D buf_vec[vec_idx].buf_len - dev->vhost_hlen; =09} =20 -=09rte_prefetch0((void *)(uintptr_t) -=09=09=09(buf_addr + buf_offset)); - =09PRINT_PACKET(dev, =09=09=09(uintptr_t)(buf_addr + buf_offset), =09=09=09(uint32_t)buf_avail, 0); @@ -1235,14 +1219,6 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vho= st_virtqueue *vq, =09=09=09buf_iova =3D buf_vec[vec_idx].buf_iova; =09=09=09buf_len =3D buf_vec[vec_idx].buf_len; =20 -=09=09=09/* -=09=09=09 * Prefecth desc n + 1 buffer while -=09=09=09 * desc n buffer is processed. -=09=09=09 */ -=09=09=09if (vec_idx + 1 < nr_vec) -=09=09=09=09rte_prefetch0((void *)(uintptr_t) -=09=09=09=09=09=09buf_vec[vec_idx + 1].buf_addr); - =09=09=09buf_offset =3D 0; =09=09=09buf_avail =3D buf_len; =20 @@ -1386,8 +1362,6 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vh= ost_virtqueue *vq, =09=09if (likely(dev->dequeue_zero_copy =3D=3D 0)) =09=09=09update_shadow_used_ring_split(vq, head_idx, 0); =20 -=09=09rte_prefetch0((void *)(uintptr_t)buf_vec[0].buf_addr); - =09=09pkts[i] =3D rte_pktmbuf_alloc(mbuf_pool); =09=09if (unlikely(pkts[i] =3D=3D NULL)) { =09=09=09RTE_LOG(ERR, VHOST_DATA, @@ -1499,8 +1473,6 @@ virtio_dev_tx_packed(struct virtio_net *dev, struct v= host_virtqueue *vq, =09=09=09update_shadow_used_ring_packed(vq, buf_id, 0, =09=09=09=09=09desc_count); =20 -=09=09rte_prefetch0((void *)(uintptr_t)buf_vec[0].buf_addr); - =09=09pkts[i] =3D rte_pktmbuf_alloc(mbuf_pool); =09=09if (unlikely(pkts[i] =3D=3D NULL)) { =09=09=09RTE_LOG(ERR, VHOST_DATA, --=20 2.21.0