diff options
| author | Yury Norov <ynorov@nvidia.com> | 2026-03-12 19:08:16 -0400 |
|---|---|---|
| committer | Yury Norov <ynorov@nvidia.com> | 2026-03-23 13:33:51 -0400 |
| commit | 4e64c91b813f666dffc3962a815a8a50b7d6f468 (patch) | |
| tree | c96774c9277e2e98429970e03472d7813afe6c33 /include/asm-x86/git@git.tavy.me:linux.git | |
| parent | 18c48899653fa7a04120537c228031b5c7e4e9d6 (diff) | |
lib: count_zeros: fix 32/64-bit inconsistency in count_trailing_zeros()
Based on 'sizeof(x) == 4' condition, in 32-bit case the function is wired
to ffs(), while in 64-bit case to __ffs(). The difference is substantial:
ffs(x) == __ffs(x) + 1. Also, ffs(0) == 0, while __ffs(0) is undefined.
The 32-bit behaviour is inconsistent with the function description, so it
needs to get fixed.
There are 9 individual users for the function in 6 different subsystems.
Some arches and drivers are 64-bit only:
- arch/loongarch/kvm/intc/eiointc.c;
- drivers/hv/mshv_vtl_main.c;
- kernel/liveupdate/kexec_handover.c;
The others are:
- ib_umem_find_best_pgsz(): as per comment, __ffs() should be correct;
- rzv2m_csi_reg_write_bit(): ARCH_RENESAS only, unclear;
- lz77_match_len(): CIFS_COMPRESSION only, unclear, experimental;
IB and CIFS are explicitly OK with the change.
The attached patch gets rid of 32-bit explicit support, so that both
32- and 64-bit versions rely on __ffs().
CC: K. Y. Srinivasan <kys@microsoft.com>
CC: Haiyang Zhang <haiyangz@microsoft.com>
CC: Mark Brown <broonie@kernel.org>
CC: Steve French <sfrench@samba.org>
CC: Alexander Graf <graf@amazon.com>
CC: Mike Rapoport <rppt@kernel.org>
CC: Pasha Tatashin <pasha.tatashin@soleen.com>
Acked-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Yury Norov <ynorov@nvidia.com>
Diffstat (limited to 'include/asm-x86/git@git.tavy.me:linux.git')
0 files changed, 0 insertions, 0 deletions
