[dpdk-stable] patch 'vhost: flush shadow Tx if no more packets' has been queued to stable release 19.11.1

luca.boccassi at gmail.com luca.boccassi at gmail.com
Tue Feb 11 12:22:04 CET 2020


Hi,

FYI, your patch has been queued to stable release 19.11.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 02/13/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 474437bad30f58321ab8723f175ad5bc862afb8d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma at redhat.com>
Date: Wed, 29 Jan 2020 20:33:10 +0100
Subject: [PATCH] vhost: flush shadow Tx if no more packets
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

[ upstream commit cdf1dc5e6a361df17d081e3e975cc586a4b7d68d ]

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.

To solve it, we flush the shadow packets at the end of
virtio_dev_tx_packed if we have starved the vring, i.e. the next
buffer is not available for the device.

Since this last check can be expensive because of the atomic, we only
check it if we have not obtained the expected "count" packets. If it
happens to obtain "count" packets and there is no more available
packets the caller needs to keep call virtio_dev_tx_packed again.

Fixes: 31d6c6a5b820 ("vhost: optimize packed ring dequeue")

Signed-off-by: Eugenio Pérez <eperezma at redhat.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
 lib/librte_vhost/virtio_net.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 21c311732a..ac2842b2d2 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -2133,6 +2133,20 @@ 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,
@@ -2165,9 +2179,20 @@ virtio_dev_tx_packed(struct virtio_net *dev,
 
 	} while (remained);
 
-	if (vq->shadow_used_idx)
+	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);
+		}
+	}
+
 	return pkt_idx;
 }
 
-- 
2.20.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2020-02-11 11:17:44.742544050 +0000
+++ 0178-vhost-flush-shadow-Tx-if-no-more-packets.patch	2020-02-11 11:17:38.824009275 +0000
@@ -1,4 +1,4 @@
-From cdf1dc5e6a361df17d081e3e975cc586a4b7d68d Mon Sep 17 00:00:00 2001
+From 474437bad30f58321ab8723f175ad5bc862afb8d Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma at redhat.com>
 Date: Wed, 29 Jan 2020 20:33:10 +0100
 Subject: [PATCH] vhost: flush shadow Tx if no more packets
@@ -6,6 +6,8 @@
 Content-Type: text/plain; charset=UTF-8
 Content-Transfer-Encoding: 8bit
 
+[ upstream commit cdf1dc5e6a361df17d081e3e975cc586a4b7d68d ]
+
 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
@@ -23,7 +25,6 @@
 packets the caller needs to keep call virtio_dev_tx_packed again.
 
 Fixes: 31d6c6a5b820 ("vhost: optimize packed ring dequeue")
-Cc: stable at dpdk.org
 
 Signed-off-by: Eugenio Pérez <eperezma at redhat.com>
 Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
@@ -32,7 +33,7 @@
  1 file changed, 26 insertions(+), 1 deletion(-)
 
 diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
-index 73bf98bd93..37c47c7dc0 100644
+index 21c311732a..ac2842b2d2 100644
 --- a/lib/librte_vhost/virtio_net.c
 +++ b/lib/librte_vhost/virtio_net.c
 @@ -2133,6 +2133,20 @@ virtio_dev_tx_packed_zmbuf(struct virtio_net *dev,


More information about the stable mailing list