From: Yury Norov <ynorov@nvidia.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: Jason Gunthorpe <jgg@nvidia.com>,
Yury Norov <yury.norov@gmail.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Eric Biggers <ebiggers@kernel.org>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
Ard Biesheuvel <ardb@kernel.org>,
linux-kernel@vger.kernel.org, kexec@lists.infradead.org,
linux-cifs@vger.kernel.org, linux-spi@vger.kernel.org,
linux-hyperv@vger.kernel.org,
"K. Y. Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Mark Brown <broonie@kernel.org>, Steve French <sfrench@samba.org>,
Alexander Graf <graf@amazon.com>, Mike Rapoport <rppt@kernel.org>,
Pasha Tatashin <pasha.tatashin@soleen.com>
Subject: Re: [PATCH] lib: count_zeros: fix 32/64-bit inconsistency in count_trailing_zeros()
Date: Wed, 18 Mar 2026 12:31:55 -0400 [thread overview]
Message-ID: <abrTexSs8F3jiJtf@yury> (raw)
In-Reply-To: <20260317091411.GQ61385@unreal>
On Tue, Mar 17, 2026 at 11:14:11AM +0200, Leon Romanovsky wrote:
> On Fri, Mar 13, 2026 at 02:14:49PM -0400, Yury Norov wrote:
> > On Fri, Mar 13, 2026 at 02:18:55PM -0300, Jason Gunthorpe wrote:
> > > On Thu, Mar 12, 2026 at 07:08:16PM -0400, Yury Norov wrote:
> > > > 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;
> > >
> > > So long as 32 bit works the same as 64 bit it is correct for ib
> >
> > This is what the patch does, except that it doesn't account for the
> > word length. In you case, 'mask' is dma_addr_t, which is u32 or u64
> > depending ARCH_DMA_ADDR_T_64BIT.
> >
> > This config is:
> >
> > config ARCH_DMA_ADDR_T_64BIT
> > def_bool 64BIT || PHYS_ADDR_T_64BIT
> >
> > And PHYS_ADDR_T_64BIT is simply def_bool 64BIT. So, at least now
> > dma_addr_t simply follows unsigned long, and thus, the patch is
> > correct. But IDK what's the history behind this configurations.
> >
> > Anyways, the patch aligns 32-bit count_trailing_zeros() with the
> > 64-bit one. If you OK with that, as you said, can you please send
> > an explicit ack?
>
> I can do that, 32 bits architectures are rarely used in the IB world.
>
> Thanks,
> Acked-by: Leon Romanovsky <leon@kernel.org>
Thanks, Leon. Seemingly no headwinds for the patch. Taking in in -next
for testing.
Thanks,
Yury
prev parent reply other threads:[~2026-03-18 16:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 23:08 [PATCH] lib: count_zeros: fix 32/64-bit inconsistency in count_trailing_zeros() Yury Norov
2026-03-12 23:54 ` Enzo Matsumiya
2026-03-13 16:31 ` Yury Norov
2026-03-13 9:47 ` Andy Shevchenko
2026-03-13 17:48 ` Yury Norov
2026-03-13 18:41 ` Konstantin Ryabitsev
2026-03-13 17:18 ` Jason Gunthorpe
2026-03-13 18:14 ` Yury Norov
2026-03-17 9:14 ` Leon Romanovsky
2026-03-18 16:31 ` Yury Norov [this message]
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=abrTexSs8F3jiJtf@yury \
--to=ynorov@nvidia.com \
--cc=Jason@zx2c4.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=ardb@kernel.org \
--cc=broonie@kernel.org \
--cc=ebiggers@kernel.org \
--cc=graf@amazon.com \
--cc=haiyangz@microsoft.com \
--cc=jgg@nvidia.com \
--cc=kexec@lists.infradead.org \
--cc=kys@microsoft.com \
--cc=leon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=pasha.tatashin@soleen.com \
--cc=rppt@kernel.org \
--cc=sfrench@samba.org \
--cc=yury.norov@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox