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 9D40A5A026F for ; Thu, 14 Mar 2024 06:07:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1710392830; bh=T7N9UOkR5hOLcyEKL+SHuNlOqmvdUW8URipIt61DM8Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YgQe5Tty1OiGqa7ZknWnrmZ6qY5OYOOtw0Ntkx4fgrSOu8MJ4gELwelPfo52YVogg LQB5j2WahP/0H8bs/qhL8qP6CWku6mcFShyP3QWANIUj4iXkq2RgO076s6iN12c12p x9RArSnw+uTl6W0LcHxPTfA9cxRTZnKRJn0zCz/Etf81TALZq6+j4ndV0DQQoUeIdV ai3aWc0K+ZyELBk41fkVPD3LJ8wH4hmyZxg1OaemtsxijzRk40aE5Qc+vjvQK54BhI RemfVJoMlMSNaToamDKuRtgopYkVulSOcg+3wHrsPgnTSu7ahelh5Tll4XkQv/ecuh 32qaGXZNvpEwQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4TwFjp2sJ3z4wcQ; Thu, 14 Mar 2024 16:07:10 +1100 (AEDT) Date: Thu, 14 Mar 2024 16:02:16 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] ip: Use regular htons() for non-constant protocol number in L2_BUF_IP4_PSUM Message-ID: References: <20240306070836.3417504-1-sbrivio@redhat.com> <20240308102838.726dcbbb@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="+itui9IXn0lRL/Qo" Content-Disposition: inline In-Reply-To: <20240308102838.726dcbbb@elisabeth> Message-ID-Hash: 6SINYJNEVNSILU6MUADZZMFZAXQWK6AR X-Message-ID-Hash: 6SINYJNEVNSILU6MUADZZMFZAXQWK6AR 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, Laurent Vivier 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: --+itui9IXn0lRL/Qo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Mar 08, 2024 at 10:28:38AM +0100, Stefano Brivio wrote: > On Fri, 8 Mar 2024 11:55:32 +1100 > David Gibson wrote: >=20 > > On Wed, Mar 06, 2024 at 08:08:36AM +0100, Stefano Brivio wrote: > > > instead of htons_constant(), which is for... constants. > > >=20 > > > Fixes: 5bf200ae8a1a ("tcp, udp: Don't include destination address in = partially precomputed csums") > > > Signed-off-by: Stefano Brivio =20 > >=20 > > Reviewed-by: David Gibson > >=20 > > It seems to get the job done, at what's probably negligible practical > > cost. My perfectionist side has some misgivings: > >=20 > > AIUI, the point of htons_constant() isn't so much that it *requires* a > > constant, but that because it's open-coded in plain arithmetic > > operations the compiler will be able to constant fold it, if it is > > invoked with a constant parameter. >=20 > Right, yes, it doesn't require a constant. Still, I'd argue it's meant > for constants. :) >=20 > > Since htons() is a library > > function, it probably can't be elided in that way. The cost of > > htons_constant() is that it may be a less optimal implementation when > > the calculation really does need to be done at runtime. > >=20 > > I'm still a bit baffled at that Coverity warning: I can't see why it > > doesn't preclude any situation where you want to write out > > calculations for clarity, even though you know the result will be a > > constant (and you expect the compiler to fold it). >=20 > ...maybe it actually does preclude any situation like that? This is the > only example we have with __bswap_constant16(), and variables mixed > (ORed) with constants. Right, but AFAICT there's nothing that should be specific to bswap_constant here, since that's just expanding to some shifts and masks. > Other usages of __bswap_constant16() have just a variable as argument > (no "problem" with that, of course), and we use __bswap_constant_32() > with constants only. >=20 --=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 --+itui9IXn0lRL/Qo Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmXyhKkACgkQzQJF27ox 2GfY2g/7BEAcXJEYnadUZQWz1EHGL4seCw0KM12BcMQasECHHappCfipqSPXs+QT sx9j+SK7124Zo4Wq6AH4rOMLTe7BmpJZ3gPHfsS0vdCNWHvJXUwa5l+iN5Gvc5C9 4fo3QtZv9TkZRZOuluCQC2x0CII0ijBp6P+1uMXzufr7Q3UtUDHSSKUVegq66vxq s1erNfsSaKSj1gOBvItBmUo18uG4uIdH3L0iPvdRfJw8/veZvyPWHhNZMLtcBoBF 6gqorq3lZIl7O26xtOtxrB61s/vOFVwz936qXfeLr8p8lcmX7BtLbhXAKCcFxtZd XCwEqYiIDUnvEAoqGID4U+NH+cQssVBUMzDqpPvleStAiIuSaz5yJbjbxcaQ0o1/ MqCWdSpyhjdwZ9/L0pD4ihT0ptzmodwEN5Y477/yJlmh309MX9YdYZ+IKyKqNbEY C8A+aN/dOJWnWcadzbco2VpkrcoqR/2quIEJL2fr9NkAbJJQoZJDw0zTI0tnEShs ZpcbG2MYw3sUiDRxT1rXMRosJbmxz5/M3lFKk/D/Ko7cjtKtUGj/VFqBVXmy8bq0 sDS8q2eJp0snxgcyE5H0FfEpih2H00lWZPSSFHLHx6Bl0Wpl/u66e8VNj4Od6Her qbrXJMF/aSy84Wa4040inHu1XoD2SPTI0xs0XBDQB6xb/AGfKlQ= =eSAs -----END PGP SIGNATURE----- --+itui9IXn0lRL/Qo--