From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202602 header.b=eHYxqQdy; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id BBCE45A061B for ; Mon, 02 Mar 2026 01:13:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1772410422; bh=j3SGr1N06v0MyDu1NiuBfgmXE4ci6Xtnz/3vRgzU1Lo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eHYxqQdyxbw7ebq/1/jum+X4Zx/f5gBRwsCkM/rDhNjGlZK7IX+ya9eQbKVwfH5ik 91t5MVtmgrqhesze5lXGAvjirFyiw7uT6+PcXZU+4pD1+HggtWzNMyg4s2/WEVIcwH hqFCV6FxYhOCylLxND1j1xVWaVnMigrbWlf9CCJXYM3i0q0rw7zMers3KLDhrJcul9 p/eC/ThYssOWIdqDsLC8bTfDAZwMf6mWfTpAqoXkgn4p2OESZHmDB+S+dgVsskC9g9 kl+yzgyCj/h/cMBQM+F9BeKozfvUd4HYTTgjIOyDExrp9X9zmh1Ut3TRhRF0Ch0lm/ zQ1y5o/g0NjXw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4fPKCp44YTz4w9y; Mon, 02 Mar 2026 11:13:42 +1100 (AEDT) Date: Mon, 2 Mar 2026 10:48:34 +1100 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH 02/12] vhost-user: Use ARRAY_SIZE(elem) instead of VIRTQUEUE_MAX_SIZE Message-ID: References: <20260227140330.2216753-1-lvivier@redhat.com> <20260227140330.2216753-3-lvivier@redhat.com> MIME-Version: 1.0 In-Reply-To: <20260227140330.2216753-3-lvivier@redhat.com> X-MailFrom: dgibson@gandalf.ozlabs.org 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 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="jKZO8avgPe7ke8Ya" Content-Disposition: inline Message-ID-Hash: SV42DTRX3QRVTUDAQQPF6Q3DDKLJIGP2 X-Message-ID-Hash: SV42DTRX3QRVTUDAQQPF6Q3DDKLJIGP2 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: passt-dev@passt.top 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: --jKZO8avgPe7ke8Ya Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Feb 27, 2026 at 03:03:20PM +0100, Laurent Vivier wrote: > When passing the element count to vu_init_elem(), vu_collect(), or using > it as a loop bound, use ARRAY_SIZE(elem) instead of the VIRTQUEUE_MAX_SIZ= E. >=20 > No functional change. >=20 > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > tcp_vu.c | 6 +++--- > udp_vu.c | 4 ++-- > vu_common.c | 6 +++--- > 3 files changed, 8 insertions(+), 8 deletions(-) >=20 > diff --git a/tcp_vu.c b/tcp_vu.c > index bb05fbf45826..98e5974fee0e 100644 > --- a/tcp_vu.c > +++ b/tcp_vu.c > @@ -201,17 +201,17 @@ static ssize_t tcp_vu_sock_recv(const struct ctx *c= , struct vu_virtq *vq, > =20 > =09hdrlen =3D tcp_vu_hdrlen(v6); > =20 > -=09vu_init_elem(elem, &iov_vu[DISCARD_IOV_NUM], VIRTQUEUE_MAX_SIZE); > +=09vu_init_elem(elem, &iov_vu[DISCARD_IOV_NUM], ARRAY_SIZE(elem)); > =20 > =09elem_cnt =3D 0; > =09*head_cnt =3D 0; > -=09while (fillsize > 0 && elem_cnt < VIRTQUEUE_MAX_SIZE) { > +=09while (fillsize > 0 && elem_cnt < ARRAY_SIZE(elem)) { > =09=09struct iovec *iov; > =09=09size_t frame_size, dlen; > =09=09int cnt; > =20 > =09=09cnt =3D vu_collect(vdev, vq, &elem[elem_cnt], > -=09=09=09=09 VIRTQUEUE_MAX_SIZE - elem_cnt, > +=09=09=09=09 ARRAY_SIZE(elem) - elem_cnt, > =09=09=09=09 MAX(MIN(mss, fillsize) + hdrlen, ETH_ZLEN + VNET_HLEN), > =09=09=09=09 &frame_size); > =09=09if (cnt =3D=3D 0) > diff --git a/udp_vu.c b/udp_vu.c > index 51f3718f5925..6f6477f7d046 100644 > --- a/udp_vu.c > +++ b/udp_vu.c > @@ -89,9 +89,9 @@ static int udp_vu_sock_recv(const struct ctx *c, struct= vu_virtq *vq, int s, > =09/* compute L2 header length */ > =09hdrlen =3D udp_vu_hdrlen(v6); > =20 > -=09vu_init_elem(elem, iov_vu, VIRTQUEUE_MAX_SIZE); > +=09vu_init_elem(elem, iov_vu, ARRAY_SIZE(elem)); > =20 > -=09iov_cnt =3D vu_collect(vdev, vq, elem, VIRTQUEUE_MAX_SIZE, > +=09iov_cnt =3D vu_collect(vdev, vq, elem, ARRAY_SIZE(elem), > =09=09=09 IP_MAX_MTU + ETH_HLEN + VNET_HLEN, NULL); > =09if (iov_cnt =3D=3D 0) > =09=09return -1; > diff --git a/vu_common.c b/vu_common.c > index aa14598ea028..7a8cd18f4e81 100644 > --- a/vu_common.c > +++ b/vu_common.c > @@ -174,7 +174,7 @@ static void vu_handle_tx(struct vu_dev *vdev, int ind= ex, > =20 > =09count =3D 0; > =09out_sg_count =3D 0; > -=09while (count < VIRTQUEUE_MAX_SIZE && > +=09while (count < ARRAY_SIZE(elem) && > =09 out_sg_count + VU_MAX_TX_BUFFER_NB <=3D VIRTQUEUE_MAX_SIZE) { > =09=09int ret; > =09=09struct iov_tail data; > @@ -259,10 +259,10 @@ int vu_send_single(const struct ctx *c, const void = *buf, size_t size) > =09=09return -1; > =09} > =20 > -=09vu_init_elem(elem, in_sg, VIRTQUEUE_MAX_SIZE); > +=09vu_init_elem(elem, in_sg, ARRAY_SIZE(elem)); > =20 > =09size +=3D VNET_HLEN; > -=09elem_cnt =3D vu_collect(vdev, vq, elem, VIRTQUEUE_MAX_SIZE, size, &to= tal); > +=09elem_cnt =3D vu_collect(vdev, vq, elem, ARRAY_SIZE(elem), size, &tota= l); > =09if (total < size) { > =09=09debug("vu_send_single: no space to send the data " > =09=09 "elem_cnt %d size %zd", elem_cnt, total); > --=20 > 2.53.0 >=20 --=20 David Gibson (he or they)=09| I'll have my music baroque, and my code david AT gibson.dropbear.id.au=09| minimalist, thank you, not the other way =09=09=09=09| around. http://www.ozlabs.org/~dgibson --jKZO8avgPe7ke8Ya Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmmk0FIACgkQzQJF27ox 2GfrHRAApHoRZlE19E2FQsvqnI2DMSsyuD6/GLxRarLR+OQ4NE9ZjC+6xPj6B4xS ZPeLPbvsHhR7wYHpsWBy/LihDuiRO640XaVQ561Ip6DIy3I1HBCufnQb4CxFKKPE ZkvPpgmW3DhU5N8XkEHUA3N7W6JAGLZIii0eag+TOz9DUbNYlDl8/Tcy33zP4a0w vXyr6i9gyM3pumV/dBsZ9PWIBxx91E2LcJ0/Yb5+mg8+Ff8V/f2ysoH6JbIf/6f1 WFO2einr0QuA6ZEjvhVMd7N4nL1mCe+F5JFKH4boezNj/zNjGqhksvecEH0uePUz quE4hgSLpRozPOc9wlSBtAyL6R7Mcs5I7rVr+n7xjdYIp3UxGgv2Drf0Dk4gyP0D TZzW3wllg+sbTxj5OG6E8NJQ4DAXKIrxStJHHwmlh9MG1mGLAEb8B01wELv53stW bzQ/eTlWWHnLZsuEAP9GyxPsowBzVwlP72fYWzt2TgLR+QhBH7e81JdhTQAK/YOG XVySJOiq5eQ2U5LkbKRdviWsOhC6JnpThw77D4+10wKlvLXnt8wILodndNFfqh40 omQniCcRfATnBXc2UXh7md1nYj3lzg0WNfAihMLuXoLgV/Bsq+xMELRNwAbKKDXP i34Co3+Zewb0IhjY++GLGkj0yttclslsib6/sFhRzi5GXL3heL8= =wc1W -----END PGP SIGNATURE----- --jKZO8avgPe7ke8Ya--