* [PATCH] lib/find: optimize find_*_bit_wrap
@ 2023-10-28 19:05 Yury Norov
2023-11-10 2:21 ` Yury Norov
0 siblings, 1 reply; 3+ messages in thread
From: Yury Norov @ 2023-10-28 19:05 UTC (permalink / raw)
To: linux-kernel; +Cc: Yury Norov, Andy Shevchenko, Rasmus Villemoes
When an offset is 0, there's no need to search a bitmap from the
beginning after the 1st search failed, because each bit has already
been tested.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
include/linux/find.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/find.h b/include/linux/find.h
index 5e4f39ef2e72..241b6d028eda 100644
--- a/include/linux/find.h
+++ b/include/linux/find.h
@@ -405,7 +405,7 @@ unsigned long find_next_and_bit_wrap(const unsigned long *addr1,
{
unsigned long bit = find_next_and_bit(addr1, addr2, size, offset);
- if (bit < size)
+ if (bit < size || offset == 0)
return bit;
bit = find_first_and_bit(addr1, addr2, offset);
@@ -427,7 +427,7 @@ unsigned long find_next_bit_wrap(const unsigned long *addr,
{
unsigned long bit = find_next_bit(addr, size, offset);
- if (bit < size)
+ if (bit < size || offset == 0)
return bit;
bit = find_first_bit(addr, offset);
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] lib/find: optimize find_*_bit_wrap
2023-10-28 19:05 [PATCH] lib/find: optimize find_*_bit_wrap Yury Norov
@ 2023-11-10 2:21 ` Yury Norov
2023-12-03 18:25 ` Yury Norov
0 siblings, 1 reply; 3+ messages in thread
From: Yury Norov @ 2023-11-10 2:21 UTC (permalink / raw)
To: linux-kernel; +Cc: Andy Shevchenko, Rasmus Villemoes
Ping?
On Sat, Oct 28, 2023 at 12:05:29PM -0700, Yury Norov wrote:
> When an offset is 0, there's no need to search a bitmap from the
> beginning after the 1st search failed, because each bit has already
> been tested.
>
> Signed-off-by: Yury Norov <yury.norov@gmail.com>
> ---
> include/linux/find.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/find.h b/include/linux/find.h
> index 5e4f39ef2e72..241b6d028eda 100644
> --- a/include/linux/find.h
> +++ b/include/linux/find.h
> @@ -405,7 +405,7 @@ unsigned long find_next_and_bit_wrap(const unsigned long *addr1,
> {
> unsigned long bit = find_next_and_bit(addr1, addr2, size, offset);
>
> - if (bit < size)
> + if (bit < size || offset == 0)
> return bit;
>
> bit = find_first_and_bit(addr1, addr2, offset);
> @@ -427,7 +427,7 @@ unsigned long find_next_bit_wrap(const unsigned long *addr,
> {
> unsigned long bit = find_next_bit(addr, size, offset);
>
> - if (bit < size)
> + if (bit < size || offset == 0)
> return bit;
>
> bit = find_first_bit(addr, offset);
> --
> 2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] lib/find: optimize find_*_bit_wrap
2023-11-10 2:21 ` Yury Norov
@ 2023-12-03 18:25 ` Yury Norov
0 siblings, 0 replies; 3+ messages in thread
From: Yury Norov @ 2023-12-03 18:25 UTC (permalink / raw)
To: linux-kernel; +Cc: Andy Shevchenko, Rasmus Villemoes
OK, taking in bitmap-for-next
On Thu, Nov 09, 2023 at 06:21:18PM -0800, Yury Norov wrote:
> Ping?
>
> On Sat, Oct 28, 2023 at 12:05:29PM -0700, Yury Norov wrote:
> > When an offset is 0, there's no need to search a bitmap from the
> > beginning after the 1st search failed, because each bit has already
> > been tested.
> >
> > Signed-off-by: Yury Norov <yury.norov@gmail.com>
> > ---
> > include/linux/find.h | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/linux/find.h b/include/linux/find.h
> > index 5e4f39ef2e72..241b6d028eda 100644
> > --- a/include/linux/find.h
> > +++ b/include/linux/find.h
> > @@ -405,7 +405,7 @@ unsigned long find_next_and_bit_wrap(const unsigned long *addr1,
> > {
> > unsigned long bit = find_next_and_bit(addr1, addr2, size, offset);
> >
> > - if (bit < size)
> > + if (bit < size || offset == 0)
> > return bit;
> >
> > bit = find_first_and_bit(addr1, addr2, offset);
> > @@ -427,7 +427,7 @@ unsigned long find_next_bit_wrap(const unsigned long *addr,
> > {
> > unsigned long bit = find_next_bit(addr, size, offset);
> >
> > - if (bit < size)
> > + if (bit < size || offset == 0)
> > return bit;
> >
> > bit = find_first_bit(addr, offset);
> > --
> > 2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-03 18:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-28 19:05 [PATCH] lib/find: optimize find_*_bit_wrap Yury Norov
2023-11-10 2:21 ` Yury Norov
2023-12-03 18:25 ` Yury Norov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox