[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z8H7ima1qAsHNhuu@thinkpad>
Date: Fri, 28 Feb 2025 13:08:10 -0500
From: Yury Norov <yury.norov@...il.com>
To: I Hsin Cheng <richard120310@...il.com>
Cc: david.laight.linux@...il.com, anshuman.khandual@....com, arnd@...db.de,
linux-kernel@...r.kernel.org, jserv@...s.ncku.edu.tw,
skhan@...uxfoundation.org, mka@...omium.org,
akpm@...ux-foundation.org
Subject: Re: [PATCH v3 RESEND] uapi: Revert "bitops: avoid integer overflow
in GENMASK(_ULL)"
On Wed, Feb 26, 2025 at 02:56:23PM +0800, I Hsin Cheng wrote:
> This patch reverts 'commit c32ee3d9abd2("bitops: avoid integer overflow in
> GENMASK(_ULL)")'.
>
> The code generation can be shrink by over 1KB by reverting this commit.
> Originally the commit claimed that clang would emit warnings using the
> implementation at that time.
>
> The patch was applied and tested against numerous compilers, including
> gcc-13, gcc-12, gcc-11 cross-compiler, clang-17, clang-18 and clang-19.
> Various warning levels were set (-W=0, -W=1, -W=2) and CONFIG_WERROR
> disabled to complete the compilation. The results show that no compilation
> errors or warnings were generated due to the patch.
>
> The results of code size reduction are summarized in the following table.
> The code size changes for clang are all zero across different versions,
> so they're not listed in the table.
>
> For NR_CPUS=64 on x86_64.
> ----------------------------------------------
> | | gcc-13 | gcc-12 | gcc-11 |
> ----------------------------------------------
> | old | 22438085 | 22453915 | 22302033 |
> ----------------------------------------------
> | new | 22436816 | 22452913 | 22300826 |
> ----------------------------------------------
> | new - old | -1269 | -1002 | -1207 |
> ----------------------------------------------
>
> For NR_CPUS=1024 on x86_64.
> ----------------------------------------------
> | | gcc-13 | gcc-12 | gcc-11 |
> ----------------------------------------------
> | old | 22493682 | 22509812 | 22357661 |
> ----------------------------------------------
> | new | 22493230 | 22509487 | 22357250 |
> ----------------------------------------------
> | new - old | -452 | -325 | -411 |
> ----------------------------------------------
>
> For arm64 architecture, gcc cross-compiler was used and QEMU was
> utilized to execute a VM for a CPU-heavy workload to ensure no
> side effects and that functionalities remained correct. The test
> even demonstrated a positive result in terms of code size reduction:
> * Before: 31660668
> * After: 31658724
> * Difference (After - Before): -1944
>
> An analysis of multiple functions compiled with gcc-13 on x86_64 was
> performed. In summary, the patch elimates one negation in almost
> every use case. However, negative effects may occur in some cases,
> such as the generation of additional "mov" instruction or increased
> register usage. The use of "~_UL(0) << (l)" may even result in the
> allocations of "%r*" registers instead of "%e*" registers (which are
> 32-bit registers) because the compiler cannot assume that the higher
> bits are zero.
>
> Signed-off-by: I Hsin Cheng <richard120310@...il.com>
Applied in bitmap-for-next. Thanks for the work!
Powered by blists - more mailing lists