From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3355148A44 for ; Fri, 31 Oct 2025 15:38:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2BEFB4067E; Fri, 31 Oct 2025 15:38:13 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 8153B4067B for ; Fri, 31 Oct 2025 15:38:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761921491; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=acvjptT3ttdp1WE8K4e1pfx7n6hK8o3nfMp7bYD5x3I=; b=Nq18Onjtq0gn68r7bkPaWBKRGCqWad3Bpbtf5Tg4wkzlQq4mYZ2Vqw6ukbMNlz02cZ0Kgw TYGJEstRVLitaC9wapC8MLfhw3HK7PT0Q8vnFJO5FklTm7ivjpUBy9c/FNO82ZxXgjFPKJ 5xRilkwED8qISJ9XBLM3oC2slm39HX4= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-422-7tgnLVq3NXCIJ1I3Rl-vlA-1; Fri, 31 Oct 2025 10:38:09 -0400 X-MC-Unique: 7tgnLVq3NXCIJ1I3Rl-vlA-1 X-Mimecast-MFC-AGG-ID: 7tgnLVq3NXCIJ1I3Rl-vlA_1761921488 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C2EC618002F7 for ; Fri, 31 Oct 2025 14:38:08 +0000 (UTC) Received: from rh.redhat.com (unknown [10.44.32.50]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2F2B91800579; Fri, 31 Oct 2025 14:38:06 +0000 (UTC) From: Kevin Traynor To: Maxime Coquelin Cc: David Marchand , dpdk stable Subject: patch 'vhost: add VDUSE virtqueue ready state polling workaround' has been queued to stable release 24.11.4 Date: Fri, 31 Oct 2025 14:33:15 +0000 Message-ID: <20251031143421.324432-73-ktraynor@redhat.com> In-Reply-To: <20251031143421.324432-1-ktraynor@redhat.com> References: <20251031143421.324432-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 9KGtXqCGqw8oihfvvvMtbHxSoDWkzmhNTgyM08IFSyk_1761921488 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 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 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 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 Signed-off-by: Maxime Coquelin --- 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@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)