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=202502 header.b=gDUDJ/MV; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id AEC3B5A0274 for ; Mon, 17 Feb 2025 04:57:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202502; t=1739764617; bh=lHo9/JnlA8mkt1thg20sTSMiIVORqGCWiWUNn5jHItk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gDUDJ/MVQBCmHi+TnM6jChgHh9RIwaopEEkKyTEwePJKxUO/0YPJpBjW/b0u7AcD8 5yyubjRjwco0I8QaVJs067rzrI9YAKGOd42Bh4JbK/15n2tpl6SlK9PmulWNc7Hb96 zYOXeMwx5REwyqcAlhH9s9QC/rFhfidr7Gm60cQ1pkCONbt9Y2048vxIij1Gj5Xse+ DUmWXNm8m42WayZXLhe8Ka65ef0GJG7GnmJVXNUAvtLHP0IkfInZXng9yIFqwNDLR8 plLn0uQq1vh85sHuub9RIjz3u1gw5m8iiQCAbk6QHf8zlJbvUCjWlFOddv023XMnH7 xLAGGa1kL6+mw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Yx83s4B0Vz4wy1; Mon, 17 Feb 2025 14:56:57 +1100 (AEDT) Date: Mon, 17 Feb 2025 14:51:20 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] tcp_splice: Don't wake up on input data if we can't write it anywhere Message-ID: References: <20250216221216.2014593-1-sbrivio@redhat.com> <20250216221216.2014593-2-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="SZIbgIUPplnjhKws" Content-Disposition: inline In-Reply-To: <20250216221216.2014593-2-sbrivio@redhat.com> Message-ID-Hash: 43TIAM2BWQNJQ6UHZMXETPTRMWVKIZNM X-Message-ID-Hash: 43TIAM2BWQNJQ6UHZMXETPTRMWVKIZNM 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: --SZIbgIUPplnjhKws Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Feb 16, 2025 at 11:12:16PM +0100, Stefano Brivio wrote: > If we set the OUT_WAIT_* flag (waiting on EPOLLOUT) for a side of a > given flow, it means that we're blocked, waiting for the receiver to > actually receive data, with a full pipe. >=20 > In that case, if we keep EPOLLIN set for the socket on the other side > (our receiving side), we'll get into a loop such as: >=20 > 41.0230: pasta: epoll event on connected spliced TCP socket 10= 8 (events: 0x00000001) > 41.0230: Flow 1 (TCP connection (spliced)): -1 from read-side = call > 41.0230: Flow 1 (TCP connection (spliced)): -1 from write-side= call (passed 8192) > 41.0230: Flow 1 (TCP connection (spliced)): event at tcp_splic= e_sock_handler:577 > 41.0230: pasta: epoll event on connected spliced TCP socket 10= 8 (events: 0x00000001) > 41.0230: Flow 1 (TCP connection (spliced)): -1 from read-side = call > 41.0230: Flow 1 (TCP connection (spliced)): -1 from write-side= call (passed 8192) > 41.0230: Flow 1 (TCP connection (spliced)): event at tcp_splic= e_sock_handler:577 >=20 > leading to 100% CPU usage, of course. >=20 > Drop EPOLLIN on our receiving side as long when we're waiting for > output readiness on the other side. >=20 > Link: https://github.com/containers/podman/issues/23686#issuecomment-2661= 036584 > Link: https://www.reddit.com/r/podman/comments/1iph50j/pasta_high_cpu_on_= podman_rootless_container/ > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > tcp_splice.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) >=20 > diff --git a/tcp_splice.c b/tcp_splice.c > index f1a9223..8a39a6f 100644 > --- a/tcp_splice.c > +++ b/tcp_splice.c > @@ -131,8 +131,12 @@ static void tcp_splice_conn_epoll_events(uint16_t ev= ents, > ev[1].events =3D EPOLLOUT; > } > =20 > - flow_foreach_sidei(sidei) > - ev[sidei].events |=3D (events & OUT_WAIT(sidei)) ? EPOLLOUT : 0; > + flow_foreach_sidei(sidei) { > + if (events & OUT_WAIT(sidei)) { > + ev[sidei].events |=3D EPOLLOUT; > + ev[!sidei].events &=3D ~EPOLLIN; > + } > + } > } > =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 --SZIbgIUPplnjhKws Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmeysjcACgkQzQJF27ox 2GfQKxAAool2LDjJSM5pbXozqrnpekqZo2zH2oXje7qkmXYbA7yZIwh0gblGHWkV H64BiXHU540RUKFmju/jEH15/MbNDyYd3VQXmQyVfsHTDSbASC9Pd3j7nAyl96Gk 9kObK0Ps55DQrwiHWU2L1pTxzj22cMrLoi0vb39rDStjpp+CaOVbxbc6IFUSr58/ NGk5iWenugfYp1tC6G3hhdwnYakAxzocCinmJ6g1KP0rBYq5yISRoX+UkA64UYoS OqTEKLSEb9wrU41gOVr9+j5+Je6cE8KskjQySk6QsSs8g6r2js5eB/IHIMfMn3mu eZsYP4b+eZ48YnnG1gCWhJ0WICwF+WLXM9G35KPvVVOoI7Xg5k3wcQ08ChrsRp3G q/poWM9+/9bp3enJENUW1aoDeLWytd5QxnhBALU7X8g/LvvruOA63YDlHWpoAdvc xsZaCyd17KArKKvXjFTU/DihQbNSw1KpI3M4mzXWxD0z//y/ZAOH+KpQtKceRuXk nQB2eFRcLC8cy8aZMkTafWatKW0/SUOjzsUcNM9WPoqlcV1YLeGQZvLUfV9U97iH LghT+BBcNt0PMGNEsH1/vIxwFBZ2/1Wy3TfDCsr0bV6HC7xHpL48QfcA0c530KVu KKJssvKrOmfjd14ovWcsN11t6P54NaHDZSna28SzZ7ybx5H1phs= =pPX3 -----END PGP SIGNATURE----- --SZIbgIUPplnjhKws--