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=c4fQ6UqK; 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 68B6A5A0265 for ; Fri, 13 Mar 2026 08:21:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773386504; 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=c4fQ6UqKFnioznTUOAX/HOR0mGkNDLNLV0OYSDLy5xAYUS2gCWYUBHHapWLTOQiiIxZjcy kJ8YN7GU9aklf0HEhReJJ5Imsxp8oW1jt843uzQ/b3jjDq+RPOQThUzoF4fcWjXrn5xslb HCNI7c/uiTO0sPCr52iV5T2WfB6eb9I= 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-264-q3H7n5G4MfC6iSgYjHU6ow-1; Fri, 13 Mar 2026 03:21:42 -0400 X-MC-Unique: q3H7n5G4MfC6iSgYjHU6ow-1 X-Mimecast-MFC-AGG-ID: q3H7n5G4MfC6iSgYjHU6ow_1773386502 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 EEEAD18005BF for ; Fri, 13 Mar 2026 07:21:41 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.44.35.65]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E208A19540C2; Fri, 13 Mar 2026 07:21:40 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH 2/3] vu_handle_tx: Pass actual remaining out_sg capacity to vu_queue_pop() Date: Fri, 13 Mar 2026 08:21:35 +0100 Message-ID: <20260313072136.4075535-3-lvivier@redhat.com> In-Reply-To: <20260313072136.4075535-1-lvivier@redhat.com> References: <20260313072136.4075535-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: YbMhcSd2sAkV-WoVrgvQ7DB6sRXWKQEH0eZa-Wq8W7s_1773386502 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: RZMZX3QLH5L4MWRZA5GV4JBZY56Y4VNK X-Message-ID-Hash: RZMZX3QLH5L4MWRZA5GV4JBZY56Y4VNK 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