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=202512 header.b=leNf+qli; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id D30BB5A0652 for ; Mon, 22 Dec 2025 06:57:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202512; t=1766383050; bh=tf3hBTzR7WO20OiftEPRZNS5TdEjqfq2TgQKOEntP9E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=leNf+qliS1udBsp552cD/giA7ZjG9BQqSiq4KCmm/V+ZtK1eYXVRvG6ko2SJYJzWY ZQ/zR7BCgJb66xc9E4Y3dSp1j/OYEs0NYsBqlsaveZYX6/Fcfdsrbi4x0a4/7HCQ77 4B6a+WyddhiR9uWjkdOw6twQPW4DYmVa/DUaDrMWz6sD3Ziy7u81j/ggsT2Tr9AIqU vHW0XOBCx6irIpZwr2vdh3A4NoQQ79llKMO2vcDfw22LqMLmVde0DDIwKMmXy0Tc4J mJrHjsApdBfvD3MAiOsqG5wSszbl9OScRvrCux2/YALbHY7ziaOOfBMAmM6Annoz4n Vi2AEOA7G/zXw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dZS8p636pz4wR6; Mon, 22 Dec 2025 16:57:30 +1100 (AEDT) Date: Mon, 22 Dec 2025 16:46:19 +1100 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH 3/7] tcp_splice: Refactor tcp_splice_conn_epoll_events() to per-side computation Message-ID: References: <20251219164518.930012-1-lvivier@redhat.com> <20251219164518.930012-4-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="bcF74MVM68SWzYWH" Content-Disposition: inline In-Reply-To: <20251219164518.930012-4-lvivier@redhat.com> Message-ID-Hash: CDZROLZPNWMCE7MPO22DMYCOFMUNGC42 X-Message-ID-Hash: CDZROLZPNWMCE7MPO22DMYCOFMUNGC42 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: --bcF74MVM68SWzYWH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 19, 2025 at 05:45:14PM +0100, Laurent Vivier wrote: > The function tcp_splice_conn_epoll_events() currently takes an array of > struct epoll_event and fills in the .events field for both sides using > flow_foreach_sidei() loops. >=20 > This works, but the function is doing two conceptually separate things > at once: computing events for side 0 and computing events for side 1. > The OUT_WAIT handling is particularly subtle, as it has cross-side > effects: when OUT_WAIT(sidei) is set, we add EPOLLOUT to ev[sidei] but > also remove EPOLLIN from ev[!sidei]. >=20 > Refactor to make the function compute events for a single side at a > time, taking sidei as a parameter and returning uint32_t. This makes > the logic more focused and easier to follow. The cross-side effects of > OUT_WAIT are preserved by checking both OUT_WAIT(sidei) and > OUT_WAIT(!sidei) within each call. >=20 > The caller tcp_splice_epoll_ctl() now invokes the function twice, once > for each side, making the two-sided nature of the operation explicit. >=20 > No functional change. >=20 > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > tcp_splice.c | 33 ++++++++++++++------------------- > 1 file changed, 14 insertions(+), 19 deletions(-) >=20 > diff --git a/tcp_splice.c b/tcp_splice.c > index 440522449c13..bf4ff466de07 100644 > --- a/tcp_splice.c > +++ b/tcp_splice.c > @@ -114,29 +114,23 @@ static struct tcp_splice_conn *conn_at_sidx(flow_si= dx_t sidx) > * @events: Connection event flags > * @ev: Events to fill in, 0 is accepted socket, 1 is connecting socket > */ > -static void tcp_splice_conn_epoll_events(uint16_t events, > - struct epoll_event ev[]) > +static uint32_t tcp_splice_conn_epoll_events(uint16_t events, unsigned s= idei) > { > - unsigned sidei; > - > - flow_foreach_sidei(sidei) > - ev[sidei].events =3D 0; > + uint32_t e =3D 0; > =20 > if (events & SPLICE_ESTABLISHED) { > - flow_foreach_sidei(sidei) { > - if (!(events & FIN_SENT(!sidei))) > - ev[sidei].events =3D EPOLLIN | EPOLLRDHUP; > - } > - } else if (events & SPLICE_CONNECT) { > - ev[1].events =3D EPOLLOUT; > + if (!(events & FIN_SENT(!sidei))) > + e =3D EPOLLIN | EPOLLRDHUP; > + } else if (sidei =3D=3D 1 && events & SPLICE_CONNECT) { > + e =3D EPOLLOUT; > } > =20 > - flow_foreach_sidei(sidei) { > - if (events & OUT_WAIT(sidei)) { > - ev[sidei].events |=3D EPOLLOUT; > - ev[!sidei].events &=3D ~EPOLLIN; > - } > - } > + if (events & OUT_WAIT(sidei)) > + e |=3D EPOLLOUT; > + if (events & OUT_WAIT(!sidei)) > + e &=3D ~EPOLLIN; > + > + return e; > } > =20 > /** > @@ -161,7 +155,8 @@ static int tcp_splice_epoll_ctl(const struct ctx *c, > struct epoll_event ev[SIDES] =3D { { .data.u64 =3D ref[0].u64 }, > { .data.u64 =3D ref[1].u64 } }; > =20 > - tcp_splice_conn_epoll_events(conn->events, ev); > + ev[0].events =3D tcp_splice_conn_epoll_events(conn->events, 0); > + ev[1].events =3D tcp_splice_conn_epoll_events(conn->events, 1); > =20 > =20 > if (epoll_ctl(epollfd, m, conn->s[0], &ev[0]) || > --=20 > 2.51.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 --bcF74MVM68SWzYWH Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmlI2x0ACgkQzQJF27ox 2GeMAA//T0pfU78YOYORjvq1wTBXt+yBmYe3nahZgkLSqERhBordXklqVjGXWIoO vefp8vKF0jdbhAu6XYAEI0Hot0AfPELhv5WVa1mxREoQzwyNPKedpEdmT0r3S8pP lPscFYdcCwY5CLwO8kFI/aIlFh3965/vDg8EszmhLuVaOZNoz2yaXB2O4NcSsTnf BMassxZResAxqojacFeyy25ve9w7Tvhp0dudLcfZHuCWpL+hcw/YU+CmPIxTOUCh f3mOpZpmTN91/3fUT8mUNhWU1bekSi2RxGgJKC+hRkhWA4c3MdFeuTv0ac0UmFki j91uguAKpZa5znLytHAx7APBQtXGvH841ehzcBqjrQ9M0Sdtrq07Yu9NfOcDwhLS XwuvmIzRD4QAyu3T17ePZjKJ//gNSaylumGmkCeCwG7esoNPrOU8HoB9Rdv5OU4X 1xh8F298DvFcVccB6I+LFbVkoR4BePDePPqwFR0wThz2evR/srfdDMF+np54Hpeo WlOt0tlU6o7xC4p7Wgx+N+9isQ58PZD11qPmdv3pW3nlfrEzmuxAuYGEWkfCtr+p k00sv8XeOvOvlMT3Qw2YMOe0WN1H0INxbDZotBkeg5wsGnDSXKAB+mHk7/V4XibH K/346sNB68YUaWkzYD2SackF95A0uP32aaYeI/opreenKOy7kU8= =3BOe -----END PGP SIGNATURE----- --bcF74MVM68SWzYWH--