From: Laurent Vivier <lvivier@redhat.com>
To: passt-dev@passt.top
Cc: Laurent Vivier <lvivier@redhat.com>
Subject: [PATCH 7/7] virtio: Prevent crash on virtqueue exhaustion with temporary workaround
Date: Fri, 31 Jul 2026 18:46:28 +0200 [thread overview]
Message-ID: <20260731164628.3556997-8-lvivier@redhat.com> (raw)
In-Reply-To: <20260731164628.3556997-1-lvivier@redhat.com>
When vq->inuse reaches vq->vring.num, instead of calling die(), yield
and retry. This is a temporary hack to avoid crashes when multiple
worker threads try to pop from an exhausted virtqueue.
The proper fix will involve coordination between worker threads to
prevent this condition entirely, but this keeps the system running for
now during multithreading development.
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
virtio.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/virtio.c b/virtio.c
index d7016cc3d580..21bdcb3c9a4d 100644
--- a/virtio.c
+++ b/virtio.c
@@ -77,6 +77,7 @@
#include <endian.h>
#include <string.h>
#include <errno.h>
+#include <sched.h>
#include <sys/eventfd.h>
#include <sys/socket.h>
@@ -531,6 +532,7 @@ int vu_queue_pop(const struct vu_dev *dev, struct vu_virtq *vq,
unsigned int head;
int ret;
+again:
if (!vq->vring.avail)
return -1;
@@ -542,8 +544,10 @@ int vu_queue_pop(const struct vu_dev *dev, struct vu_virtq *vq,
*/
smp_rmb();
- if (vq->inuse >= vq->vring.num)
- die("vhost-user queue size exceeded");
+ if (vq->inuse >= vq->vring.num) {
+ sched_yield();
+ goto again;
+ }
virtqueue_get_head(vq, vq->last_avail_idx++, &head);
--
2.54.0
prev parent reply other threads:[~2026-07-31 16:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 16:46 [PATCH 0/7] multithreading: Add worker threads for queue pair processing Laurent Vivier
2026-07-31 16:46 ` [PATCH 1/7] vhost_user: Reset vq enable flag in vu_cleanup() Laurent Vivier
2026-07-31 16:46 ` [PATCH 2/7] threading: Add basic threading infrastructure Laurent Vivier
2026-07-31 16:46 ` [PATCH 3/7] passt: Integrate main event loop with " Laurent Vivier
2026-07-31 16:46 ` [PATCH 4/7] flow: Delegate epoll file descriptor management to threading subsystem Laurent Vivier
2026-07-31 16:46 ` [PATCH 5/7] ctx: Remove epollfd from context structure Laurent Vivier
2026-07-31 16:46 ` [PATCH 6/7] vhost-user: Add per-qpair worker threads Laurent Vivier
2026-07-31 16:46 ` Laurent Vivier [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260731164628.3556997-8-lvivier@redhat.com \
--to=lvivier@redhat.com \
--cc=passt-dev@passt.top \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).