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=I7sR1uY0; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 9B33C5A0274 for ; Fri, 13 Mar 2026 19:26:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773426388; 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=HsDz5V/PMQ8b27T4j9WZoRdNjtPyWSyE+dAU81M/ZXw=; b=I7sR1uY0dGZlZNUNZ8CrSszsjfYulwlZPhAwDZsS5oA0SiFrKv2x/30z1ESBNImLnKtYh7 md0XdjDRuqcgNVSbM92saFrCNQOmcVGD+Q9jS9nf66e8Az85WmGr/EOrgC+du0WG44PQHr ybggV6ynXalwv/6qQO0Gr83X5n93my4= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-346--0fL6lpZMgKV6nH2KTCfqA-1; Fri, 13 Mar 2026 14:26:27 -0400 X-MC-Unique: -0fL6lpZMgKV6nH2KTCfqA-1 X-Mimecast-MFC-AGG-ID: -0fL6lpZMgKV6nH2KTCfqA_1773426385 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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C7E991977699 for ; Fri, 13 Mar 2026 18:26:24 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.44.35.65]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D270318002A6; Fri, 13 Mar 2026 18:26:23 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH v2 2/3] vu_handle_tx: Pass actual remaining out_sg capacity to vu_queue_pop() Date: Fri, 13 Mar 2026 19:26:17 +0100 Message-ID: <20260313182618.4157365-3-lvivier@redhat.com> In-Reply-To: <20260313182618.4157365-1-lvivier@redhat.com> References: <20260313182618.4157365-1-lvivier@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: 0rT6ZVszVfk2U9C3VzNWERsFyIkwkXIjF4wrVsXRzho_1773426385 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: LZNRNJIH62Q7TE74MC4FFMNQ7GLTOEUX X-Message-ID-Hash: LZNRNJIH62Q7TE74MC4FFMNQ7GLTOEUX 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: In vu_handle_tx(), pass the actual remaining iovec capacity (ARRAY_SIZE(out_sg) - out_sg_count) to vu_queue_pop() rather than a fixed VU_MAX_TX_BUFFER_NB. This enables dynamic allocation of iovec entries to each element rather than reserving a fixed number of slots per descriptor. Signed-off-by: Laurent Vivier --- vu_common.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/vu_common.c b/vu_common.c index 4d809ac38a4b..ed0033d6bb11 100644 --- a/vu_common.c +++ b/vu_common.c @@ -20,8 +20,6 @@ #include "migrate.h" #include "epoll_ctl.h" -#define VU_MAX_TX_BUFFER_NB 2 - /** * vu_packet_check_range() - Check if a given memory zone is contained in * a mapped guest memory region @@ -177,13 +175,14 @@ static void vu_handle_tx(struct vu_dev *vdev, int index, count = 0; out_sg_count = 0; - while (count < VIRTQUEUE_MAX_SIZE && - out_sg_count + VU_MAX_TX_BUFFER_NB <= VIRTQUEUE_MAX_SIZE) { - int ret; + while (count < ARRAY_SIZE(elem) && + out_sg_count < ARRAY_SIZE(out_sg)) { struct iov_tail data; + int ret; ret = vu_queue_pop(vdev, vq, &elem[count], NULL, 0, - &out_sg[out_sg_count], VU_MAX_TX_BUFFER_NB); + &out_sg[out_sg_count], + ARRAY_SIZE(out_sg) - out_sg_count); if (ret < 0) break; out_sg_count += elem[count].out_num; -- 2.53.0