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=202412 header.b=kgdSV8Qs; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id D34C55A0275 for ; Fri, 24 Jan 2025 04:38:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202412; t=1737689892; bh=yZeUI8NGFZEgJbSlwYmpIJctgZTVKnA8yHTuq9/mAS4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kgdSV8Qs79g3vY2qA9g23BbMyrHJus8OclXC31tIkodSnwLuGdB3Fq4uULFJ+lXVp Wgz2vknXGXex6r0o+I5FBxV4iVOMRtZcqZ9I9BLzDQ+24KjnPaAqRjPM0V9kX1WWWs E4i4N/yYLgn1ANmlk9rKXrM1mKN8WCx4YhVv2JSpXOpec0iI01a3cTfCsGqMNaQtO3 tJUOBuirgybz9xpcPJImiGjzQBwJ4PBDCOZolAvPQEa1lL4OxPb1zs1UWZDiOqWXGL KgjIhGN8Arig2P8SDJpKdPw7xIpDEBoLA4UXrN88J83+c6xK+Gb0fdwiPXez0zwipl 2AIESyGx9BliQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4YfNnJ3lbLz4wnp; Fri, 24 Jan 2025 14:38:12 +1100 (AEDT) Date: Fri, 24 Jan 2025 14:00:54 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 3/4] tcp: Set EPOLLET when when reading from a socket fails with EAGAIN Message-ID: References: <20250116203250.784496-1-sbrivio@redhat.com> <20250116203250.784496-4-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="nXBYNvcdN2XBKofI" Content-Disposition: inline In-Reply-To: <20250116203250.784496-4-sbrivio@redhat.com> Message-ID-Hash: H5ZFY265NP2K7D3TWJ7BYNCMNJHV7XLC X-Message-ID-Hash: H5ZFY265NP2K7D3TWJ7BYNCMNJHV7XLC 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, Asahi Lina , Sergio Lopez , Jon Maloy 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: --nXBYNvcdN2XBKofI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jan 16, 2025 at 09:32:49PM +0100, Stefano Brivio wrote: > Before SO_PEEK_OFF support was introduced by commit e63d281871ef > ("tcp: leverage support of SO_PEEK_OFF socket option when available"), > we would peek data from sockets using a "discard" buffer as first > iovec element, so that, unless we had no pending data at all, we would > always get a positive return code from recvmsg() (except for closing > connections or errors). >=20 > If we couldn't send more data to the guest, in the window, we would > set the STALLED flag (causing the epoll descriptor to switch to > edge-triggered mode), and return early from tcp_data_from_sock(). >=20 > With SO_PEEK_OFF, we don't have a discard buffer, and if there's data > on the socket, but nothing beyond our current peeking offset, we'll > get EAGAIN instead of our current "discard" length. In that case, we > return even earlier, and we don't set EPOLLET on the socket as a > result. >=20 > As reported by Asahi Lina, this causes event loops where the kernel is > signalling socket readiness, because there's data we didn't dequeue > yet (waiting for the guest to acknowledge it), but we won't actually > peek anything new, and return early without setting EPOLLET. >=20 > This is the original report, mentioning the originally proposed fix: Reviewed-by: David Gibson --=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 --nXBYNvcdN2XBKofI Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmeTAmUACgkQzQJF27ox 2GcDjw//YkrL7WYfSmXmQrBWfc0CDDwd72zbnmmYhP0ALzrWv4k9jEppM3gGoMPV 0q4c4PaRrH+itPBGKyNrRwUaefv3RZIzlvxuoBy0LezCO8gY2uhIJcwkdX1ADffb XU3if/sq58tUCQaeMKmGHcfdEx7DAcypq3bhrexmpv8/QoWytMnAdZx+wYrFrxJ2 XG4e6pfdIGrb6og5YsxTxKfiOiYvmvCz0jE6Q7esSsa8Der+c/xfjJRygVoF7ytt Eban48aGeOYJjgUuNn8+HJf+2qtyWVXmbyME8xW6Pc+n0ok+gRuqYBBGcskZS2vd Z2TMJEKqYw32rCwP5C133Id7JR/8nOhLpxqT98SrIV/ICvFnPI2qSrVwn6Lra4Eq V41fPhW+V1Dp/j6TyHxtkS87AC0HRhywBRPTvaslya5GcNgs6bBcthXATbYjdyj1 aqrWwMVagp842edcalTVVwINvUFQcDBacLJ2tAElYHU/vkTDMPePeGa7RPR2qYhZ zVFlQGO1X19sJVDDYFoNdPHkQu+VZ15bJ4P86TditHy72U0dFzg3QQMs8j3mUs3u qxNGfsyojWppnJFfiYO1D50jd4jmzAu6Fkbwkl6zMRZT11FBkDL56KqFHXKYX7zD iVZVtfdLIikX2Tb55jDpcGRkMsSY6s1yUwSOaO6XRRnyWuAj3IY= =AvqJ -----END PGP SIGNATURE----- --nXBYNvcdN2XBKofI--