Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-08-14 Thread Andy Shevchenko
On Tue, Aug 7, 2018 at 2:22 PM, Wei Wang wrote: > On 08/07/2018 06:26 PM, Andy Shevchenko wrote: > "there", I meant that user-space port, not in the kernel. > e.g. > Line 225 at https://github.com/qemu/qemu/blob/master/include/qemu/bitmap.h > (there are a couple of other places) So, means no

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-08-14 Thread Andy Shevchenko
On Tue, Aug 7, 2018 at 2:22 PM, Wei Wang wrote: > On 08/07/2018 06:26 PM, Andy Shevchenko wrote: > "there", I meant that user-space port, not in the kernel. > e.g. > Line 225 at https://github.com/qemu/qemu/blob/master/include/qemu/bitmap.h > (there are a couple of other places) So, means no

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-08-07 Thread Wei Wang
On 08/07/2018 06:26 PM, Andy Shevchenko wrote: Probably it's more clear to post the entire function here for a discussion: int __bitmap_weight(const unsigned long *bitmap, unsigned int bits) { unsigned int k, lim = bits/BITS_PER_LONG; int w = 0; for (k = 0; k < lim;

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-08-07 Thread Wei Wang
On 08/07/2018 06:26 PM, Andy Shevchenko wrote: Probably it's more clear to post the entire function here for a discussion: int __bitmap_weight(const unsigned long *bitmap, unsigned int bits) { unsigned int k, lim = bits/BITS_PER_LONG; int w = 0; for (k = 0; k < lim;

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-08-07 Thread Andy Shevchenko
On Tue, Aug 7, 2018 at 10:03 AM, Wei Wang wrote: > On 08/07/2018 07:30 AM, Rasmus Villemoes wrote: >> On 2018-07-26 12:15, Wei Wang wrote: >>> if (bits % BITS_PER_LONG) >>> w += hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits)); >>> >>> we could remove the "if" check by "w +=

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-08-07 Thread Andy Shevchenko
On Tue, Aug 7, 2018 at 10:03 AM, Wei Wang wrote: > On 08/07/2018 07:30 AM, Rasmus Villemoes wrote: >> On 2018-07-26 12:15, Wei Wang wrote: >>> if (bits % BITS_PER_LONG) >>> w += hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits)); >>> >>> we could remove the "if" check by "w +=

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-08-07 Thread Wei Wang
On 08/07/2018 03:03 PM, Wei Wang wrote: On 08/07/2018 07:30 AM, Rasmus Villemoes wrote: On 2018-07-26 12:15, Wei Wang wrote: On 07/26/2018 05:37 PM, Yury Norov wrote: On Thu, Jul 26, 2018 at 04:07:51PM +0800, Wei Wang wrote: The existing BITMAP_LAST_WORD_MASK macro returns 0x if

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-08-07 Thread Wei Wang
On 08/07/2018 03:03 PM, Wei Wang wrote: On 08/07/2018 07:30 AM, Rasmus Villemoes wrote: On 2018-07-26 12:15, Wei Wang wrote: On 07/26/2018 05:37 PM, Yury Norov wrote: On Thu, Jul 26, 2018 at 04:07:51PM +0800, Wei Wang wrote: The existing BITMAP_LAST_WORD_MASK macro returns 0x if

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-08-07 Thread Wei Wang
On 08/07/2018 07:30 AM, Rasmus Villemoes wrote: On 2018-07-26 12:15, Wei Wang wrote: On 07/26/2018 05:37 PM, Yury Norov wrote: On Thu, Jul 26, 2018 at 04:07:51PM +0800, Wei Wang wrote: The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is 0. This patch changes the macro to

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-08-07 Thread Wei Wang
On 08/07/2018 07:30 AM, Rasmus Villemoes wrote: On 2018-07-26 12:15, Wei Wang wrote: On 07/26/2018 05:37 PM, Yury Norov wrote: On Thu, Jul 26, 2018 at 04:07:51PM +0800, Wei Wang wrote: The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is 0. This patch changes the macro to

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-08-06 Thread Rasmus Villemoes
On 2018-07-26 12:15, Wei Wang wrote: > On 07/26/2018 05:37 PM, Yury Norov wrote: >> On Thu, Jul 26, 2018 at 04:07:51PM +0800, Wei Wang wrote: >>> The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is >>> 0. This patch changes the macro to return 0 when there is no bit >>> needs

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-08-06 Thread Rasmus Villemoes
On 2018-07-26 12:15, Wei Wang wrote: > On 07/26/2018 05:37 PM, Yury Norov wrote: >> On Thu, Jul 26, 2018 at 04:07:51PM +0800, Wei Wang wrote: >>> The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is >>> 0. This patch changes the macro to return 0 when there is no bit >>> needs

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-07-26 Thread Wei Wang
On 07/26/2018 08:10 PM, Yury Norov wrote: On Thu, Jul 26, 2018 at 06:15:59PM +0800, Wei Wang wrote: External Email On 07/26/2018 05:37 PM, Yury Norov wrote: On Thu, Jul 26, 2018 at 04:07:51PM +0800, Wei Wang wrote: The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is 0.

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-07-26 Thread Wei Wang
On 07/26/2018 08:10 PM, Yury Norov wrote: On Thu, Jul 26, 2018 at 06:15:59PM +0800, Wei Wang wrote: External Email On 07/26/2018 05:37 PM, Yury Norov wrote: On Thu, Jul 26, 2018 at 04:07:51PM +0800, Wei Wang wrote: The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is 0.

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-07-26 Thread Andy Shevchenko
On Thu, Jul 26, 2018 at 1:08 PM, Wei Wang wrote: > On 07/26/2018 04:48 PM, Andy Shevchenko wrote: >> >> On Thu, Jul 26, 2018 at 11:07 AM, Wei Wang wrote: >>> >>> The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is >>> 0. This patch changes the macro to return 0 when there is

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-07-26 Thread Andy Shevchenko
On Thu, Jul 26, 2018 at 1:08 PM, Wei Wang wrote: > On 07/26/2018 04:48 PM, Andy Shevchenko wrote: >> >> On Thu, Jul 26, 2018 at 11:07 AM, Wei Wang wrote: >>> >>> The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is >>> 0. This patch changes the macro to return 0 when there is

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-07-26 Thread Yury Norov
On Thu, Jul 26, 2018 at 06:15:59PM +0800, Wei Wang wrote: > External Email > > On 07/26/2018 05:37 PM, Yury Norov wrote: > > On Thu, Jul 26, 2018 at 04:07:51PM +0800, Wei Wang wrote: > > > The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is > > > 0. This patch changes the

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-07-26 Thread Yury Norov
On Thu, Jul 26, 2018 at 06:15:59PM +0800, Wei Wang wrote: > External Email > > On 07/26/2018 05:37 PM, Yury Norov wrote: > > On Thu, Jul 26, 2018 at 04:07:51PM +0800, Wei Wang wrote: > > > The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is > > > 0. This patch changes the

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-07-26 Thread Wei Wang
On 07/26/2018 05:37 PM, Yury Norov wrote: On Thu, Jul 26, 2018 at 04:07:51PM +0800, Wei Wang wrote: The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is 0. This patch changes the macro to return 0 when there is no bit needs to be masked. I think this is intentional behavour.

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-07-26 Thread Wei Wang
On 07/26/2018 05:37 PM, Yury Norov wrote: On Thu, Jul 26, 2018 at 04:07:51PM +0800, Wei Wang wrote: The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is 0. This patch changes the macro to return 0 when there is no bit needs to be masked. I think this is intentional behavour.

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-07-26 Thread Wei Wang
On 07/26/2018 04:48 PM, Andy Shevchenko wrote: On Thu, Jul 26, 2018 at 11:07 AM, Wei Wang wrote: The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is 0. This patch changes the macro to return 0 when there is no bit needs to be masked. Can you provide a practical example of

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-07-26 Thread Wei Wang
On 07/26/2018 04:48 PM, Andy Shevchenko wrote: On Thu, Jul 26, 2018 at 11:07 AM, Wei Wang wrote: The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is 0. This patch changes the macro to return 0 when there is no bit needs to be masked. Can you provide a practical example of

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-07-26 Thread Yury Norov
On Thu, Jul 26, 2018 at 04:07:51PM +0800, Wei Wang wrote: > The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is > 0. This patch changes the macro to return 0 when there is no bit needs to > be masked. I think this is intentional behavour. Previous version did return ~0UL

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-07-26 Thread Yury Norov
On Thu, Jul 26, 2018 at 04:07:51PM +0800, Wei Wang wrote: > The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is > 0. This patch changes the macro to return 0 when there is no bit needs to > be masked. I think this is intentional behavour. Previous version did return ~0UL

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-07-26 Thread Andy Shevchenko
On Thu, Jul 26, 2018 at 11:07 AM, Wei Wang wrote: > The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is > 0. This patch changes the macro to return 0 when there is no bit needs to > be masked. > Can you provide a practical example of what's going wrong before this patch

Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-07-26 Thread Andy Shevchenko
On Thu, Jul 26, 2018 at 11:07 AM, Wei Wang wrote: > The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is > 0. This patch changes the macro to return 0 when there is no bit needs to > be masked. > Can you provide a practical example of what's going wrong before this patch

[PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-07-26 Thread Wei Wang
The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is 0. This patch changes the macro to return 0 when there is no bit needs to be masked. Signed-off-by: Wei Wang Cc: Andrew Morton Cc: Rasmus Villemoes Cc: Yury Norov --- include/linux/bitmap.h | 5 - 1 file changed, 4

[PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK

2018-07-26 Thread Wei Wang
The existing BITMAP_LAST_WORD_MASK macro returns 0x if nbits is 0. This patch changes the macro to return 0 when there is no bit needs to be masked. Signed-off-by: Wei Wang Cc: Andrew Morton Cc: Rasmus Villemoes Cc: Yury Norov --- include/linux/bitmap.h | 5 - 1 file changed, 4