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=202606 header.b=ZwLNq+ig; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 4C8065A0265 for ; Thu, 02 Jul 2026 04:37:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202606; t=1782959865; bh=lAiLhPRkxhDBNIFbcW6hBlfb2eEt0oe8V2PJvjBolJQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZwLNq+ig0QXGl3x+JpNtISoata5B+YJeZMUdxjjNdMRaTbScgcGMHD8exkqCoEpth s5XOg+unt51Ca8X2pLKYj1DNdCQdKxlvqXbWEuV5CLfrxZm4exgQSTYEQUiX/a3EF/ T7jrvXJO68AClQQMgWTF4bgVhcFt6DqZBdplnK9aFhhdkMdugimOcaC64tmcPdHdzE I8oJE516o+9UUv7ozNIqAJM3WqWxXf7LSemTD0eeKKPyL94XvX1fN6k7yh2Nof/zId Kp+VcTYy+ovkoiUP7hn2lk/wmrGdiGX/Pkde0rXyWw+htjpg+U6Nj4A8+ioUeoDoWF CqlNa5iPxRcrA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4grLdj6wwTz58mh; Thu, 02 Jul 2026 12:37:45 +1000 (AEST) Date: Thu, 2 Jul 2026 12:37:36 +1000 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH 4/8] udp_vu: Make virtqueue buffers stack-local for thread safety Message-ID: References: <20260616171052.3785909-1-lvivier@redhat.com> <20260616171052.3785909-5-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ezoME5wH1+kd+zZg" Content-Disposition: inline In-Reply-To: <20260616171052.3785909-5-lvivier@redhat.com> Message-ID-Hash: CNM3OZPQ32DEDR2TY4BQKTCHX4KL4DUD X-Message-ID-Hash: CNM3OZPQ32DEDR2TY4BQKTCHX4KL4DUD 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: --ezoME5wH1+kd+zZg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jun 16, 2026 at 07:10:48PM +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 I generally dislike static locals anyway, though they have their uses. I'd be happy to see this applied independent of the rest of the series. > --- > udp_vu.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/udp_vu.c b/udp_vu.c > index 864e7a99b8d9..342673dc7e6d 100644 > --- a/udp_vu.c > +++ b/udp_vu.c > @@ -146,8 +146,8 @@ 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]; > - static struct iovec iov_vu[VIRTQUEUE_MAX_SIZE]; > + struct vu_virtq_element elem[VIRTQUEUE_MAX_SIZE]; > + struct iovec iov_vu[VIRTQUEUE_MAX_SIZE]; Nit, this needs a little re-ordering to preserve the reverse christmas tree. > int rx_queue =3D QPAIR_TOGUEST_QUEUE(qpair); > struct vu_dev *vdev =3D c->vdev; > struct vu_virtq *vq =3D &vdev->vq[rx_queue]; > --=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 --ezoME5wH1+kd+zZg Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmpFzuoACgkQzQJF27ox 2Gcd9Q//c7Y1oeOXmLyztJSK+mFDsSvzEux4ZmoaltFOIf8z+l9jCzXRaLu5cmcg K5q/23dyiuZqe6rkZQJ++DMXJm2l8jz/VpLOJ1kykDxyVo80z/c71JNMZMufB92m GcIjrR+it3BH1IsOA1UZy4GDfbYUQIc0R51CUkkbaVuPZ39GjxdmU8UrvNZJFImm TYfiJ1v4zAPeiS60HsGuszFYmkcqRj6A6FQ5GMrlpzsGc61sRUJ7gpdz4ccPjbp9 UHnfB39+0btp2AOQJEQnSVq3ifDCipvJMQ55p/XIYn3MAEc8VN04zpGBlDK1lG5k Df9q0QsdyNgXGJigB2zPGy6dOB12/pv8esI46RbcbzBESFKu9Q4wYdWOAtQonJvf g7LqofLn9iHlA/YaVDOANsx5HPmrlImlWknfx+m8/8lrWFl3wF4sRo2K0sDOaq26 DqQJ8IlLCNWEC9+IL+Y8G+M1OogbM0ia7cIeinTuuneWBYiJmY33EsJ36jDREDag UXjVPodtrIS3Y2v6ShhyT3yKYJw+7Bdc9JQhku8dKcPnUsQHFgLin0dhv9K+Ha7b VYYe80XIX3FmD3TUM59gQU/52WI4wHKDGyLmxZMQnf53J7EI5+psF4Xn0W7vz8kH zFbSetxcz54ZDFx/OJ7oJ7S/Kfup6nsGzlcNh/D/ms6e8R9GJlg= =aioG -----END PGP SIGNATURE----- --ezoME5wH1+kd+zZg--