Re: [PATCH v2 2/6] bitmap: replace _reg_op(REG_OP_ALLOC) with bitmap_set()

From: Yury Norov
Date: Fri Aug 11 2023 - 09:02:06 EST


On Fri, Aug 11, 2023 at 12:25:02PM +0300, Andy Shevchenko wrote:
> On Thu, Aug 10, 2023 at 05:57:28PM -0700, Yury Norov wrote:
> > _reg_op(REG_OP_ALLOC) duplicates bitmap_set(). Fix it.
>
> ...
>
> > int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order)
> > {
> > + unsigned int nbits = pos + BIT(order);
>
> Shouldn't this be unsigned long?
> As the prototype of the used later unsigned long find_next_bit().

Linux doesn't support bitmaps longer than 2^32 bits. I really doubt
such huge bitmaps would ever exist, but if that will happen, too many
bitmap functions will have to be revisited.

For the reference, check the code of __reg_op(), which I remove in the
series - all indexes and offsets are int's there.

Thanks,
Yury

> > if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
> > return -EBUSY;
> > - return __reg_op(bitmap, pos, order, REG_OP_ALLOC);
> > + bitmap_set(bitmap, pos, nbits);
> > + return 0;
> > }
>
> --
> With Best Regards,
> Andy Shevchenko
>