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=202510 header.b=Q1CAeWNQ; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 582615A026F for ; Tue, 07 Oct 2025 08:08:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202510; t=1759817304; bh=cHPwKQQbXx2v3JMQR4DFoSyJV9+b0C7RT55wcra9OOw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Q1CAeWNQn6ifs6vRIYtz+JB5VUxkWNSinHnhWWPpWLinXsvGlxcDxnyjKYvfuiVgu R5vUmm8XWiYSiwPNq90hoSWIaN6C6iyhovdLO7HoNaRnzPLrgXR8J3KbinGn6ptlLO HOy+RJdizFk/KJus7j8ENh5UwvLnVeZS3MvD1U8O/ntjx/4h9TsDToGRp4wW2Zy9fH UsQqZCnxMudY9XLM7JPkVjpGgaclTdPa28o2/LqfYzTfXSF7V7M6B4vt1UEtColquv DouZxXyxb2b/Y+0ku7mEiH5h6fxbAVQBqE8gYbyJxQwGdnYyh/DooKQip1Yk7mDnrB pJLQp+8ij8YHg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4cgm0S4rfgz4wB5; Tue, 7 Oct 2025 17:08:24 +1100 (AEDT) Date: Tue, 7 Oct 2025 16:26:40 +1100 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH 1/5] util: Simplify epoll_del() interface to take epollfd directly Message-ID: References: <20251003152717.2437765-1-lvivier@redhat.com> <20251003152717.2437765-2-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="p2iw3C4kybqrXiNS" Content-Disposition: inline In-Reply-To: <20251003152717.2437765-2-lvivier@redhat.com> Message-ID-Hash: VWWDE6K4BX7FCO7DFJKYBL7KBIH5QBLD X-Message-ID-Hash: VWWDE6K4BX7FCO7DFJKYBL7KBIH5QBLD 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: --p2iw3C4kybqrXiNS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 03, 2025 at 05:27:13PM +0200, Laurent Vivier wrote: > Change epoll_del() to accept the epoll file descriptor directly instead > of the full context structure. This simplifies the interface and aligns > with the threading refactoring by reducing dependency on the context > structure for basic epoll operations as we will manage an epollfd per > thread. >=20 > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > icmp.c | 2 +- > tap.c | 2 +- > tcp.c | 6 +++--- > tcp_splice.c | 4 ++-- > udp_flow.c | 4 ++-- > util.c | 6 +++--- > util.h | 2 +- > vhost_user.c | 6 +++--- > 8 files changed, 16 insertions(+), 16 deletions(-) >=20 > diff --git a/icmp.c b/icmp.c > index 6dffafb0bf54..bd3108a21675 100644 > --- a/icmp.c > +++ b/icmp.c > @@ -151,7 +151,7 @@ unexpected: > static void icmp_ping_close(const struct ctx *c, > const struct icmp_ping_flow *pingf) > { > - epoll_del(c, pingf->sock); > + epoll_del(c->epollfd, pingf->sock); > close(pingf->sock); > flow_hash_remove(c, FLOW_SIDX(pingf, INISIDE)); > } > diff --git a/tap.c b/tap.c > index 95d309bd1938..134c37a72979 100644 > --- a/tap.c > +++ b/tap.c > @@ -1142,7 +1142,7 @@ void tap_sock_reset(struct ctx *c) > } > =20 > /* Close the connected socket, wait for a new connection */ > - epoll_del(c, c->fd_tap); > + epoll_del(c->epollfd, c->fd_tap); > close(c->fd_tap); > c->fd_tap =3D -1; > if (c->mode =3D=3D MODE_VU) > diff --git a/tcp.c b/tcp.c > index 48b1ef29bfe8..04725deabb65 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -511,9 +511,9 @@ static int tcp_epoll_ctl(const struct ctx *c, struct = tcp_tap_conn *conn) > =20 > if (conn->events =3D=3D CLOSED) { > if (conn->in_epoll) > - epoll_del(c, conn->sock); > + epoll_del(c->epollfd, conn->sock); > if (conn->timer !=3D -1) > - epoll_del(c, conn->timer); > + epoll_del(c->epollfd, conn->timer); > return 0; > } > =20 > @@ -3445,7 +3445,7 @@ int tcp_flow_migrate_source_ext(const struct ctx *c, > if (c->migrate_no_linger) > close(s); > else > - epoll_del(c, s); > + epoll_del(c->epollfd, s); > =20 > /* Adjustments unrelated to FIN segments: sequence numbers we dumped are > * based on the end of the queues. > diff --git a/tcp_splice.c b/tcp_splice.c > index 26cb63064583..666ee62b738f 100644 > --- a/tcp_splice.c > +++ b/tcp_splice.c > @@ -204,8 +204,8 @@ static void conn_flag_do(const struct ctx *c, struct = tcp_splice_conn *conn, > } > =20 > if (flag =3D=3D CLOSING) { > - epoll_del(c, conn->s[0]); > - epoll_del(c, conn->s[1]); > + epoll_del(c->epollfd, conn->s[0]); > + epoll_del(c->epollfd, conn->s[1]); > } > } > =20 > diff --git a/udp_flow.c b/udp_flow.c > index cef3fb588bbe..84973f807167 100644 > --- a/udp_flow.c > +++ b/udp_flow.c > @@ -51,7 +51,7 @@ void udp_flow_close(const struct ctx *c, struct udp_flo= w *uflow) > flow_foreach_sidei(sidei) { > flow_hash_remove(c, FLOW_SIDX(uflow, sidei)); > if (uflow->s[sidei] >=3D 0) { > - epoll_del(c, uflow->s[sidei]); > + epoll_del(c->epollfd, uflow->s[sidei]); > close(uflow->s[sidei]); > uflow->s[sidei] =3D -1; > } > @@ -88,7 +88,7 @@ static int udp_flow_sock(const struct ctx *c, > if (flowside_connect(c, s, pif, side) < 0) { > int rc =3D -errno; > =20 > - epoll_del(c, s); > + epoll_del(c->epollfd, s); > close(s); > =20 > flow_dbg_perror(uflow, "Couldn't connect flow socket"); > diff --git a/util.c b/util.c > index c492f904b3fc..88a91b1100f5 100644 > --- a/util.c > +++ b/util.c > @@ -996,12 +996,12 @@ void raw_random(void *buf, size_t buflen) > =20 > /** > * epoll_del() - Remove a file descriptor from our passt epoll > - * @c: Execution context > + * @epollfd: epoll file descriptor to add to > * @fd: File descriptor to remove > */ > -void epoll_del(const struct ctx *c, int fd) > +void epoll_del(int epollfd, int fd) > { > - epoll_ctl(c->epollfd, EPOLL_CTL_DEL, fd, NULL); > + epoll_ctl(epollfd, EPOLL_CTL_DEL, fd, NULL); > =20 > } > =20 > diff --git a/util.h b/util.h > index 22eaac56e719..c61cbef357aa 100644 > --- a/util.h > +++ b/util.h > @@ -300,7 +300,7 @@ static inline bool mod_between(unsigned x, unsigned i= , unsigned j, unsigned m) > #define FPRINTF(f, ...) (void)fprintf(f, __VA_ARGS__) > =20 > void raw_random(void *buf, size_t buflen); > -void epoll_del(const struct ctx *c, int fd); > +void epoll_del(int epollfd, int fd); > =20 > /* > * Starting from glibc 2.40.9000 and commit 25a5eb4010df ("string: strer= ror, > diff --git a/vhost_user.c b/vhost_user.c > index fa343a86fac2..1221ac1abcd0 100644 > --- a/vhost_user.c > +++ b/vhost_user.c > @@ -733,7 +733,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, vdev->vq[idx].kick_fd); > + epoll_del(vdev->context->epollfd, vdev->vq[idx].kick_fd); > close(vdev->vq[idx].kick_fd); > vdev->vq[idx].kick_fd =3D -1; > } > @@ -801,7 +801,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, vdev->vq[idx].kick_fd); > + epoll_del(vdev->context->epollfd, vdev->vq[idx].kick_fd); > close(vdev->vq[idx].kick_fd); > vdev->vq[idx].kick_fd =3D -1; > } > @@ -1092,7 +1092,7 @@ void vu_cleanup(struct vu_dev *vdev) > vq->err_fd =3D -1; > } > if (vq->kick_fd !=3D -1) { > - epoll_del(vdev->context, vq->kick_fd); > + epoll_del(vdev->context->epollfd, vq->kick_fd); > close(vq->kick_fd); > vq->kick_fd =3D -1; > } > --=20 > 2.50.1 >=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 --p2iw3C4kybqrXiNS Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmjkpI8ACgkQzQJF27ox 2GfRQg/5Ado3QQO78NXzKu/9x4zFBm83OZzCCWRIB7DhZOqtlj7Ie1fLaw+QS+Ek OcAVadt8LX7SkNkkyCNSRaDdDsHDHHgOoEUUryZPsScx6TB5qyvpsIpJFem1xInu gLBd0B68gdf247JlS2blVdq3VAQMq90qALPl4WgvNb0VLh+Osx8vMlsaPEyh1rG/ mJy+oDCvkDRYwDKmye0TNWVTxHS9+7BAyDxHXoy6JY0D3oraeRkLnbkXpM5Xhgby B0ClJ5wxfEslsevCOtkitTs2schTZL9A/HJTlUAu4alttBuK4DV2spqRRYFNksix WhOe4X/yFaDbYIsKsThGuGfl4i7B3EBfCTJ/lKaX2F9AXR0kaOE7yhHJW0EqdRQ+ jt7Tzxt0jpNg6wPc4ix/xHkdf1v7C1TIVZa3hBPEQ/cCDLMvzfvoYZ9Xw/q8nWlC 3sVPmUfutRcwiJg3Lb5AkbebT4bq6buceUsDAoU0yx+LRu1ccWTk4xc3jSeqtiD4 LoYVa2LnLNmfGSRzE8CaUUsGY6kK4+mQcHZRhJHszrLteO8kzbnsNsdkE9fPAi/4 2Lukc4LqZpmj/ylwKSor9GyW9bGAkVELV4p+nfEZ+hm8f8or4Ap81BLXD8yqu3PG NGKqJu3xQ4EPBGyG0ZHIfcTA4RHipXDoqXqQNzXZEUwXFb2pdAc= =fjmq -----END PGP SIGNATURE----- --p2iw3C4kybqrXiNS--