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 40F1FA0093 for ; Tue, 19 May 2020 15:11:06 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3A02E1D6FC; Tue, 19 May 2020 15:11:06 +0200 (CEST) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by dpdk.org (Postfix) with ESMTP id D62271D6A4 for ; Tue, 19 May 2020 15:11:04 +0200 (CEST) Received: by mail-wr1-f67.google.com with SMTP id e16so15838588wra.7 for ; Tue, 19 May 2020 06:11:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sLGfyJCPlwsxXGGuNnRTCFvPqmLNqdwcOc3MBaQFmLE=; b=MxrpW6fI6b0GHnN7x9n63SnBHALUo+8mmsM9tg4FMvKBspaX1A0eu+PDJoSyMDzuJH 6mizOSMp++T7wc56AjJ5Qr1KQ+Kx/rn2TIQ/mBoKqWqmV1JCsJ9fUH5nOABPQ736/eiH QUmrN8eV4SV/Y+GgvJnfsDdSoSotdLqsat47+a4jMrsm5il4bRi2jstJJF9e+UGRKX7Q IuIi1+2C3dtw/gMrkWbK0uXkuRVzhv6oVdGt7ffxICu6PXOdIGcfVJYxcJIPzPwugYSI pbKtA6k7NXJJrO0ZPgAd0jd8hEknGh9byW40hQEnAZMfTzc6y80l9vfaZBDyq8M6z/UB 1CZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sLGfyJCPlwsxXGGuNnRTCFvPqmLNqdwcOc3MBaQFmLE=; b=l172vZgmObQKA74XFEr+YAEKz1W7GRvFE0Z1/Yydc7UJwscExF/V+kQB1rp4rkxc1S dUImWpAUA65uhO1YDoSQPnlBWcT6zqMTEL3f/OuMkoHoVLphwn+lftScUZmYeMFQaXmP wOL8gJJH3fJ3eyzptFnYnN4TsEosAy3GhWCGG8Q7rXtbkmzSNTBwi7wePtQnblcUVuIz Q8XlLQTeBmgebORBB2wO0s/oe0r5bZSKYMqesCTuSQRPbEGafoXDJSmn9gD4H+mx+FQa eXaVeYs2DVkdceK1osjy3RP0mll1VGxcSGFaZrlgAHcyb/UsYztRJBKJU7FFwda54c0y nODA== X-Gm-Message-State: AOAM533xt/W5J/4icwgJ6oTbMvC+rB1Z3+HVCRRPBFln5X2FdiRl7XP+ +rFQa+CLP3kJunMr3vuIqoo= X-Google-Smtp-Source: ABdhPJxZmG3wg7zQHf/6/Dr4DAkZZYjSeOMdUNS52H3DoM7bSHkUKH4nzMc18zvS+nSmB02GO68MyQ== X-Received: by 2002:adf:e408:: with SMTP id g8mr27668686wrm.363.1589893864564; Tue, 19 May 2020 06:11:04 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id a8sm21494429wrg.85.2020.05.19.06.11.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 06:11:03 -0700 (PDT) From: luca.boccassi@gmail.com To: Marvin Liu Cc: Yinan Wang , Maxime Coquelin , dpdk stable Date: Tue, 19 May 2020 14:03:54 +0100 Message-Id: <20200519130549.112823-99-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519130549.112823-1-luca.boccassi@gmail.com> References: <20200519125804.104349-1-luca.boccassi@gmail.com> <20200519130549.112823-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'vhost: fix shadow update' has been queued to stable release 19.11.3 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" Hi, FYI, your patch has been queued to stable release 19.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/21/20. 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. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Luca Boccassi --- >From 2f48b0530563e5ce5f383212d0da5fad758cab82 Mon Sep 17 00:00:00 2001 From: Marvin Liu Date: Fri, 17 Apr 2020 10:39:05 +0800 Subject: [PATCH] vhost: fix shadow update [ upstream commit 8b13d12a16e7da07326f75bb8b5b82a39bdcbe9e ] Defer shadow ring update introduces functional issue which has been described in Eugenio's fix patch. The current implementation of vhost_net in packed vring tries to fill the shadow vector before send any actual changes to the guest. While this can be beneficial for the throughput, it conflicts with some bufferfloats methods like the linux kernel napi, that stops transmitting packets if there are too much bytes/buffers in the driver. It also introduces performance issue when frontend run much faster than backend. Frontend may not be able to collect available descs when shadow update is deferred. That will harm RFC2544 throughput. Appropriate choice is to remove deferred shadowed update method. Now shadowed used descs are flushed at the end of dequeue function. Fixes: 31d6c6a5b820 ("vhost: optimize packed ring dequeue") Signed-off-by: Marvin Liu Tested-by: Yinan Wang Reviewed-by: Maxime Coquelin --- lib/librte_vhost/virtio_net.c | 46 ++--------------------------------- 1 file changed, 2 insertions(+), 44 deletions(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 3f46f5c517..4c7ae29a36 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -382,25 +382,6 @@ vhost_shadow_enqueue_single_packed(struct virtio_net *dev, } } -static __rte_always_inline void -vhost_flush_dequeue_packed(struct virtio_net *dev, - struct vhost_virtqueue *vq) -{ - int shadow_count; - if (!vq->shadow_used_idx) - return; - - shadow_count = vq->last_used_idx - vq->shadow_last_used_idx; - if (shadow_count <= 0) - shadow_count += vq->size; - - if ((uint32_t)shadow_count >= (vq->size - MAX_PKT_BURST)) { - do_data_copy_dequeue(vq); - vhost_flush_dequeue_shadow_packed(dev, vq); - vhost_vring_call_packed(dev, vq); - } -} - /* avoid write operation when necessary, to lessen cache issues */ #define ASSIGN_UNLESS_EQUAL(var, val) do { \ if ((var) != (val)) \ @@ -2137,20 +2118,6 @@ virtio_dev_tx_packed_zmbuf(struct virtio_net *dev, return pkt_idx; } -static __rte_always_inline bool -next_desc_is_avail(const struct vhost_virtqueue *vq) -{ - bool wrap_counter = vq->avail_wrap_counter; - uint16_t next_used_idx = vq->last_used_idx + 1; - - if (next_used_idx >= vq->size) { - next_used_idx -= vq->size; - wrap_counter ^= 1; - } - - return desc_is_avail(&vq->desc_packed[next_used_idx], wrap_counter); -} - static __rte_noinline uint16_t virtio_dev_tx_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, @@ -2167,7 +2134,6 @@ virtio_dev_tx_packed(struct virtio_net *dev, if (remained >= PACKED_BATCH_SIZE) { if (!virtio_dev_tx_batch_packed(dev, vq, mbuf_pool, &pkts[pkt_idx])) { - vhost_flush_dequeue_packed(dev, vq); pkt_idx += PACKED_BATCH_SIZE; remained -= PACKED_BATCH_SIZE; continue; @@ -2177,7 +2143,6 @@ virtio_dev_tx_packed(struct virtio_net *dev, if (virtio_dev_tx_single_packed(dev, vq, mbuf_pool, &pkts[pkt_idx])) break; - vhost_flush_dequeue_packed(dev, vq); pkt_idx++; remained--; @@ -2186,15 +2151,8 @@ virtio_dev_tx_packed(struct virtio_net *dev, if (vq->shadow_used_idx) { do_data_copy_dequeue(vq); - if (remained && !next_desc_is_avail(vq)) { - /* - * The guest may be waiting to TX some buffers to - * enqueue more to avoid bufferfloat, so we try to - * reduce latency here. - */ - vhost_flush_dequeue_shadow_packed(dev, vq); - vhost_vring_call_packed(dev, vq); - } + vhost_flush_dequeue_shadow_packed(dev, vq); + vhost_vring_call_packed(dev, vq); } return pkt_idx; -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-05-19 14:04:48.497459873 +0100 +++ 0099-vhost-fix-shadow-update.patch 2020-05-19 14:04:44.312650112 +0100 @@ -1,8 +1,10 @@ -From 8b13d12a16e7da07326f75bb8b5b82a39bdcbe9e Mon Sep 17 00:00:00 2001 +From 2f48b0530563e5ce5f383212d0da5fad758cab82 Mon Sep 17 00:00:00 2001 From: Marvin Liu Date: Fri, 17 Apr 2020 10:39:05 +0800 Subject: [PATCH] vhost: fix shadow update +[ upstream commit 8b13d12a16e7da07326f75bb8b5b82a39bdcbe9e ] + Defer shadow ring update introduces functional issue which has been described in Eugenio's fix patch. @@ -21,7 +23,6 @@ Now shadowed used descs are flushed at the end of dequeue function. Fixes: 31d6c6a5b820 ("vhost: optimize packed ring dequeue") -Cc: stable@dpdk.org Signed-off-by: Marvin Liu Tested-by: Yinan Wang @@ -31,7 +32,7 @@ 1 file changed, 2 insertions(+), 44 deletions(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c -index 2104159047..4a75319432 100644 +index 3f46f5c517..4c7ae29a36 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -382,25 +382,6 @@ vhost_shadow_enqueue_single_packed(struct virtio_net *dev, @@ -60,7 +61,7 @@ /* avoid write operation when necessary, to lessen cache issues */ #define ASSIGN_UNLESS_EQUAL(var, val) do { \ if ((var) != (val)) \ -@@ -2133,20 +2114,6 @@ virtio_dev_tx_packed_zmbuf(struct virtio_net *dev, +@@ -2137,20 +2118,6 @@ virtio_dev_tx_packed_zmbuf(struct virtio_net *dev, return pkt_idx; } @@ -81,7 +82,7 @@ static __rte_noinline uint16_t virtio_dev_tx_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, -@@ -2163,7 +2130,6 @@ virtio_dev_tx_packed(struct virtio_net *dev, +@@ -2167,7 +2134,6 @@ virtio_dev_tx_packed(struct virtio_net *dev, if (remained >= PACKED_BATCH_SIZE) { if (!virtio_dev_tx_batch_packed(dev, vq, mbuf_pool, &pkts[pkt_idx])) { @@ -89,7 +90,7 @@ pkt_idx += PACKED_BATCH_SIZE; remained -= PACKED_BATCH_SIZE; continue; -@@ -2173,7 +2139,6 @@ virtio_dev_tx_packed(struct virtio_net *dev, +@@ -2177,7 +2143,6 @@ virtio_dev_tx_packed(struct virtio_net *dev, if (virtio_dev_tx_single_packed(dev, vq, mbuf_pool, &pkts[pkt_idx])) break; @@ -97,7 +98,7 @@ pkt_idx++; remained--; -@@ -2182,15 +2147,8 @@ virtio_dev_tx_packed(struct virtio_net *dev, +@@ -2186,15 +2151,8 @@ virtio_dev_tx_packed(struct virtio_net *dev, if (vq->shadow_used_idx) { do_data_copy_dequeue(vq);