* [PATCH] bitops: use the same mechanism for get_count_order[_long]
@ 2020-05-25 21:59 Wei Yang
2020-05-26 7:04 ` Andy Shevchenko
2020-05-30 21:22 ` Wei Yang
0 siblings, 2 replies; 4+ messages in thread
From: Wei Yang @ 2020-05-25 21:59 UTC (permalink / raw)
To: akpm, andriy.shevchenko, christian.brauner; +Cc: linux-kernel, Wei Yang
These two functions share the same logic.
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
include/linux/bitops.h | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 5b5609e81a84..80703ef27aee 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -188,12 +188,10 @@ static inline unsigned fls_long(unsigned long l)
static inline int get_count_order(unsigned int count)
{
- int order;
+ if (count == 0)
+ return -1;
- order = fls(count) - 1;
- if (count & (count - 1))
- order++;
- return order;
+ return fls(--count);
}
/**
--
2.23.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] bitops: use the same mechanism for get_count_order[_long]
2020-05-25 21:59 [PATCH] bitops: use the same mechanism for get_count_order[_long] Wei Yang
@ 2020-05-26 7:04 ` Andy Shevchenko
2020-05-26 21:57 ` Wei Yang
2020-05-30 21:22 ` Wei Yang
1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2020-05-26 7:04 UTC (permalink / raw)
To: Wei Yang; +Cc: akpm, christian.brauner, linux-kernel
On Mon, May 25, 2020 at 09:59:58PM +0000, Wei Yang wrote:
> These two functions share the same logic.
So, same comment. Please, add test first, make sure it works on current kernel,
then after your patch applied, and send it as a series, thanks!
P.S. W/o test code looks good, but based on my experience I'm very suspicious
about "small" changes that may lead to big issues. Hope you understand my point.
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> ---
> include/linux/bitops.h | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/bitops.h b/include/linux/bitops.h
> index 5b5609e81a84..80703ef27aee 100644
> --- a/include/linux/bitops.h
> +++ b/include/linux/bitops.h
> @@ -188,12 +188,10 @@ static inline unsigned fls_long(unsigned long l)
>
> static inline int get_count_order(unsigned int count)
> {
> - int order;
> + if (count == 0)
> + return -1;
>
> - order = fls(count) - 1;
> - if (count & (count - 1))
> - order++;
> - return order;
> + return fls(--count);
> }
>
> /**
> --
> 2.23.0
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] bitops: use the same mechanism for get_count_order[_long]
2020-05-26 7:04 ` Andy Shevchenko
@ 2020-05-26 21:57 ` Wei Yang
0 siblings, 0 replies; 4+ messages in thread
From: Wei Yang @ 2020-05-26 21:57 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Wei Yang, akpm, christian.brauner, linux-kernel
On Tue, May 26, 2020 at 10:04:57AM +0300, Andy Shevchenko wrote:
>On Mon, May 25, 2020 at 09:59:58PM +0000, Wei Yang wrote:
>> These two functions share the same logic.
>
>So, same comment. Please, add test first, make sure it works on current kernel,
>then after your patch applied, and send it as a series, thanks!
>
>P.S. W/o test code looks good, but based on my experience I'm very suspicious
>about "small" changes that may lead to big issues. Hope you understand my point.
>
Sure, I see your point.
>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> ---
>> include/linux/bitops.h | 8 +++-----
>> 1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/include/linux/bitops.h b/include/linux/bitops.h
>> index 5b5609e81a84..80703ef27aee 100644
>> --- a/include/linux/bitops.h
>> +++ b/include/linux/bitops.h
>> @@ -188,12 +188,10 @@ static inline unsigned fls_long(unsigned long l)
>>
>> static inline int get_count_order(unsigned int count)
>> {
>> - int order;
>> + if (count == 0)
>> + return -1;
>>
>> - order = fls(count) - 1;
>> - if (count & (count - 1))
>> - order++;
>> - return order;
>> + return fls(--count);
>> }
>>
>> /**
>> --
>> 2.23.0
>>
>
>--
>With Best Regards,
>Andy Shevchenko
>
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] bitops: use the same mechanism for get_count_order[_long]
2020-05-25 21:59 [PATCH] bitops: use the same mechanism for get_count_order[_long] Wei Yang
2020-05-26 7:04 ` Andy Shevchenko
@ 2020-05-30 21:22 ` Wei Yang
1 sibling, 0 replies; 4+ messages in thread
From: Wei Yang @ 2020-05-30 21:22 UTC (permalink / raw)
To: Wei Yang; +Cc: akpm, andriy.shevchenko, christian.brauner, linux-kernel
Andrew,
Would you mind picking up this one? The test module doesn't show any warning
after this on applied.
On Mon, May 25, 2020 at 09:59:58PM +0000, Wei Yang wrote:
>These two functions share the same logic.
>
>Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>---
> include/linux/bitops.h | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
>diff --git a/include/linux/bitops.h b/include/linux/bitops.h
>index 5b5609e81a84..80703ef27aee 100644
>--- a/include/linux/bitops.h
>+++ b/include/linux/bitops.h
>@@ -188,12 +188,10 @@ static inline unsigned fls_long(unsigned long l)
>
> static inline int get_count_order(unsigned int count)
> {
>- int order;
>+ if (count == 0)
>+ return -1;
>
>- order = fls(count) - 1;
>- if (count & (count - 1))
>- order++;
>- return order;
>+ return fls(--count);
> }
>
> /**
>--
>2.23.0
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-05-30 21:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-25 21:59 [PATCH] bitops: use the same mechanism for get_count_order[_long] Wei Yang
2020-05-26 7:04 ` Andy Shevchenko
2020-05-26 21:57 ` Wei Yang
2020-05-30 21:22 ` Wei Yang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.