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=HBiczqiK; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 6BCF85A0269 for ; Mon, 03 Aug 2026 07:43:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202608; t=1785735811; bh=SCGSMVIFG+f+37HKmi+qtx/JnWWIyU952xHuuraLPG0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HBiczqiKCf35MndYhGXW/A1X2BYIeJedsJN/Ydi8kEUL/uIf9nmQCcWK4i5uYmZlx viZkYgnXCrjbaO7G9r58I1daQ5miEKLqTBy/jeKA1E/nPYCyMh+kXtRXPBFYkr/xT9 IOSwnSxvKy+oAo92jdzRX+EY8CX+qfS+IPtXq/zujnc5ZSNRBujcTlFnRnmDpscgcQ gnkUN9G5QfDJj0qZ7xjlVCeAKPvHZc1/r+PvX93b8MIbCrbO23bL+r0cIY1jbOPt+a /veTvdRflUtlrP+QzgWMpwEIi9dINtgZFOY63wpo+WZsCddLeGgvozv6XeEkmwDcYU rlU9pd8joz2XQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4hD5FH2y0Lz4wC6; Mon, 03 Aug 2026 15:43:31 +1000 (AEST) Date: Mon, 3 Aug 2026 15:43:15 +1000 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH v2 02/10] tap: Make L4 sequence pools per-qpair for thread safety Message-ID: References: <20260731162329.3552800-1-lvivier@redhat.com> <20260731162329.3552800-3-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="sbfDemeoBcTaKwZf" Content-Disposition: inline In-Reply-To: <20260731162329.3552800-3-lvivier@redhat.com> Message-ID-Hash: 5BNOOFRVAZM3YKSPJVVR2UHKBXOCRER7 X-Message-ID-Hash: 5BNOOFRVAZM3YKSPJVVR2UHKBXOCRER7 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: --sbfDemeoBcTaKwZf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jul 31, 2026 at 06:23:21PM +0200, Laurent Vivier wrote: > The L4 sequence arrays tap4_l4[] and tap6_l4[] are used to batch > packets with the same L4 tuple within a single tap_handler() call. > They are global, but tap_handler() can be called concurrently from > different worker threads with different qpairs in vhost-user mode. >=20 > Make these arrays per-qpair by adding a VHOST_USER_MAX_VQS/2 first > dimension, indexed by the qpair parameter already available in > tap4_handler() and tap6_handler(). >=20 > Update tap_sock_update_pool() to initialize all qpair*seq entries. >=20 > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > tap.c | 32 +++++++++++++++++++------------- > 1 file changed, 19 insertions(+), 13 deletions(-) >=20 > diff --git a/tap.c b/tap.c > index 6bba436f148f..25cde67538ac 100644 > --- a/tap.c > +++ b/tap.c > @@ -591,7 +591,7 @@ static struct tap4_l4_t { > struct in_addr daddr; > =20 > struct pool_l4_t p; > -} tap4_l4[TAP_SEQS /* Arbitrary: TAP_MSGS in theory, so limit in users *= /]; > +} tap4_l4[VHOST_USER_MAX_VQS / 2][TAP_SEQS /* Arbitrary: TAP_MSGS in the= ory, so limit in users */]; > =20 > /** > * struct l4_seq6_t - Message sequence for one protocol handler call, IP= v6 > @@ -618,7 +618,7 @@ static struct tap6_l4_t { > uint8_t hop_limit; > =20 > struct pool_l4_t p; > -} tap6_l4[TAP_SEQS /* Arbitrary: TAP_MSGS in theory, so limit in users *= /]; > +} tap6_l4[VHOST_USER_MAX_VQS / 2][TAP_SEQS /* Arbitrary: TAP_MSGS in the= ory, so limit in users */]; > =20 > /** > * tap_packet_debug() - Print debug message for packet(s) from guest/tap > @@ -838,7 +838,7 @@ resume: > if (seq_count =3D=3D TAP_SEQS) > break; /* Resume after flushing if i < pool_tap4[qpair]->count */ > =20 > - for (seq =3D tap4_l4 + seq_count - 1; seq >=3D tap4_l4; seq--) { > + for (seq =3D tap4_l4[qpair] + seq_count - 1; seq >=3D tap4_l4[qpair]; = seq--) { > if (L4_MATCH(iph, uh, seq)) { > if (seq->p.count >=3D UIO_MAXIOV) > seq =3D NULL; > @@ -846,8 +846,8 @@ resume: > } > } > =20 > - if (!seq || seq < tap4_l4) { > - seq =3D tap4_l4 + seq_count++; > + if (!seq || seq < tap4_l4[qpair]) { > + seq =3D tap4_l4[qpair] + seq_count++; > L4_SET(iph, uh, seq); > pool_flush((struct pool *)&seq->p); > } > @@ -859,7 +859,7 @@ append: > packet_add((struct pool *)&seq->p, &data); > } > =20 > - for (j =3D 0, seq =3D tap4_l4; j < seq_count; j++, seq++) { > + for (j =3D 0, seq =3D tap4_l4[qpair]; j < seq_count; j++, seq++) { > const struct pool *p =3D (const struct pool *)&seq->p; > size_t k; > =20 > @@ -1088,7 +1088,7 @@ resume: > if (seq_count =3D=3D TAP_SEQS) > break; /* Resume after flushing if i < pool_tap6[qpair]->count */ > =20 > - for (seq =3D tap6_l4 + seq_count - 1; seq >=3D tap6_l4; seq--) { > + for (seq =3D tap6_l4[qpair] + seq_count - 1; seq >=3D tap6_l4[qpair]; = seq--) { > if (L4_MATCH(ip6h, proto, uh, seq)) { > if (seq->p.count >=3D UIO_MAXIOV) > seq =3D NULL; > @@ -1096,8 +1096,8 @@ resume: > } > } > =20 > - if (!seq || seq < tap6_l4) { > - seq =3D tap6_l4 + seq_count++; > + if (!seq || seq < tap6_l4[qpair]) { > + seq =3D tap6_l4[qpair] + seq_count++; > L4_SET(ip6h, proto, uh, seq); > pool_flush((struct pool *)&seq->p); > } > @@ -1109,7 +1109,7 @@ append: > packet_add((struct pool *)&seq->p, &data); > } > =20 > - for (j =3D 0, seq =3D tap6_l4; j < seq_count; j++, seq++) { > + for (j =3D 0, seq =3D tap6_l4[qpair]; j < seq_count; j++, seq++) { > const struct pool *p =3D (const struct pool *)&seq->p; > size_t k; > =20 > @@ -1602,9 +1602,15 @@ static void tap_sock_update_pool(void *base, size_= t size) > pool_tap6[i] =3D (struct pool *)&pool_tap6_storage[i]; > } > =20 > - for (i =3D 0; i < TAP_SEQS; i++) { > - tap4_l4[i].p =3D PACKET_INIT(pool_l4, UIO_MAXIOV, base, size); > - tap6_l4[i].p =3D PACKET_INIT(pool_l4, UIO_MAXIOV, base, size); > + for (i =3D 0; i < VHOST_USER_MAX_VQS / 2; i++) { > + unsigned int j; > + > + for (j =3D 0; j < TAP_SEQS; j++) { > + tap4_l4[i][j].p =3D PACKET_INIT(pool_l4, UIO_MAXIOV, > + base, size); > + tap6_l4[i][j].p =3D PACKET_INIT(pool_l4, UIO_MAXIOV, > + base, size); > + } > } > } > =20 > --=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 --sbfDemeoBcTaKwZf Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmpwKnIACgkQzQJF27ox 2GcJ9A//TtBW9VnvV3VcqXDwEOE8eBOA9b2cYZ2qMAiSgBX58Y5GoQBwBBI/jnRl 1jGt1voGt/K454SKB/s65cv/gJVixf8EZiar/BWXOASzBfpKqCKMQSBT1Q3OtfAD AKpJvHMaJMw5hGCNQ3HKckoo+V0KfN8o5xJcIEYz7sQ/wjO5+gM9yiJJbJMiNt7T qeqitXneDHSCSZFBjxyGPm9A3XkHljxUyjJ7uhA25kVT3vLguxtXTzs12s08+l9b omzGwvqbWjgIPkGZmoS6pxPnkxxp8bQf2MNpBfrR/MnE275aYdZi/jyFdtjEwzK6 Gtf+2YMCly/qEdS8gXtiLn8Ndytd9y0zdMa7wWI7poyEYlpXL7IrC4SbmrpU6lQi 8SN0gWEr+uelyUd5tnLAn70ckRQdGWFL0ixJVE8Upc2rP3J+iLEvysWfAdflotdc og2epOWklCl0W/It1IrwCUhpZMeQRcWcpYhQqd/EhGitQaEMTfTrKJU6gcMpjsCI AvC1i01fIyyFOGvmEXVsDRHhvnnvR5A+3g+8zVPcjQGOlHhZiynxkF5OlLGXpbEo 10BT+ATcIMqioT9ROsed4D7Rhxa8oFfj7HR63xBA2CEoNdhbEGM0Y0HAhEuTfxKx fpj9yqE0Pfz9B++iXq95nsnPx7FUTNnyWSYHJZRxUPExWCWa5lQ= =cUUY -----END PGP SIGNATURE----- --sbfDemeoBcTaKwZf--