Re: [PATCH v12 01/11] bitops: Introduce the for_each_set_clump8 macro
From: Andy Shevchenko
Date: Tue Mar 26 2019 - 05:53:21 EST
On Tue, Mar 26, 2019 at 10:43:45AM +0100, Lukas Wunner wrote:
> On Tue, Mar 26, 2019 at 12:14:22PM +0900, William Breathitt Gray wrote:
> > On Mon, Mar 25, 2019 at 10:38:54AM +0100, Lukas Wunner wrote:
> > Is this the sort of implementation you had in mind:
> >
> > offset = find_next_bit(addr, size, offset);
> > if (offset == size)
> > return size;
> >
> > offset -= offset % 8;
> > *clump = bitmap_get_value8(addr, size, offset);
> >
> > return offset;
>
> Almost. I'd use round_down() instead of "offset -= offset % 8".
> Then it's just a single cheap logical and operation at runtime.
> I'd try to avoid copying around the clump value and use a pointer
> to u8 instead.
u8 might be inconvenient in environment where everything else is type of
unsigned long.
--
With Best Regards,
Andy Shevchenko