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=laoxDXZZ; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 6B87D5A026E for ; Fri, 14 Aug 2026 08:52:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202608; t=1786690355; bh=VA7rbWOFoDTiRsOigs8NBS9AawSA9m0+NU5md7qjfXo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=laoxDXZZwPZDidKoIWYj6rtrs+2scsBvD/z4wEc3XcwprTzjntm+isQbRb4SCI2tk L8N/WXXpCtrrvDVroYKlgBi/ECKDJoDVhIEWPAfIFcfn+IyudnDj98xGlRcWn44+QV oXgZd0eO2roKIdnWuOSUmlZVnBfn62I/wX9ODnh0DTMl2kcUwrg188Z8ls1ed4XmD6 Z9SLWjqH45rvs63Pdvah0TMvg72uyzx7651Mb4U75JBzjaSJcysNoGTxx9KFFInASh AFIqZ48GGUMnOeI9Oo8fBsbqmb/+MBDxbzEwEhzBxwHiaF6/6g1AD9+dHUUGizCuXc fxu7TczNhrqjg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4hLtFv02Y4z4wJK; Fri, 14 Aug 2026 16:52:34 +1000 (AEST) Date: Fri, 14 Aug 2026 16:33:18 +1000 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH 4/7] flow: Delegate epoll file descriptor management to threading subsystem Message-ID: References: <20260731164628.3556997-1-lvivier@redhat.com> <20260731164628.3556997-5-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="maH9aBg2RRO6Qiw2" Content-Disposition: inline In-Reply-To: <20260731164628.3556997-5-lvivier@redhat.com> Message-ID-Hash: T66GCJ7ARCKRFLG26MIK7RLKMIMHWMOO X-Message-ID-Hash: T66GCJ7ARCKRFLG26MIK7RLKMIMHWMOO 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: --maH9aBg2RRO6Qiw2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jul 31, 2026 at 06:46:25PM +0200, Laurent Vivier wrote: > Remove the flow-local epoll_id_to_fd mapping array and instead > rely on the threading subsystem to provide the epoll file descriptor > for a given thread number. >=20 > Update all protocol handlers (ICMP, TCP, TCP splice, UDP). >=20 > Signed-off-by: Laurent Vivier > --- > flow.c | 17 +++++++++-------- > flow.h | 4 +--- > passt.c | 2 +- > tcp.c | 3 ++- > 4 files changed, 13 insertions(+), 13 deletions(-) >=20 > diff --git a/flow.c b/flow.c > index 3012a07ed680..7821b3f91285 100644 > --- a/flow.c > +++ b/flow.c > @@ -24,6 +24,7 @@ > #include "repair.h" > #include "epoll_ctl.h" > #include "serialise.h" > +#include "threading.h" > =20 > const char *flow_state_str[] =3D { > [FLOW_STATE_FREE] =3D "FREE", > @@ -221,7 +222,6 @@ static_assert(ARRAY_SIZE(flow_epoll) =3D=3D FLOW_NUM_= TYPES, > unsigned flow_first_free; > union flow flowtab[FLOW_MAX]; > static _Thread_local const union flow *flow_new_entry; /* =3D NULL */ > -int qpair_to_fd[FLOW_QPAIR_SIZE]; > =20 > /* Hash table to index it */ > #define FLOW_HASH_LOAD 70 /* % */ > @@ -457,7 +457,12 @@ static void flow_set_state(struct flow_common *f, en= um flow_state state) > */ > int flow_epollfd(const struct flow_common *f) > { > - return qpair_to_fd[f->qpair]; > + /* mapping 1:1 between qpair and threadid > + * return threading_epollfd(f->qpair); > + * but for the moment we have only one thread > + */ > + (void)f; > + return threading_epollfd(THREADING_ID_DEFAULT); This seems like it's going backwards, always using thread 0's epollfd, rather than choosing the right thread based on the qpair. > } > =20 > /** > @@ -525,7 +530,7 @@ bool flow_migrate_epollfd(struct flow_common *f, unsi= gned int qpair, > flow_trace((union flow *)f, > "migrating from qpair %d to %d", qpair, target); > =20 > - epoll_del(qpair_to_fd[qpair], ref.fd); > + epoll_del(threading_epollfd(qpair), ref.fd); > flow_setqp(f, target); > flow_epoll_set(f, EPOLL_CTL_ADD, events, ref.fd, ref.flowside.sidei); > ret =3D true; > @@ -1444,9 +1449,8 @@ int flow_migrate_target(struct ctx *c, const struct= migrate_stage *stage, > =20 > /** > * flow_init() - Initialise flow related data structures > - * @c: Execution context > */ > -void flow_init(const struct ctx *c) > +void flow_init(void) > { > unsigned b; > =20 > @@ -1456,7 +1460,4 @@ void flow_init(const struct ctx *c) > =20 > for (b =3D 0; b < FLOW_HASH_SIZE; b++) > flow_hashtab[b] =3D FLOW_SIDX_NONE; > - > - for (b =3D 0; b < FLOW_QPAIR_SIZE; b++) > - qpair_to_fd[b] =3D c->epollfd; > } > diff --git a/flow.h b/flow.h > index c31a51a9cc96..e2693efd0f70 100644 > --- a/flow.h > +++ b/flow.h > @@ -157,8 +157,6 @@ struct flowside { > in_port_t eport; > }; > =20 > -extern int qpair_to_fd[]; > - > /** > * flowside_eq() - Check if two flowsides are equal > * @left, @right: Flowsides to compare > @@ -266,7 +264,7 @@ flow_sidx_t flow_lookup_sa(const struct ctx *c, uint8= _t proto, uint8_t pif, > =20 > union flow; > =20 > -void flow_init(const struct ctx *c); > +void flow_init(void); > int flow_epollfd(const struct flow_common *f); > int flow_epoll_set(const struct flow_common *f, int command, uint32_t ev= ents, > int fd, unsigned int sidei); > diff --git a/passt.c b/passt.c > index 2cedb7ba0756..57290a5a7c6e 100644 > --- a/passt.c > +++ b/passt.c > @@ -399,7 +399,7 @@ int main(int argc, char **argv) > if (clock_gettime(CLOCK_MONOTONIC, &now)) > die_perror("Failed to get CLOCK_MONOTONIC time"); > =20 > - flow_init(c); > + flow_init(); > fwd_scan_ports_init(c); > =20 > if ((!c->no_udp && udp_init(c)) || (!c->no_tcp && tcp_init(c))) > diff --git a/tcp.c b/tcp.c > index 2767a8494107..e8da65410bcf 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -317,6 +317,7 @@ > #include "tcp_buf.h" > #include "tcp_vu.h" > #include "epoll_ctl.h" > +#include "threading.h" > =20 > /* > * The size of TCP header (including options) is given by doff (Data Off= set) > @@ -2721,7 +2722,7 @@ void tcp_timer_handler(const struct ctx *c, union e= poll_ref ref, > assert(conn->f.type =3D=3D FLOW_TCP); > =20 > if (conn->f.qpair !=3D qpair) { > - int old_epollfd =3D qpair_to_fd[qpair]; > + int old_epollfd =3D threading_epollfd(qpair); > =20 > epoll_del(old_epollfd, conn->timer); > if (tcp_timer_epoll_add(conn, conn->timer, now) < 0) { > --=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 --maH9aBg2RRO6Qiw2 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmp+tp8ACgkQzQJF27ox 2Ge/fA//d8q+ORamihDG/DFX8VTHoiCoeEK9ElnOZ7gPiuynl4GusYKmFFEDk/eZ NmGX6Hpw6eeQq4C4L/dvxst39HjNEzkGik8Zunhl7xyDcHxC1G5eLBWgAwi++p1i 2riRUUUZXtyN372UsMf8DrK2EqdQ6spzuhWP7O/yk+4zofCta1AkjTWQsy24xW9+ n2PBGEw0KX5K9XnbUpxpkIjVOVgsshStgUXPL4sHDxwbX945otuUHNxU4g6KuTpo C/1qcfIZEnLwzO3j+DdJBFez8CkBgNPyxzV8Z94S7RvqrUSv1CA7WcJSod3wG/Pn pWpJqUhok7rq9lddVbhkP3k6jCK3nr/kOHEZWko+IFteKuhfkx4qVcBlFtJ/i6PD 8p4Tmmh1ULbGlr6VmFCMxdVspMkePVcl8D9hl8ztPbdtNt4NsYdh7sBjyy7QGXth km8UibeQR5A93yiKMncRFe2fCIo0RBC2b47p/YdxZ0QHPEBJQEWA3yHYpoNdfnKV NzOPht6BV5IgtlMdWpFQVLAsyN/63qNKUOVWOIbTOX38CdW0KB6cNadISMxZAH8S ma9Q30ClWSHvPpRNEExP7ngJSZD3cl3MYF08WUBeMN1KC/vrEeFc51ZmG3GjNd8u d9+HreUJ+vfeQQGRnyg4Dh3AzxpNHJMVHv9N8qaA3fzj4EfGLcM= =BHPM -----END PGP SIGNATURE----- --maH9aBg2RRO6Qiw2--