Re: [PATCH 06/12] tools: sync small_const_nbits() macro with the kernel
From: Yury Norov
Date: Wed Mar 24 2021 - 15:50:08 EST
On Mon, Mar 22, 2021 at 09:34:47AM +0100, Rasmus Villemoes wrote:
> On 21/03/2021 22.54, Yury Norov wrote:
> > Move the macro from tools/include/asm-generic/bitsperlong.h
> > to tools/include/linux/bitmap.h
>
> The patch does it the other way around :)
>
> > Signed-off-by: Yury Norov <yury.norov@xxxxxxxxx>
> > ---
> > tools/include/asm-generic/bitsperlong.h | 3 +++
> > tools/include/linux/bitmap.h | 3 ---
> > 2 files changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/tools/include/asm-generic/bitsperlong.h b/tools/include/asm-generic/bitsperlong.h
> > index 8f2283052333..f530da2506cc 100644
> > --- a/tools/include/asm-generic/bitsperlong.h
> > +++ b/tools/include/asm-generic/bitsperlong.h
> > @@ -18,4 +18,7 @@
> > #define BITS_PER_LONG_LONG 64
> > #endif
> >
> > +#define small_const_nbits(nbits) \
> > + (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
> > +
>
> Well, the movement is consistent with the kernel, but shouldn't the
> definition also be updated to exclude constant-zero-size? It's not that
> they exist or ever have, in tools/ or kernel proper, but just if some
> day some oddball CONFIG_ combination ends up creating such a beast, I'd
> rather not have code like
>
> + if (small_const_nbits(size)) {
> + unsigned long val = *addr & GENMASK(size - 1, 0);
>
> blow up at run-time.
>
> Other than that (and the above commit log typo), consider the series
>
> Acked-by: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>
Thanks for spotting out this. The proper version of the patch is
below.
Andrew, it seems everything else looks good. If so, should I resubmit
the series, or you can pull it as is, including this patch?
Thanks,
Yury