From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 7461F5A0272 for ; Sat, 4 Nov 2023 07:11:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1699078279; bh=3PseIPVwWzV7WJOQLGe6RAnraTHy44d/Qnnrqwm13xk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cio4w6qNp6HHMfl/04FjcTIMwQsBC40chE8f4P1ino+thBwuMe7nPKyhPf/IHwEeO A2fdZzoPeSKn17VJXjOrD9d8XPrSeSPt5o1youG6GVB5E+/QDI2opCJdwHeLt0IHwD NP5COSkD+NSSYYsDjIaYsA1ZpInRKR2nunYNP6OU= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4SMnLH4rTBz4xWp; Sat, 4 Nov 2023 17:11:19 +1100 (AEDT) Date: Sat, 4 Nov 2023 16:58:04 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 05/11] tcp_splice: Avoid awkward temporaries in tcp_splice_epoll_ctl() Message-ID: References: <20231012015114.2612066-1-david@gibson.dropbear.id.au> <20231012015114.2612066-6-david@gibson.dropbear.id.au> <20231103172134.5be225c9@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="uiB7WlpoKX0JZEiv" Content-Disposition: inline In-Reply-To: <20231103172134.5be225c9@elisabeth> Message-ID-Hash: 4ISK4KIEAPL2WKZVWXBFOMRRTEEH3A5D X-Message-ID-Hash: 4ISK4KIEAPL2WKZVWXBFOMRRTEEH3A5D 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: --uiB7WlpoKX0JZEiv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Nov 03, 2023 at 05:21:34PM +0100, Stefano Brivio wrote: > On Thu, 12 Oct 2023 12:51:08 +1100 > David Gibson wrote: >=20 > > We initialise the events_a and events_b variables with > > tcp_splice_conn_epoll_events() function, then immediately copy the valu= es > > into ev_a.events and ev_b.events. We can't simply pass &ev_[ab].events= to > > tcp_splice_conn_epoll_events(), because struct epoll_event is packed, > > leading to 'pointer may be unaligned' warnings if we attempt that. > >=20 > > We can, however, make tcp_splice_conn_epoll_events() take struct > > epoll_event pointers rather than raw u32 pointers, avoiding the awkward > > temporaries. > >=20 > > Signed-off-by: David Gibson > > --- > > tcp_splice.c | 24 +++++++++++------------- > > 1 file changed, 11 insertions(+), 13 deletions(-) > >=20 > > diff --git a/tcp_splice.c b/tcp_splice.c > > index 439fc1d..3419207 100644 > > --- a/tcp_splice.c > > +++ b/tcp_splice.c > > @@ -95,25 +95,26 @@ static int tcp_sock_refill_ns(void *arg); > > /** > > * tcp_splice_conn_epoll_events() - epoll events masks for given state > > * @events: Connection event flags > > - * @a: Event mask for socket with accepted connection, set on return > > - * @b: Event mask for connection target socket, set on return > > + * @a: Event for socket with accepted connection, set on return > > + * @b: Event for connection target socket, set on return > > */ > > static void tcp_splice_conn_epoll_events(uint16_t events, > > - uint32_t *a, uint32_t *b) > > + struct epoll_event *a, > > + struct epoll_event *b) > > { > > - *a =3D *b =3D 0; > > + a->events =3D b->events =3D 0; > > =20 > > if (events & SPLICE_ESTABLISHED) { > > if (!(events & B_FIN_SENT)) > > - *a =3D EPOLLIN | EPOLLRDHUP; > > + a->events =3D EPOLLIN | EPOLLRDHUP; > > if (!(events & A_FIN_SENT)) > > - *b =3D EPOLLIN | EPOLLRDHUP; > > + b->events =3D EPOLLIN | EPOLLRDHUP; > > } else if (events & SPLICE_CONNECT) { > > - *b =3D EPOLLOUT; > > + b->events =3D EPOLLOUT; > > } > > =20 > > - *a |=3D (events & A_OUT_WAIT) ? EPOLLOUT : 0; > > - *b |=3D (events & B_OUT_WAIT) ? EPOLLOUT : 0; > > + a->events |=3D (events & A_OUT_WAIT) ? EPOLLOUT : 0; > > + a->events |=3D (events & B_OUT_WAIT) ? EPOLLOUT : 0; >=20 > This should be b->events |=3D ..., but it's fixed in 7/11 anyway. Oops. Fixed, nonetheless. --=20 David Gibson | 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 --uiB7WlpoKX0JZEiv Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmVF3WMACgkQzQJF27ox 2GecfBAAgxEA9izQEKEXx3V6QNAj2iuCSG6q3CedHa+h6NFlI+2mBweO8Hixv8Lu RopcivgJxk3izzx3GfqdjLwGEBf6YY/6f481/mCvnJi5Jc1XIam7Hco0qLgBiDCp x/nSK6L+Odpgvv20SSfNH6LJ4Y7Li/aoco3Qhf/cWzqUD2iX13LPjNx42215kqzd oZ2A8wvXAIQLZsr5Om1RiJ6ej9BpbK60c1fFLlabOKMJUN/TEB2tiRVG4aUfyZLI Z1LlldZpOkiy9hfpYx2OWBUaeEqP2eQeAopigEl5sJXhMBoI6O2JcAVPP3eMJD3K LbJw97kkMe8b8QOXF5KqmGkIA7ImQrBdJ8PAe4SaZlwlVtGILmPBIBLA8dr3VwsK qIEOdL3IwXhI5rBqOufTLJx39wbGFNXag33XV9eEeoOdtga+bBu6Rnrksn5pYP3V oMSJ3H9GZ54NSFnFHsUxAtM6x06ykHWdja+f9kbMyX8wA55S6Df5UxPJo7K3aItw VTN/369K0L8CrQXgX1lMNBQmV557QrqLr3x4sYgzGIuPq5h4E3rAT0obpVs4zt1q ooO1YnzhAuaDAiwHJvM8BVVGn6H0/32GFBFtNX58p7qDnZyRy2RLLwqLvYAgnoQ7 byH6XNrrx8wSHZA0MboWPaXZjLpneZu/aK7XLBZx1viRfURQLGM= =nfyD -----END PGP SIGNATURE----- --uiB7WlpoKX0JZEiv--