From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Wl/FGVPZ; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id 94D3D5A026D for ; Fri, 31 Jul 2026 18:46:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785516400; 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=JqmqWhhqDSmlLkpjTQSw17AyvnPt7oTMEWG3qY4aky4=; b=Wl/FGVPZ/SUv213dvNtBLmdl/6hLH8k33ts5wmiyHDDnyDJKgqVp0uJHk/v+yL/fKD8rel MnSMxoWs1VaEjVLd5D6WbrnTgr7JJBEtn4pN+5iTYKqHv6AFLADi11AFW2RXykvtizx5QD DV9oF/RcRb/ElAu6+0WQNIzY3xA1vgM= Received: from mx-prod-mc-06.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-499-kPkj6ECoP0WYYbAgYAH-JQ-1; Fri, 31 Jul 2026 12:46:39 -0400 X-MC-Unique: kPkj6ECoP0WYYbAgYAH-JQ-1 X-Mimecast-MFC-AGG-ID: kPkj6ECoP0WYYbAgYAH-JQ_1785516398 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4B91018002A7 for ; Fri, 31 Jul 2026 16:46:38 +0000 (UTC) Received: from lenovo-t14s.redhat.corp (headnet05.pony-001.prod.iad2.dc.redhat.com [10.2.32.117]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8AAF941C; Fri, 31 Jul 2026 16:46:37 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH 7/7] virtio: Prevent crash on virtqueue exhaustion with temporary workaround Date: Fri, 31 Jul 2026 18:46:28 +0200 Message-ID: <20260731164628.3556997-8-lvivier@redhat.com> In-Reply-To: <20260731164628.3556997-1-lvivier@redhat.com> References: <20260731164628.3556997-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 8Njzql3CANp7-Pn4P-fXhLZ5Mzc5uaGdi4Z5LmbPZPs_1785516398 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: BZYTCM5RQRBSL47FRKRBVOUU3LE3YVEG X-Message-ID-Hash: BZYTCM5RQRBSL47FRKRBVOUU3LE3YVEG X-MailFrom: lvivier@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Laurent Vivier X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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 #include #include +#include #include #include @@ -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