mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yury Norov <ynorov@caviumnetworks.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: kbuild test robot <lkp@intel.com>,
	kbuild-all@01.org, Noam Camus <noamca@mellanox.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Matthew Wilcox <mawilcox@microsoft.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] lib: add test for bitmap_parselist()
Date: Thu, 10 Aug 2017 01:52:31 +0300	[thread overview]
Message-ID: <20170809225231.ythrktk43gswfnjd@yury-thinkpad> (raw)
In-Reply-To: <20170809133309.746aafee5e22c9345debd671@linux-foundation.org>

On Wed, Aug 09, 2017 at 01:33:09PM -0700, Andrew Morton wrote:
> On Wed, 9 Aug 2017 11:28:56 +0800 kbuild test robot <lkp@intel.com> wrote:
> 
> > [auto build test WARNING on linus/master]
> > [also build test WARNING on v4.13-rc4 next-20170808]
> > [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
> > 
> > url:    https://github.com/0day-ci/linux/commits/Yury-Norov/lib-make-bitmap_parselist-thread-safe-and-much-faster/20170809-105307
> > config: i386-randconfig-x000-201732 (attached as .config)
> > compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
> > reproduce:
> >         # save the attached .config to linux build tree
> >         make ARCH=i386 
> > 
> > All warnings (new ones prefixed by >>):
> > 
> > >> lib/test_bitmap.c:180:17: warning: large integer implicitly truncated to unsigned type [-Woverflow]
> >         0xfffffffe, 0x3333333311111111, 0xffffffff77777777};
> >                     ^~~~~~~~~~~~~~~~~~
 
Ahh... I didn't take 32-bit arches into account...

> I assume that a simple convertion to unsigned long long will fix that,
> but I'll await Yuri's input (and testing).

The conversion to unsigned long long will work only for little endian
32-bit arches. We trapped into it once:
https://patchwork.kernel.org/patch/9260919+/

It should be the compile-time analogue of bitmap_from_u64()

The patch is attached and seems working to me. But I need some time
for testing...

Yury

>From be0e663b804daff0d0512e72cf94b5143270bd29 Mon Sep 17 00:00:00 2001
From: Yury Norov <ynorov@caviumnetworks.com>
Date: Thu, 10 Aug 2017 01:25:46 +0300
Subject: [PATCH] bitmap: introduce BITMAP_FROM_U64() and use it in test for
 bitmap_parselist()

The macro is the compile-time analogue of bitmap_from_u64() with the
same purpose: convert the 64-bit number to the properly ordered pair
of 32-bit parts to be suitable for filling the bitmap.

Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
---
 include/linux/bitmap.h |  6 ++++++
 lib/test_bitmap.c      | 23 +++++++++++++++++++----
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 5797ca6fdfe2..bdc487e47de1 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -378,6 +378,12 @@ static inline void bitmap_from_u64(unsigned long *dst, u64 mask)
 		dst[1] = mask >> 32;
 }
 
+#if __BITS_PER_LONG == 64
+#define BITMAP_FROM_U64(n) (n)
+#else
+#define BITMAP_FROM_U64(n) ((n) & ULONG_MAX), ((unsigned long long) (n) >> 32)
+#endif
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __LINUX_BITMAP_H */
diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
index 5b80dd94e4d1..65b8fcc41fd0 100644
--- a/lib/test_bitmap.c
+++ b/lib/test_bitmap.c
@@ -175,10 +175,25 @@ struct test_bitmap_parselist{
 	const int flags;
 };
 
-static const unsigned long exp[] = {1, 2, 0x0000ffff, 0xffff0000, 0x55555555,
-				0xaaaaaaaa, 0x11111111, 0x22222222, 0xffffffff,
-				0xfffffffe, 0x3333333311111111, 0xffffffff77777777};
-static const unsigned long exp2[] = {0x3333333311111111, 0xffffffff77777777};
+static const unsigned long exp[] __initconst = {
+	BITMAP_FROM_U64(1),
+	BITMAP_FROM_U64(2),
+	BITMAP_FROM_U64(0x0000ffff),
+	BITMAP_FROM_U64(0xffff0000),
+	BITMAP_FROM_U64(0x55555555),
+	BITMAP_FROM_U64(0xaaaaaaaa),
+	BITMAP_FROM_U64(0x11111111),
+	BITMAP_FROM_U64(0x22222222),
+	BITMAP_FROM_U64(0xffffffff),
+	BITMAP_FROM_U64(0xfffffffe),
+	BITMAP_FROM_U64(0x3333333311111111),
+	BITMAP_FROM_U64(0xffffffff77777777)
+};
+
+static const unsigned long exp2[] __initconst = {
+	BITMAP_FROM_U64(0x3333333311111111),
+	BITMAP_FROM_U64(0xffffffff77777777)
+};
 
 static const struct test_bitmap_parselist parselist_tests[] __initconst = {
 	{0, "0",			&exp[0], 8, 0},
-- 
2.11.0

  reply	other threads:[~2017-08-09 22:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-07 22:54 [PATCH 1/2] lib: make bitmap_parselist thread-safe and much faster Yury Norov
2017-08-07 22:54 ` [PATCH 2/2] lib: add test for bitmap_parselist() Yury Norov
2017-08-09  3:28   ` kbuild test robot
2017-08-09 20:33     ` Andrew Morton
2017-08-09 22:52       ` Yury Norov [this message]
2017-08-10  7:30         ` Rasmus Villemoes
2017-08-10 10:37           ` Yury Norov
2017-08-09  4:11   ` kbuild test robot
2017-08-09 20:28     ` Andrew Morton

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=20170809225231.ythrktk43gswfnjd@yury-thinkpad \
    --to=ynorov@caviumnetworks.com \
    --cc=akpm@linux-foundation.org \
    --cc=kbuild-all@01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=lkp@intel.com \
    --cc=mawilcox@microsoft.com \
    --cc=mchehab@kernel.org \
    --cc=noamca@mellanox.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

all inboxes | Powered by JetHome®