Re: [PATCH] RAS/AMD/ATL: Replace bitwise_xor_bits() with hweight16()
From: Borislav Petkov
Date: Mon Nov 24 2025 - 12:06:22 EST
On Mon, Nov 24, 2025 at 04:25:17PM +0200, Nikolay Borisov wrote:
> Doing hweight16 and checking whether the lsb is set is functionally
> equivalent to what bitwise_xor_bits() does. In addition it results in
> better generated code as before gcc would inline the function 4 times.
> With hweight, the resulting code boils down to 2 instructions - popcnt
> and andl as all cpus we care about has popcnt. No functional changes.
>
> An alternative would have been to use the __builtin_parity() function provided
> by both Clang/GCC, however under some circumstances the compiler can choose not
> to inline it but generate a library call which is unsupported in the kernel.
>
> Signed-off-by: Nikolay Borisov <nik.borisov@xxxxxxxx>
> ---
> drivers/ras/amd/atl/umc.c | 21 +++++----------------
> 1 file changed, 5 insertions(+), 16 deletions(-)
Applied, thanks.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette