]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
RAS/AMD/ATL: Replace bitwise_xor_bits() with hweight16()
authorNikolay Borisov <nik.borisov@suse.com>
Mon, 24 Nov 2025 14:25:17 +0000 (16:25 +0200)
committerBorislav Petkov (AMD) <bp@alien8.de>
Mon, 24 Nov 2025 16:00:37 +0000 (17:00 +0100)
commit69acbdbbefbda7b7b32faa706a8f68c399c9e47b
tree3b4d570a2f8504f128d1ad4cff94be2541a51504
parent187d1b27a1e436822c31e43aa58505f6dd8987e2
RAS/AMD/ATL: Replace bitwise_xor_bits() with hweight16()

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 hweight16(),
the resulting code boils down to 2 instructions -  POPCNT and AND, and all
relevant CPUs support POPCNT.

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.

No functional changes.

  [ bp: Massage commit message. ]

Signed-off-by: Nikolay Borisov <nik.borisov@suse.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://patch.msgid.link/20251124142517.1708451-1-nik.borisov@suse.com
drivers/ras/amd/atl/umc.c