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=lI9xCJjX; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id B65855A0265 for ; Fri, 14 Aug 2026 08:52:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202608; t=1786690355; bh=QwM1HuZEkemADW9URcnDsaGav9lUb1vB2xXFdfXDoA8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lI9xCJjX79TsfDuEy1Bh39D9jWGIQ1/pPu60TuHJHOeunkvfr+FQrpGfLSAU3oU42 u4+JTXnLhNd8Z6LiiqFMtvYHA4rUJFL13pS3dcLOBPWyXmpOz5kvfgtgGjNxoXgq+k Ycl1AskdFGkSBFjqCH07RzX3rkN9zn1f0b/bGdalGp1X19x939tZ4Yu4RidFEj6feA Jd++7kKK9xU8pkgKKRR+TU0jrLaF5mXBJ3YdOtzxFdMMIsuucWCv045j+FdEoDXwpm v4hGaDZoYbaKEX91BiFdh7dZUtJ38fdiL9sFqGOqctIIgf+zEtcsOVuZa2NbvOj4U5 Ytoyoxbka8T5Q== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4hLtFv0CtQz4wJR; Fri, 14 Aug 2026 16:52:35 +1000 (AEST) Date: Fri, 14 Aug 2026 16:34:25 +1000 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH 5/7] ctx: Remove epollfd from context structure Message-ID: References: <20260731164628.3556997-1-lvivier@redhat.com> <20260731164628.3556997-6-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="3X/DP2REA0Md7yUt" Content-Disposition: inline In-Reply-To: <20260731164628.3556997-6-lvivier@redhat.com> Message-ID-Hash: WW2BTST32H7P6CQFGEYCV6F6S7ICHD5K X-Message-ID-Hash: WW2BTST32H7P6CQFGEYCV6F6S7ICHD5K 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: --3X/DP2REA0Md7yUt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jul 31, 2026 at 06:46:26PM +0200, Laurent Vivier wrote: > The main epoll file descriptor is now managed by the threading subsystem, > so there's no need to store it in the context structure. > All code that previously accessed c->epollfd now calls > threading_epollfd(THREADING_ID_DEFAULT) to get the main event loop's > epoll file descriptor. >=20 > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > conf.c | 10 +++++++--- > fwd.c | 4 +++- > netlink.c | 4 +++- > passt.c | 1 - > passt.h | 2 -- > pasta.c | 3 ++- > pif.c | 3 ++- > repair.c | 12 ++++++++---- > tap.c | 9 ++++++--- > tcp_splice.c | 1 + > vhost_user.c | 9 +++++---- > 11 files changed, 37 insertions(+), 21 deletions(-) >=20 > diff --git a/conf.c b/conf.c > index faf268140321..733bad4228cb 100644 > --- a/conf.c > +++ b/conf.c > @@ -53,6 +53,7 @@ > #include "pesto.h" > #include "serialise.h" > #include "parse.h" > +#include "threading.h" > =20 > #define NETNS_RUN_DIR "/run/netns" > =20 > @@ -1164,7 +1165,8 @@ static void conf_sock_listen(const struct ctx *c) > die_perror("Couldn't listen on configuration socket"); > =20 > ref.fd =3D c->fd_control_listen; > - if (epoll_add(c->epollfd, EPOLLIN | EPOLLET, ref)) > + if (epoll_add(threading_epollfd(THREADING_ID_DEFAULT), > + EPOLLIN | EPOLLET, ref)) > die_perror("Couldn't add configuration socket to epoll"); > } > =20 > @@ -2117,7 +2119,8 @@ static int conf_recv_rules(const struct ctx *c, int= fd) > static void conf_close(struct ctx *c) > { > debug("Closing configuration socket"); > - epoll_ctl(c->epollfd, EPOLL_CTL_DEL, c->fd_control, NULL); > + epoll_ctl(threading_epollfd(THREADING_ID_DEFAULT), EPOLL_CTL_DEL, > + c->fd_control, NULL); > close(c->fd_control); > c->fd_control =3D -1; > } > @@ -2180,7 +2183,8 @@ retry: > warn_perror("Can't get configuration client credentials"); > =20 > c->fd_control =3D ref.fd =3D fd; > - rc =3D epoll_add(c->epollfd, EPOLLIN | EPOLLET, ref); > + rc =3D epoll_add(threading_epollfd(THREADING_ID_DEFAULT), > + EPOLLIN | EPOLLET, ref); > if (rc < 0) { > warn_perror("epoll_ctl() on configuration socket"); > goto fail; > diff --git a/fwd.c b/fwd.c > index 5679a3d606ea..fa6679ea1b2e 100644 > --- a/fwd.c > +++ b/fwd.c > @@ -33,6 +33,7 @@ > #include "netlink.h" > #include "arp.h" > #include "ndp.h" > +#include "threading.h" > =20 > #define NEIGH_TABLE_SLOTS 1024 > #define NEIGH_TABLE_SIZE (NEIGH_TABLE_SLOTS / 2) > @@ -377,7 +378,8 @@ static int fwd_sync_one(const struct ctx *c, uint8_t = pif, unsigned idx, > /* We don't want to listen on this port */ > if (fd >=3D 0) { > /* We already are, so stop */ > - epoll_del(c->epollfd, fd); > + epoll_del(threading_epollfd(THREADING_ID_DEFAULT), > + fd); > close(fd); > socks[port - rule->first] =3D -1; > } > diff --git a/netlink.c b/netlink.c > index 8d20dbb57fb8..8fffe490b6f3 100644 > --- a/netlink.c > +++ b/netlink.c > @@ -37,6 +37,7 @@ > #include "ip.h" > #include "netlink.h" > #include "epoll_ctl.h" > +#include "threading.h" > =20 > /* Same as RTA_NEXT() but for nexthops: RTNH_NEXT() doesn't take 'attrle= n' */ > #define RTNH_NEXT_AND_DEC(rtnh, attrlen) \ > @@ -1292,7 +1293,8 @@ int nl_neigh_notify_init(const struct ctx *c) > } > =20 > ev.data.u64 =3D ref.u64; > - if (epoll_ctl(c->epollfd, EPOLL_CTL_ADD, nl_sock_neigh, &ev) =3D=3D -1)= { > + if (epoll_ctl(threading_epollfd(THREADING_ID_DEFAULT), EPOLL_CTL_ADD, > + nl_sock_neigh, &ev) =3D=3D -1) { > warn_perror("epoll_ctl() on neighbour notifier socket failed"); > close(nl_sock_neigh); > nl_sock_neigh =3D -1; > diff --git a/passt.c b/passt.c > index 57290a5a7c6e..469e2525f545 100644 > --- a/passt.c > +++ b/passt.c > @@ -376,7 +376,6 @@ int main(int argc, char **argv) > madvise(pkt_buf, sizeof(pkt_buf), MADV_HUGEPAGE); > =20 > threading_init(); > - c->epollfd =3D threading_epollfd(THREADING_ID_DEFAULT); > =20 > if (getrlimit(RLIMIT_NOFILE, &limit)) > die_perror("Failed to get maximum value of open files limit"); > diff --git a/passt.h b/passt.h > index 00ef5a8f85e5..40abc5995ffd 100644 > --- a/passt.h > +++ b/passt.h > @@ -190,7 +190,6 @@ struct ip6_ctx { > * @no_netns_quit: In pasta mode, don't exit if fs-bound namespace is go= ne > * @netns_base: Base name for fs-bound namespace, if any, in pasta mode > * @netns_dir: Directory of fs-bound namespace, if any, in pasta mode > - * @epollfd: File descriptor for epoll instance > * @fd_tap_listen: File descriptor for listening AF_UNIX socket, if any > * @fd_tap: AF_UNIX socket, tuntap device, or pre-opened socket > * @fd_control_listen: Listening control/configuration socket, if any > @@ -266,7 +265,6 @@ struct ctx { > char netns_base[PATH_MAX]; > char netns_dir[PATH_MAX]; > =20 > - int epollfd; > int fd_tap_listen; > int fd_tap; > int fd_control_listen; > diff --git a/pasta.c b/pasta.c > index 5aa56b78d262..0a742a4f9abe 100644 > --- a/pasta.c > +++ b/pasta.c > @@ -50,6 +50,7 @@ > #include "netlink.h" > #include "log.h" > #include "epoll_ctl.h" > +#include "threading.h" > =20 > #define HOSTNAME_PREFIX "pasta-" > =20 > @@ -517,7 +518,7 @@ void pasta_netns_quit_init(const struct ctx *c) > =20 > ref.fd =3D fd; > =20 > - epoll_add(c->epollfd, EPOLLIN, ref); > + epoll_add(threading_epollfd(THREADING_ID_DEFAULT), EPOLLIN, ref); > } > =20 > /** > diff --git a/pif.c b/pif.c > index 8ade587c623a..e0a36413878b 100644 > --- a/pif.c > +++ b/pif.c > @@ -16,6 +16,7 @@ > #include "ip.h" > #include "inany.h" > #include "epoll_ctl.h" > +#include "threading.h" > =20 > const char pif_type_str[][PIF_NAME_SIZE] =3D { > [PIF_NONE] =3D "", > @@ -130,7 +131,7 @@ int pif_listen(const struct ctx *c, uint8_t proto, ui= nt8_t pif, > goto fail; > } > =20 > - ret =3D epoll_add(c->epollfd, EPOLLIN, ref); > + ret =3D epoll_add(threading_epollfd(THREADING_ID_DEFAULT), EPOLLIN, ref= ); > if (ret < 0) > goto fail; > =20 > diff --git a/repair.c b/repair.c > index f31ccceed7c6..7560242cf1c1 100644 > --- a/repair.c > +++ b/repair.c > @@ -23,6 +23,7 @@ > #include "flow.h" > #include "flow_table.h" > #include "epoll_ctl.h" > +#include "threading.h" > =20 > #include "repair.h" > =20 > @@ -58,8 +59,9 @@ void repair_sock_init(const struct ctx *c) > } > =20 > ref.fd =3D c->fd_repair_listen; > - if (epoll_add(c->epollfd, EPOLLIN | EPOLLHUP | EPOLLET, ref)) > - err("repair helper socket epoll_ctl(), won't migrate"); > + if (epoll_add(threading_epollfd(THREADING_ID_DEFAULT), > + EPOLLIN | EPOLLHUP | EPOLLET, ref)) > + err_perror("repair helper socket epoll_ctl(), won't migrate"); > } > =20 > /** > @@ -115,7 +117,8 @@ int repair_listen_handler(struct ctx *c, uint32_t eve= nts) > =20 > ref.fd =3D c->fd_repair; > =20 > - rc =3D epoll_add(c->epollfd, EPOLLHUP | EPOLLET, ref); > + rc =3D epoll_add(threading_epollfd(THREADING_ID_DEFAULT), > + EPOLLHUP | EPOLLET, ref); > if (rc < 0) { > debug("epoll_ctl() on TCP_REPAIR helper socket"); > close(c->fd_repair); > @@ -134,7 +137,8 @@ void repair_close(struct ctx *c) > { > debug("Closing TCP_REPAIR helper socket"); > =20 > - epoll_ctl(c->epollfd, EPOLL_CTL_DEL, c->fd_repair, NULL); > + epoll_ctl(threading_epollfd(THREADING_ID_DEFAULT), EPOLL_CTL_DEL, > + c->fd_repair, NULL); > close(c->fd_repair); > c->fd_repair =3D -1; > } > diff --git a/tap.c b/tap.c > index 25cde67538ac..d9be6bcc41a0 100644 > --- a/tap.c > +++ b/tap.c > @@ -61,6 +61,7 @@ > #include "vhost_user.h" > #include "vu_common.h" > #include "epoll_ctl.h" > +#include "threading.h" > =20 > /* Maximum allowed frame lengths (including L2 header) */ > =20 > @@ -1226,7 +1227,7 @@ void tap_sock_reset(struct ctx *c) > passt_exit(EXIT_SUCCESS); > =20 > /* Close the connected socket, wait for a new connection */ > - epoll_del(c->epollfd, c->fd_tap); > + epoll_del(threading_epollfd(THREADING_ID_DEFAULT), c->fd_tap); > close(c->fd_tap); > c->fd_tap =3D -1; > if (c->mode =3D=3D MODE_VU) > @@ -1417,7 +1418,8 @@ static void tap_sock_unix_init(const struct ctx *c) > =20 > ref.fd =3D c->fd_tap_listen; > =20 > - epoll_add(c->epollfd, EPOLLIN | EPOLLET, ref); > + epoll_add(threading_epollfd(THREADING_ID_DEFAULT), EPOLLIN | EPOLLET, > + ref); > } > =20 > /** > @@ -1465,7 +1467,8 @@ static void tap_start_connection(const struct ctx *= c) > break; > } > =20 > - epoll_add(c->epollfd, EPOLLIN | EPOLLRDHUP, ref); > + epoll_add(threading_epollfd(THREADING_ID_DEFAULT), > + EPOLLIN | EPOLLRDHUP, ref); > =20 > if (!tap_is_ready(c)) > return; > diff --git a/tcp_splice.c b/tcp_splice.c > index 8617e62cea9a..fc5b6c25670d 100644 > --- a/tcp_splice.c > +++ b/tcp_splice.c > @@ -56,6 +56,7 @@ > #include "inany.h" > #include "flow.h" > #include "epoll_ctl.h" > +#include "threading.h" > =20 > #include "flow_table.h" > =20 > diff --git a/vhost_user.c b/vhost_user.c > index 8ba3949e4e9d..ad316aee12c3 100644 > --- a/vhost_user.c > +++ b/vhost_user.c > @@ -44,6 +44,7 @@ > #include "pcap.h" > #include "migrate.h" > #include "epoll_ctl.h" > +#include "threading.h" > =20 > /* vhost-user version we are compatible with */ > #define VHOST_USER_VERSION 1 > @@ -736,7 +737,7 @@ static bool vu_get_vring_base_exec(struct vu_dev *vde= v, > vdev->vq[idx].call_fd =3D -1; > } > if (vdev->vq[idx].kick_fd !=3D -1) { > - epoll_del(vdev->context->epollfd, vdev->vq[idx].kick_fd); > + epoll_del(threading_epollfd(THREADING_ID_DEFAULT), vdev->vq[idx].kick_= fd); > close(vdev->vq[idx].kick_fd); > vdev->vq[idx].kick_fd =3D -1; > } > @@ -757,7 +758,7 @@ static void vu_set_watch(const struct vu_dev *vdev, i= nt idx) > .queue =3D idx > }; > =20 > - epoll_add(vdev->context->epollfd, EPOLLIN, ref); > + epoll_add(threading_epollfd(THREADING_ID_DEFAULT), EPOLLIN, ref); > } > =20 > /** > @@ -802,7 +803,7 @@ static bool vu_set_vring_kick_exec(struct vu_dev *vde= v, > vu_check_queue_msg_file(vmsg); > =20 > if (vdev->vq[idx].kick_fd !=3D -1) { > - epoll_del(vdev->context->epollfd, vdev->vq[idx].kick_fd); > + epoll_del(threading_epollfd(THREADING_ID_DEFAULT), vdev->vq[idx].kick_= fd); > close(vdev->vq[idx].kick_fd); > vdev->vq[idx].kick_fd =3D -1; > } > @@ -1095,7 +1096,7 @@ void vu_cleanup(struct vu_dev *vdev) > vq->err_fd =3D -1; > } > if (vq->kick_fd !=3D -1) { > - epoll_del(vdev->context->epollfd, vq->kick_fd); > + epoll_del(threading_epollfd(THREADING_ID_DEFAULT), vq->kick_fd); > close(vq->kick_fd); > vq->kick_fd =3D -1; > } > --=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 --3X/DP2REA0Md7yUt Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmp+tvEACgkQzQJF27ox 2Gd8UhAAj74LzCOpb4lHPU9MzTC20NISAgV2Mi8pLxBeatMbqq3G5t+KwiOwab0i ep5ztdCVF4zHrioERVHruBsRz00QtGV0bsEj4L7Uif1SD4q6hLdGL7jfHeqNZY2T FsIFe0M7kMGDCQGUDXXdozLPLUD0uFvUGku0ctjzVBVdVMnkB9CsYXFyYZV8Cjj9 CrG8Zgu271DSKWrmfNqLIRQW4o3hrjakS9fZn3z7eKVhxf7Zd/ti0Erakw376mZ6 T0zwuvIMkbb8kRkkmDzeDuqM7MJVsxrg0jwag66711YNQcTwGuTnaeTJBV02/fNv ISJmBQfmwZMg5Xy03uiVpdmWy7Xu5xmvLE7cok6jyXvHKqhMlPibdGWW6mBqgf7B qb5r+oE0T1iT9YNNb8iufk0Kj7VRUM2WF5l4xUVZpp8Pe5RXA+2Q9DXwD5n8C9ly muvdX5STTMlYeJODosRnRjgwJSZRuZT3l4L7UD5JdbE5cSrujTTgv36cL4qfOuKl i8CEd/bHzOxjghhFGNGIUhiY7CSQNWsBEOK2i9zTJ6V3+MYrBxxJ7z3VXu2/3S4B ad28EK2hghgm4MTxFynYS8FMdJIOZ7CEfq3vMXUnvrmEU4nx4IcVn/sOUfZdoL6D iXs3lpIkCu8dufU4YLAxpCUkhU6HOx1OzK6qiiYTE5A9IifU2g4= =4Jda -----END PGP SIGNATURE----- --3X/DP2REA0Md7yUt--