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 8B7651B488 for ; Thu, 22 Nov 2018 17:53:13 +0100 (CET) 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 F149689AD6; Thu, 22 Nov 2018 16:53:12 +0000 (UTC) Received: from ktraynor.remote.csb (unknown [10.36.118.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FC0660FD9; Thu, 22 Nov 2018 16:53:08 +0000 (UTC) From: Kevin Traynor To: Maxime Coquelin Cc: Jens Freimann , Tiwei Bie , dpdk stable Date: Thu, 22 Nov 2018 16:49:46 +0000 Message-Id: <20181122164957.13003-54-ktraynor@redhat.com> In-Reply-To: <20181122164957.13003-1-ktraynor@redhat.com> References: <20181122164957.13003-1-ktraynor@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.26]); Thu, 22 Nov 2018 16:53:13 +0000 (UTC) Subject: [dpdk-stable] patch 'vhost: avoid memory barriers when no descriptors dequeued' has been queued to stable release 18.08.1 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: , X-List-Received-Date: Thu, 22 Nov 2018 16:53:14 -0000 Hi, FYI, your patch has been queued to stable release 18.08.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/28/18. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. If the code is different (ie: not only metadata diffs), due for example to a change in context or macro names, please double check it. Thanks. Kevin Traynor --- >>From e0ac20188fdc6b7b0fddb4c813385dc5982fd3b4 Mon Sep 17 00:00:00 2001 From: Maxime Coquelin Date: Tue, 23 Oct 2018 12:07:10 +0200 Subject: [PATCH] vhost: avoid memory barriers when no descriptors dequeued [ upstream commit e988a6d84599f83321f8036dc45acf26a97ad7ea ] In both split and packed dequeue paths, flush_shadow_used_ring and vhost_ring_call variants gets called even if not packets have been dequeued, and so no descriptors updates happened. It has an impact on CPU pipeline, as memory barriers are used in these functions. This patch don't call these functions if no descriptors have been dequeued. The performance gain with split ring when dequeue zero-copy is disabled should be null, but should be noticeable with packed ring or dequeue zero-copy enabled. Fixes: ae999ce49dcb ("vhost: add Tx support for packed ring") Fixes: 915cf9404225 ("vhost: use shadow used ring in dequeue path") Signed-off-by: Maxime Coquelin Reviewed-by: Jens Freimann Tested-by: Jens Freimann Reviewed-by: Tiwei Bie --- lib/librte_vhost/virtio_net.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 1c31c0562..8ad30c94a 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -1361,6 +1361,8 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, } - flush_shadow_used_ring_split(dev, vq); - vhost_vring_call_split(dev, vq); + if (likely(vq->shadow_used_idx)) { + flush_shadow_used_ring_split(dev, vq); + vhost_vring_call_split(dev, vq); + } } @@ -1441,6 +1443,8 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, if (unlikely(i < count)) vq->shadow_used_idx = i; - flush_shadow_used_ring_split(dev, vq); - vhost_vring_call_split(dev, vq); + if (likely(vq->shadow_used_idx)) { + flush_shadow_used_ring_split(dev, vq); + vhost_vring_call_split(dev, vq); + } } @@ -1477,6 +1481,8 @@ virtio_dev_tx_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, } - flush_shadow_used_ring_packed(dev, vq); - vhost_vring_call_packed(dev, vq); + if (likely(vq->shadow_used_idx)) { + flush_shadow_used_ring_packed(dev, vq); + vhost_vring_call_packed(dev, vq); + } } @@ -1556,6 +1562,8 @@ virtio_dev_tx_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, if (unlikely(i < count)) vq->shadow_used_idx = i; - flush_shadow_used_ring_packed(dev, vq); - vhost_vring_call_packed(dev, vq); + if (likely(vq->shadow_used_idx)) { + flush_shadow_used_ring_packed(dev, vq); + vhost_vring_call_packed(dev, vq); + } } -- 2.19.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2018-11-22 16:47:33.690885454 +0000 +++ 0054-vhost-avoid-memory-barriers-when-no-descriptors-dequ.patch 2018-11-22 16:47:32.000000000 +0000 @@ -1,8 +1,10 @@ -From e988a6d84599f83321f8036dc45acf26a97ad7ea Mon Sep 17 00:00:00 2001 +From e0ac20188fdc6b7b0fddb4c813385dc5982fd3b4 Mon Sep 17 00:00:00 2001 From: Maxime Coquelin Date: Tue, 23 Oct 2018 12:07:10 +0200 Subject: [PATCH] vhost: avoid memory barriers when no descriptors dequeued +[ upstream commit e988a6d84599f83321f8036dc45acf26a97ad7ea ] + In both split and packed dequeue paths, flush_shadow_used_ring and vhost_ring_call variants gets called even if not packets have been dequeued, and so no descriptors updates happened. @@ -17,7 +19,6 @@ Fixes: ae999ce49dcb ("vhost: add Tx support for packed ring") Fixes: 915cf9404225 ("vhost: use shadow used ring in dequeue path") -Cc: stable@dpdk.org Signed-off-by: Maxime Coquelin Reviewed-by: Jens Freimann