From: Yury Norov <yury.norov@gmail.com>
To: I Hsin Cheng <richard120310@gmail.com>
Cc: david.laight.linux@gmail.com, anshuman.khandual@arm.com,
arnd@arndb.de, linux-kernel@vger.kernel.org,
jserv@ccns.ncku.edu.tw, skhan@linuxfoundation.org,
mka@chromium.org, akpm@linux-foundation.org
Subject: Re: [PATCH v3 RESEND] uapi: Revert "bitops: avoid integer overflow in GENMASK(_ULL)"
Date: Fri, 28 Feb 2025 13:08:10 -0500 [thread overview]
Message-ID: <Z8H7ima1qAsHNhuu@thinkpad> (raw)
In-Reply-To: <20250226065623.1567363-1-richard120310@gmail.com>
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@gmail.com>
Applied in bitmap-for-next. Thanks for the work!
next prev parent reply other threads:[~2025-02-28 18:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-26 6:56 [PATCH v3 RESEND] uapi: Revert "bitops: avoid integer overflow in GENMASK(_ULL)" I Hsin Cheng
2025-02-28 18:08 ` Yury Norov [this message]
2025-03-02 22:38 ` David Laight
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z8H7ima1qAsHNhuu@thinkpad \
--to=yury.norov@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=arnd@arndb.de \
--cc=david.laight.linux@gmail.com \
--cc=jserv@ccns.ncku.edu.tw \
--cc=linux-kernel@vger.kernel.org \
--cc=mka@chromium.org \
--cc=richard120310@gmail.com \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.