patch 'vhost: add VDUSE virtqueue ready state polling workaround' has been queued to stable release 24.11.4

Kevin Traynor ktraynor at redhat.com
Fri Oct 31 15:33:15 CET 2025


Hi,

FYI, your patch has been queued to stable release 24.11.4

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/05/25. 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.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/f8f9f0ff9a1533efed64d553fcba28f0a26f6fc6

Thanks.

Kevin

---
>From f8f9f0ff9a1533efed64d553fcba28f0a26f6fc6 Mon Sep 17 00:00:00 2001
From: Maxime Coquelin <maxime.coquelin at redhat.com>
Date: Tue, 16 Sep 2025 11:35:49 +0200
Subject: [PATCH] vhost: add VDUSE virtqueue ready state polling workaround

[ upstream commit 84350b1f470558836b61ff1347f660e06c81cbf5 ]

Add workaround to poll virtqueue ready states before starting device
when VIRTIO_DEVICE_STATUS_DRIVER_OK is set in vduse_events_handler().

For each virtqueue, poll using VDUSE_VQ_GET_INFO ioctl to check
vq_info->ready state with configurable retry limit. This addresses
timing issues where device start was attempted before all virtqueues
were properly initialized and ready.

A notification mechanism will be introduced in the next version of
the VDUSE uAPI. When it lands, we would only apply this workaround
when the kernel does not support it.

Fixes: a9120db8b98b ("vhost: add VDUSE device startup")

Reviewed-by: David Marchand <david.marchand at redhat.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
 lib/vhost/vduse.c | 61 +++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 59 insertions(+), 2 deletions(-)

diff --git a/lib/vhost/vduse.c b/lib/vhost/vduse.c
index 801674be42..63750d0b25 100644
--- a/lib/vhost/vduse.c
+++ b/lib/vhost/vduse.c
@@ -272,4 +272,53 @@ vduse_vring_cleanup(struct virtio_net *dev, unsigned int index)
 }
 
+/*
+ * Tests show that virtqueues get ready at the first retry at worst,
+ * but let's be on the safe side and allow more retries.
+ */
+#define VDUSE_VQ_READY_POLL_MAX_RETRIES 100
+
+static int
+vduse_wait_for_virtqueues_ready(struct virtio_net *dev)
+{
+	unsigned int i;
+	int ret;
+
+	for (i = 0; i < dev->nr_vring; i++) {
+		int retry_count = 0;
+
+		while (retry_count < VDUSE_VQ_READY_POLL_MAX_RETRIES) {
+			struct vduse_vq_info vq_info = { 0 };
+
+			vq_info.index = i;
+			ret = ioctl(dev->vduse_dev_fd, VDUSE_VQ_GET_INFO, &vq_info);
+			if (ret) {
+				VHOST_CONFIG_LOG(dev->ifname, ERR,
+					"Failed to get VQ %u info while polling ready state: %s",
+					i, strerror(errno));
+				return -1;
+			}
+
+			if (vq_info.ready) {
+				VHOST_CONFIG_LOG(dev->ifname, DEBUG,
+					"VQ %u is ready after %u retries", i, retry_count);
+				break;
+			}
+
+			retry_count++;
+			usleep(1000);
+		}
+
+		if (retry_count >= VDUSE_VQ_READY_POLL_MAX_RETRIES) {
+			VHOST_CONFIG_LOG(dev->ifname, ERR,
+				"VQ %u ready state polling timeout after %u retries",
+				i, VDUSE_VQ_READY_POLL_MAX_RETRIES);
+			return -1;
+		}
+	}
+
+	VHOST_CONFIG_LOG(dev->ifname, INFO, "All virtqueues are ready after polling");
+	return 0;
+}
+
 static void
 vduse_device_start(struct virtio_net *dev, bool reconnect)
@@ -414,8 +463,16 @@ vduse_events_handler(int fd, void *arg, int *close __rte_unused)
 
 	if ((old_status ^ dev->status) & VIRTIO_DEVICE_STATUS_DRIVER_OK) {
-		if (dev->status & VIRTIO_DEVICE_STATUS_DRIVER_OK)
+		if (dev->status & VIRTIO_DEVICE_STATUS_DRIVER_OK) {
+			/* Poll virtqueues ready states before starting device */
+			ret = vduse_wait_for_virtqueues_ready(dev);
+			if (ret < 0) {
+				VHOST_CONFIG_LOG(dev->ifname, ERR,
+					"Failed to wait for virtqueues ready, aborting device start");
+				return;
+			}
 			vduse_device_start(dev, false);
-		else
+		} else {
 			vduse_device_stop(dev);
+		}
 	}
 
-- 
2.51.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2025-10-31 13:53:54.463454382 +0000
+++ 0073-vhost-add-VDUSE-virtqueue-ready-state-polling-workar.patch	2025-10-31 13:53:52.175523802 +0000
@@ -1 +1 @@
-From 84350b1f470558836b61ff1347f660e06c81cbf5 Mon Sep 17 00:00:00 2001
+From f8f9f0ff9a1533efed64d553fcba28f0a26f6fc6 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 84350b1f470558836b61ff1347f660e06c81cbf5 ]
+
@@ -19 +20,0 @@
-Cc: stable at dpdk.org
@@ -28 +29 @@
-index 2015ae9f21..70fe472624 100644
+index 801674be42..63750d0b25 100644
@@ -31 +32 @@
-@@ -273,4 +273,53 @@ vduse_vring_cleanup(struct virtio_net *dev, unsigned int index)
+@@ -272,4 +272,53 @@ vduse_vring_cleanup(struct virtio_net *dev, unsigned int index)
@@ -85 +86 @@
-@@ -415,8 +464,16 @@ vduse_events_handler(int fd, void *arg, int *close __rte_unused)
+@@ -414,8 +463,16 @@ vduse_events_handler(int fd, void *arg, int *close __rte_unused)



More information about the stable mailing list