[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210324194911.GA18844@yury-ThinkPad>
Date: Wed, 24 Mar 2021 12:49:11 -0700
From: Yury Norov <yury.norov@...il.com>
To: Rasmus Villemoes <linux@...musvillemoes.dk>
Cc: linux-kernel@...r.kernel.org, linux-m68k@...ts.linux-m68k.org,
linux-arch@...r.kernel.org, linux-sh@...r.kernel.org,
Alexey Klimov <aklimov@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Arnd Bergmann <arnd@...db.de>, David Sterba <dsterba@...e.com>,
Dennis Zhou <dennis@...nel.org>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Jianpeng Ma <jianpeng.ma@...el.com>,
Joe Perches <joe@...ches.com>,
John Paul Adrian Glaubitz <glaubitz@...sik.fu-berlin.de>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Rich Felker <dalias@...c.org>,
Stefano Brivio <sbrivio@...hat.com>,
Wei Yang <richard.weiyang@...ux.alibaba.com>,
Wolfram Sang <wsa+renesas@...g-engineering.com>,
Yoshinori Sato <ysato@...rs.sourceforge.jp>
Subject: Re: [PATCH 06/12] tools: sync small_const_nbits() macro with the
kernel
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@...il.com>
> > ---
> > 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@...musvillemoes.dk>
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
>From 7558697d4448f01a8ef73cd31def5d3e68b44b61 Mon Sep 17 00:00:00 2001
From: Yury Norov <yury.norov@...il.com>
Date: Wed, 17 Feb 2021 20:05:05 -0800
Subject: [PATCH] tools: sync small_const_nbits() macro with the kernel
Sync implementation with the kernel and move the macro from
tools/include/linux/bitmap.h to tools/include/asm-generic/bitsperlong.h
Signed-off-by: Yury Norov <yury.norov@...il.com>
---
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..2093d56ddd11 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 && (nbits) > 0)
+
#endif /* __ASM_GENERIC_BITS_PER_LONG */
diff --git a/tools/include/linux/bitmap.h b/tools/include/linux/bitmap.h
index 4aabc23ec747..330dbf7509cc 100644
--- a/tools/include/linux/bitmap.h
+++ b/tools/include/linux/bitmap.h
@@ -22,9 +22,6 @@ void bitmap_clear(unsigned long *map, unsigned int start, int len);
#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1)))
#define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1)))
-#define small_const_nbits(nbits) \
- (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
-
static inline void bitmap_zero(unsigned long *dst, unsigned int nbits)
{
if (small_const_nbits(nbits))
--
2.25.1
Powered by blists - more mailing lists