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=202410 header.b=lZxGT7e3; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 0660E5A061B for ; Fri, 08 Nov 2024 03:23:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202410; t=1731032623; bh=BP9gdPBauEAhDVCY/dHP8QjfQiPo2r5tniMqhw7xJ8k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lZxGT7e3TNNTdDj6eejxv/s+5esjw5D2FCBg6ESyEZBs0zP9RLwMhzZ1JaI2BCX0d cRsLSSr8LQkzh6tTwr6CVuPzEf5c85NhDY/bQQ/4kAzoU8Uj1ZnOAg3/ij7k5Urb23 eh2KKJ4tw8mx9LcOEz1Ij0GdECxPyZPseOtj8w8itS2Q+aQtzDvl+RTTrXq33n3P7q Apxqcju3oeLCzAQpezrUO0xrU+7sHy2Dy1uk699KBWNe9vJtHzVWWbClcvaelWlO6i D5sZDI+TcIM5vcT54asuRPH//OM4LVkcm71x7THlNw1VLzcAoDDtms7gFTdIC31FbC CPxODPVt3LZuw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Xl2mv2MGfz4x7X; Fri, 8 Nov 2024 13:23:43 +1100 (AEDT) Date: Fri, 8 Nov 2024 11:29:58 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 4/6] util: Define small and big thresholds for socket buffers as unsigned long long Message-ID: References: <20241107184331.3164784-1-sbrivio@redhat.com> <20241107184331.3164784-5-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="X8829QcuFHL8p61L" Content-Disposition: inline In-Reply-To: <20241107184331.3164784-5-sbrivio@redhat.com> Message-ID-Hash: 5LLBDF6AYUIVHG5IDJDP6BDP3GY4XCVZ X-Message-ID-Hash: 5LLBDF6AYUIVHG5IDJDP6BDP3GY4XCVZ 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: --X8829QcuFHL8p61L Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 07, 2024 at 07:43:29PM +0100, Stefano Brivio wrote: > On 32-bit architectures, clang-tidy reports: >=20 > /home/pi/passt/tcp.c:728:11: error: performing an implicit widening conve= rsion to type 'uint64_t' (aka 'unsigned long long') of a multiplication per= formed in type 'unsigned long' [bugprone-implicit-widening-of-multiplicatio= n-result,-warnings-as-errors] > 728 | if (v >=3D SNDBUF_BIG) > | ^ > /home/pi/passt/util.h:158:22: note: expanded from macro 'SNDBUF_BIG' > 158 | #define SNDBUF_BIG (4UL * 1024 * 1024) > | ^ > /home/pi/passt/tcp.c:728:11: note: make conversion explicit to silence th= is warning > 728 | if (v >=3D SNDBUF_BIG) > | ^ > /home/pi/passt/util.h:158:22: note: expanded from macro 'SNDBUF_BIG' > 158 | #define SNDBUF_BIG (4UL * 1024 * 1024) > | ^~~~~~~~~~~~~~~~~ > /home/pi/passt/tcp.c:728:11: note: perform multiplication in a wider type > 728 | if (v >=3D SNDBUF_BIG) > | ^ > /home/pi/passt/util.h:158:22: note: expanded from macro 'SNDBUF_BIG' > 158 | #define SNDBUF_BIG (4UL * 1024 * 1024) > | ^~~~~~~~~~ > /home/pi/passt/tcp.c:730:15: error: performing an implicit widening conve= rsion to type 'uint64_t' (aka 'unsigned long long') of a multiplication per= formed in type 'unsigned long' [bugprone-implicit-widening-of-multiplicatio= n-result,-warnings-as-errors] > 730 | else if (v > SNDBUF_SMALL) > | ^ > /home/pi/passt/util.h:159:24: note: expanded from macro 'SNDBUF_SMALL' > 159 | #define SNDBUF_SMALL (128UL * 1024) > | ^ > /home/pi/passt/tcp.c:730:15: note: make conversion explicit to silence th= is warning > 730 | else if (v > SNDBUF_SMALL) > | ^ > /home/pi/passt/util.h:159:24: note: expanded from macro 'SNDBUF_SMALL' > 159 | #define SNDBUF_SMALL (128UL * 1024) > | ^~~~~~~~~~~~ > /home/pi/passt/tcp.c:730:15: note: perform multiplication in a wider type > 730 | else if (v > SNDBUF_SMALL) > | ^ > /home/pi/passt/util.h:159:24: note: expanded from macro 'SNDBUF_SMALL' > 159 | #define SNDBUF_SMALL (128UL * 1024) > | ^~~~~ > /home/pi/passt/tcp.c:731:17: error: performing an implicit widening conve= rsion to type 'uint64_t' (aka 'unsigned long long') of a multiplication per= formed in type 'unsigned long' [bugprone-implicit-widening-of-multiplicatio= n-result,-warnings-as-errors] > 731 | v -=3D v * (v - SNDBUF_SMALL) / (SNDBUF_BIG - SND= BUF_SMALL) / 2; > | ^ > /home/pi/passt/util.h:159:24: note: expanded from macro 'SNDBUF_SMALL' > 159 | #define SNDBUF_SMALL (128UL * 1024) > | ^ > /home/pi/passt/tcp.c:731:17: note: make conversion explicit to silence th= is warning > 731 | v -=3D v * (v - SNDBUF_SMALL) / (SNDBUF_BIG - SND= BUF_SMALL) / 2; > | ^ > /home/pi/passt/util.h:159:24: note: expanded from macro 'SNDBUF_SMALL' > 159 | #define SNDBUF_SMALL (128UL * 1024) > | ^~~~~~~~~~~~ > /home/pi/passt/tcp.c:731:17: note: perform multiplication in a wider type > 731 | v -=3D v * (v - SNDBUF_SMALL) / (SNDBUF_BIG - SND= BUF_SMALL) / 2; > | ^ > /home/pi/passt/util.h:159:24: note: expanded from macro 'SNDBUF_SMALL' > 159 | #define SNDBUF_SMALL (128UL * 1024) > | ^~~~~ >=20 > because, wherever we use those thresholds, we define the other term > of comparison as uint64_t. Define the thresholds as unsigned long long > as well, to make sure we match types. >=20 > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > util.h | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) >=20 > diff --git a/util.h b/util.h > index 582ef57..963f57b 100644 > --- a/util.h > +++ b/util.h > @@ -158,9 +158,9 @@ int do_clone(int (*fn)(void *), char *stack_area, siz= e_t stack_size, int flags, > (void *)(arg)); \ > } while (0) > =20 > -#define RCVBUF_BIG (2UL * 1024 * 1024) > -#define SNDBUF_BIG (4UL * 1024 * 1024) > -#define SNDBUF_SMALL (128UL * 1024) > +#define RCVBUF_BIG (2ULL * 1024 * 1024) > +#define SNDBUF_BIG (4ULL * 1024 * 1024) > +#define SNDBUF_SMALL (128ULL * 1024) > =20 > #include > #include --=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 --X8829QcuFHL8p61L Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmctW4UACgkQzQJF27ox 2Gdy2g//Rr8NUcL3EQqJDUtqAR39fuvwTbaKw/iPMrg0MWHzsEI1nfJq1xlBeyiU /tBkwboyrpXk2ZA/CmTi9RPTaaEwducf3qkm/eh5DvQW++gcipTOPe9KJzGL/ARy Xw1799FitAYEc6vcjRVLLX1jMPNvuMF8hf2FyVOqTdlBhaHXChGTVoc5y1x5om8r RiCpiPAZ62v5D07g7zl3ennIQhEm1r8qoKpc8aKp9Lk86VWdZ3Q08+q7Cra0n9sl sNmPNVoGyQeCVwwN8sASP5bxLgEc7FlI6garBNCbcfo1scffxQR75i6154SbX7fI mjxdigGMbCk0hZjgl2WgPBxfmMgC8jmQW9BUT8EtsJUPL0oE4FDcAigAMMMZJg5K TXnUBM3f/+xZCScMd1vp3oBnU7eeGgXmGQ47U9UAQU3Jy/5I4fWZ6t9qFu91vu9C nnDGVuzV2S3oTW6/XFUc3NfXYr2ompcaobEP4PAyNz6tPlAg0axkumAujFMkXQ5R ZdcHOxeOM1eMbRoJfURByLcAlXgMicFtJ6RqkQb/CEZ7sEK5EC2u0vJ3b/i8/2Tp 8IGSBRyz71CaAED1fyh6R1ZgFpprLNJmDicTJD6MoW8CQW+bkrQmNnV1j84y9X5t FqGFLBc8t8u/QaHsFNDFCQQr1vNxeGgrGhFBpXTtx23PhJN67Gk= =rBTo -----END PGP SIGNATURE----- --X8829QcuFHL8p61L--