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

Shani Peretz shperetz at nvidia.com
Sun Dec 21 15:56:46 CET 2025


Hi,

FYI, your patch has been queued to stable release 23.11.6

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 12/26/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/shanipr/dpdk-stable

This queued commit can be viewed at:
https://github.com/shanipr/dpdk-stable/commit/0deaa8dd208d0afda5941aefe1cd76ab7f8ef0fc

Thanks.

Shani

---
>From 0deaa8dd208d0afda5941aefe1cd76ab7f8ef0fc 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 3b1a3b008e..d0bd2a537d 100644
--- a/lib/vhost/vduse.c
+++ b/lib/vhost/vduse.c
@@ -279,6 +279,55 @@ vduse_vring_cleanup(struct virtio_net *dev, unsigned int index)
 	vq->last_avail_idx = 0;
 }
 
+/*
+ * 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_LOG_CONFIG(dev->ifname, ERR,
+					"Failed to get VQ %u info while polling ready state: %s",
+					i, strerror(errno));
+				return -1;
+			}
+
+			if (vq_info.ready) {
+				VHOST_LOG_CONFIG(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_LOG_CONFIG(dev->ifname, ERR,
+				"VQ %u ready state polling timeout after %u retries",
+				i, VDUSE_VQ_READY_POLL_MAX_RETRIES);
+			return -1;
+		}
+	}
+
+	VHOST_LOG_CONFIG(dev->ifname, INFO, "All virtqueues are ready after polling");
+	return 0;
+}
+
 static void
 vduse_device_start(struct virtio_net *dev)
 {
@@ -411,10 +460,18 @@ vduse_events_handler(int fd, void *arg, int *remove __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_LOG_CONFIG(dev->ifname, ERR,
+					"Failed to wait for virtqueues ready, aborting device start");
+				return;
+			}
 			vduse_device_start(dev);
-		else
+		} else {
 			vduse_device_stop(dev);
+		}
 	}
 
 	VHOST_LOG_CONFIG(dev->ifname, INFO, "Request %s (%u) handled successfully\n",
-- 
2.43.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2025-12-21 16:54:20.174396818 +0200
+++ 0058-vhost-add-VDUSE-virtqueue-ready-state-polling-workar.patch	2025-12-21 16:54:17.148081000 +0200
@@ -1 +1 @@
-From 84350b1f470558836b61ff1347f660e06c81cbf5 Mon Sep 17 00:00:00 2001
+From 0deaa8dd208d0afda5941aefe1cd76ab7f8ef0fc 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 3b1a3b008e..d0bd2a537d 100644
@@ -31 +32 @@
-@@ -272,6 +272,55 @@ vduse_vring_cleanup(struct virtio_net *dev, unsigned int index)
+@@ -279,6 +279,55 @@ vduse_vring_cleanup(struct virtio_net *dev, unsigned int index)
@@ -56 +57 @@
-+				VHOST_CONFIG_LOG(dev->ifname, ERR,
++				VHOST_LOG_CONFIG(dev->ifname, ERR,
@@ -63 +64 @@
-+				VHOST_CONFIG_LOG(dev->ifname, DEBUG,
++				VHOST_LOG_CONFIG(dev->ifname, DEBUG,
@@ -73 +74 @@
-+			VHOST_CONFIG_LOG(dev->ifname, ERR,
++			VHOST_LOG_CONFIG(dev->ifname, ERR,
@@ -80 +81 @@
-+	VHOST_CONFIG_LOG(dev->ifname, INFO, "All virtqueues are ready after polling");
++	VHOST_LOG_CONFIG(dev->ifname, INFO, "All virtqueues are ready after polling");
@@ -85 +86 @@
- vduse_device_start(struct virtio_net *dev, bool reconnect)
+ vduse_device_start(struct virtio_net *dev)
@@ -87 +88 @@
-@@ -414,10 +463,18 @@ vduse_events_handler(int fd, void *arg, int *close __rte_unused)
+@@ -411,10 +460,18 @@ vduse_events_handler(int fd, void *arg, int *remove __rte_unused)
@@ -96 +97 @@
-+				VHOST_CONFIG_LOG(dev->ifname, ERR,
++				VHOST_LOG_CONFIG(dev->ifname, ERR,
@@ -100 +101 @@
- 			vduse_device_start(dev, false);
+ 			vduse_device_start(dev);
@@ -107 +108 @@
- 	VHOST_CONFIG_LOG(dev->ifname, INFO, "Request %s (%u) handled successfully",
+ 	VHOST_LOG_CONFIG(dev->ifname, INFO, "Request %s (%u) handled successfully\n",


More information about the stable mailing list