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=202608 header.b=ODZw1Vsl; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id D146D5A026D for ; Mon, 03 Aug 2026 08:11:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202608; t=1785737502; bh=3o+UFT3gS0y/yU0u04dbyqOXmJpqJ/7RemCVnbzKKa4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ODZw1VslO7Vim2J8s/t7SVozbMS4dRwJruNMiK1F79eXbuiiOkGZdkSQ76C3eVKDr H0hYGBjq5bYI5nF95iOTgq5egRshk4BFb9/I+W7D0nnqD1OVfRxlm5hm73CgGMJYn0 KtOwOliZbMPKTjJnf/O9uDZnOEHUwk63Z2zPJfxJomwKrj6W4NSv2sVM4z97JtEMzM 3aMCnqku+Zk1oGbqwHb54o8CrT7Xo3kfCRiVFR6b2gs1Bg85wMXZfM9E5QDjVCi9Zj qAiqG8cgRNDZRpt9mUf1FiQCpSpL+OHwUFk9otd5NwUkyTNs+4k/4k1kT82trxqJwr rBaEHuqSb82qg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4hD5sp59Sdz4wCJ; Mon, 03 Aug 2026 16:11:42 +1000 (AEST) Date: Mon, 3 Aug 2026 16:00:01 +1000 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH v2 04/10] udp_vu: Make virtqueue buffers stack-local for thread safety Message-ID: References: <20260731162329.3552800-1-lvivier@redhat.com> <20260731162329.3552800-5-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="He3JPLSNp3sBH+yQ" Content-Disposition: inline In-Reply-To: <20260731162329.3552800-5-lvivier@redhat.com> Message-ID-Hash: Q6AB43OT6TCJ6UGV72N2XTI6FZCN4Y6Z X-Message-ID-Hash: Q6AB43OT6TCJ6UGV72N2XTI6FZCN4Y6Z 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 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: --He3JPLSNp3sBH+yQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jul 31, 2026 at 06:23:23PM +0200, Laurent Vivier wrote: > The function-local static buffers elem[] and iov_vu[] in > udp_vu_sock_to_tap() are shared across all threads. When multiple > worker threads process UDP vhost-user data concurrently, they would > stomp on each other's buffers. >=20 > Remove the static qualifier so each call gets its own stack-allocated > arrays, eliminating cross-thread sharing. >=20 > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > udp_vu.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/udp_vu.c b/udp_vu.c > index 21fa891b3b51..c045e421001c 100644 > --- a/udp_vu.c > +++ b/udp_vu.c > @@ -151,9 +151,9 @@ void udp_vu_sock_to_tap(const struct ctx *c, int s, i= nt n, flow_sidx_t tosidx, > { > const struct flowside *toside =3D flowside_at_sidx(tosidx); > bool v6 =3D !(inany_v4(&toside->eaddr) && inany_v4(&toside->oaddr)); > - static struct vu_virtq_element elem[VIRTQUEUE_MAX_SIZE]; > + struct vu_virtq_element elem[VIRTQUEUE_MAX_SIZE]; > + struct iovec iov_vu[VIRTQUEUE_MAX_SIZE]; > int toguest =3D QPAIR_TOGUEST_QUEUE(qpair); > - static struct iovec iov_vu[VIRTQUEUE_MAX_SIZE]; > struct vu_dev *vdev =3D c->vdev; > struct vu_virtq *vq =3D &vdev->vq[toguest]; > size_t hdrlen =3D udp_vu_hdrlen(v6); > --=20 > 2.54.0 >=20 --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --He3JPLSNp3sBH+yQ Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmpwLl0ACgkQzQJF27ox 2Gdg/g//b1krW3pS5rEKGjaLW6ClDi9PA7UqsdPHD16NGGxibCFK5JKcStNNvCNE PlJ2PFIz9A9VBCCjuhNqGIG5ZpfdD0HIvwHASSTaHz7IYU5ZZHoJ+o6qoDDkAqc9 T/7Gl5QnhSlmLPcR8sxaqA0d9Qy3RbadmtnBfc/DJZ38ExAeeD9DRPZs924dmFh4 lUS7WZ6KV09sJ64/kkk5yzi2XpPAp5Nl5+GObZ9r8tnU+C5DHK+duMZ53HLV1EEV GWl1A/+/EHUMfKygY+FYxZFaTALPBeO+dVrlj84nLdKWCqSrrqNpocG+FPXQ1xs6 BnL3E9Jx0a9Gtj7CEL9UTod896lDvSN8qdc0uJYOCyniEIB5SbFjtGHzFJfTV+KJ aLqakGT6ZwJO/wG1sM+ORXNr2Q8ppKitiZlQOkdoSYU69csfdjX3so/klSy0qsVz KCoLuOxJDS8/aGqdZOrHgXLssChSy7VnM1kdEW8UHaN2d2Rrrn+L0p8Av8RKVaeQ MfBvMV9zZHbsQRUp2xUshaiXI3esaAnJ9cz9zoobOUODAhukTVFjQNspO/nSfoe8 hhuRRyzy13sm2KWGe7yQs4xY9LFdUrJfMSA4lv9FNQ4VRhTBoOl7QUqFNK/tZ8J4 4rWqZOi7apunh1GfsZPVH2LJt1lvDpoGeS3Adti2RIpp0cwHwWQ= =lrvK -----END PGP SIGNATURE----- --He3JPLSNp3sBH+yQ--