On Mon, Oct 07, 2019 at 04:26:13PM -0400, Josef Bacik wrote:
> On Mon, Oct 07, 2019 at 04:17:32PM -0400, Dennis Zhou wrote:
> > Bitmaps are fairly popular for their space efficiency, but we don't have
> > generic iterators available. Make percpu's bitmap region iterators
> > available to everyone.
> >
> > Signed-off-by: Dennis Zhou <dennis@xxxxxxxxxx>
> > ---
> > include/linux/bitmap.h | 35 ++++++++++++++++++++++++
> > mm/percpu.c | 61 +++++++++++-------------------------------
> > 2 files changed, 51 insertions(+), 45 deletions(-)
> >
> > diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
> > index 90528f12bdfa..9b0664f36808 100644
> > --- a/include/linux/bitmap.h
> > +++ b/include/linux/bitmap.h
> > @@ -437,6 +437,41 @@ static inline int bitmap_parse(const char *buf, unsigned int buflen,
> > return __bitmap_parse(buf, buflen, 0, maskp, nmaskbits);
> > }
> >
> > +static inline void bitmap_next_clear_region(unsigned long *bitmap,
> > + unsigned int *rs, unsigned int *re,
> > + unsigned int end)
> > +{
> > + *rs = find_next_zero_bit(bitmap, end, *rs);
> > + *re = find_next_bit(bitmap, end, *rs + 1);
> > +}
> > +
> > +static inline void bitmap_next_set_region(unsigned long *bitmap,
> > + unsigned int *rs, unsigned int *re,
> > + unsigned int end)
> > +{
> > + *rs = find_next_bit(bitmap, end, *rs);
> > + *re = find_next_zero_bit(bitmap, end, *rs + 1);
> > +}
> > +
> > +/*
> > + * Bitmap region iterators. Iterates over the bitmap between [@start, @end).
>
> Gonna be that guy here, should be '[@start, @end]'
>
I disagree here. I'm pretty happy with [@start, @end). If btrfs wants to
carry their own iterators I'm happy to copy and paste them, but as far
as percpu goes I like [@start, @end).
> Reviewed-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
>
Thanks,
Dennis