From patchwork Fri Jul 10 02:38:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Joyce Kong X-Patchwork-Id: 73680 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AE9DAA0526; Fri, 10 Jul 2020 04:42:17 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DD9421DD21; Fri, 10 Jul 2020 04:42:09 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id F42351DCF9 for ; Fri, 10 Jul 2020 04:42:07 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7F727113E; Thu, 9 Jul 2020 19:42:07 -0700 (PDT) Received: from net-arm-thunderx2-03.shanghai.arm.com (net-arm-thunderx2-03.shanghai.arm.com [10.169.208.204]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 92A1A3F9AB; Thu, 9 Jul 2020 19:42:02 -0700 (PDT) From: Joyce Kong To: maxime.coquelin@redhat.com, jerinj@marvell.com, zhihong.wang@intel.com, amorenoz@redhat.com, mb@smartsharesystems.com, xiaolong.ye@intel.com, beilei.xing@intel.com, jia.guo@intel.com, john.mcnamara@intel.com, matan@mellanox.com, shahafs@mellanox.com, viacheslavo@mellanox.com, honnappa.nagarahalli@arm.com, phil.yang@arm.com, ruifeng.wang@arm.com Cc: dev@dpdk.org, nd@arm.com Date: Fri, 10 Jul 2020 10:38:50 +0800 Message-Id: <20200710023850.43898-4-joyce.kong@arm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200710023850.43898-1-joyce.kong@arm.com> References: <20200611033248.39049-1-joyce.kong@arm.com> <20200710023850.43898-1-joyce.kong@arm.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 3/3] lib/vhost: restrict pointer aliasing for packed vpmd 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Restrict pointer aliasing to allow the compiler to vectorize loop more aggressively. With this patch, a 9.6% improvement is observed in throughput for the packed virtio-net PVP case, and a 2.8% improvement in throughput for the packed virtio-user PVP case. All performance data are measured on ThunderX-2 platform under 0.001% acceptable packet loss with 1 core on both vhost and virtio side. Signed-off-by: Joyce Kong Reviewed-by: Phil Yang Acked-by: Adrián Moreno --- drivers/net/virtio/virtio_rxtx_simple_neon.c | 5 +++-- lib/librte_vhost/virtio_net.c | 14 +++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/net/virtio/virtio_rxtx_simple_neon.c b/drivers/net/virtio/virtio_rxtx_simple_neon.c index a9b649814..02520fda8 100644 --- a/drivers/net/virtio/virtio_rxtx_simple_neon.c +++ b/drivers/net/virtio/virtio_rxtx_simple_neon.c @@ -36,8 +36,9 @@ * - nb_pkts < RTE_VIRTIO_DESC_PER_LOOP, just return no packet */ uint16_t -virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf - **__rte_restrict rx_pkts, uint16_t nb_pkts) +virtio_recv_pkts_vec(void *rx_queue, + struct rte_mbuf **__rte_restrict rx_pkts, + uint16_t nb_pkts) { struct virtnet_rx *rxvq = rx_queue; struct virtqueue *vq = rxvq->vq; diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 236498f71..1d0be3dd4 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -1353,8 +1353,8 @@ virtio_dev_rx_single_packed(struct virtio_net *dev, static __rte_noinline uint32_t virtio_dev_rx_packed(struct virtio_net *dev, - struct vhost_virtqueue *vq, - struct rte_mbuf **pkts, + struct vhost_virtqueue *__rte_restrict vq, + struct rte_mbuf **__rte_restrict pkts, uint32_t count) { uint32_t pkt_idx = 0; @@ -1439,7 +1439,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id, uint16_t rte_vhost_enqueue_burst(int vid, uint16_t queue_id, - struct rte_mbuf **pkts, uint16_t count) + struct rte_mbuf **__rte_restrict pkts, uint16_t count) { struct virtio_net *dev = get_device(vid); @@ -2671,9 +2671,9 @@ free_zmbuf(struct vhost_virtqueue *vq) static __rte_noinline uint16_t virtio_dev_tx_packed_zmbuf(struct virtio_net *dev, - struct vhost_virtqueue *vq, + struct vhost_virtqueue *__rte_restrict vq, struct rte_mempool *mbuf_pool, - struct rte_mbuf **pkts, + struct rte_mbuf **__rte_restrict pkts, uint32_t count) { uint32_t pkt_idx = 0; @@ -2707,9 +2707,9 @@ virtio_dev_tx_packed_zmbuf(struct virtio_net *dev, static __rte_noinline uint16_t virtio_dev_tx_packed(struct virtio_net *dev, - struct vhost_virtqueue *vq, + struct vhost_virtqueue *__rte_restrict vq, struct rte_mempool *mbuf_pool, - struct rte_mbuf **pkts, + struct rte_mbuf **__rte_restrict pkts, uint32_t count) { uint32_t pkt_idx = 0;