Re: [PATCH v4 1/5] lib/bitmap: add bitmap_{set,get}_value()

From: Andy Shevchenko
Date: Tue Jul 25 2023 - 05:00:46 EST


On Mon, Jul 24, 2023 at 10:04:34PM -0700, Yury Norov wrote:
> On Mon, Jul 24, 2023 at 11:36:36AM +0300, Andy Shevchenko wrote:
> > On Sat, Jul 22, 2023 at 06:57:23PM -0700, Yury Norov wrote:
> > > On Thu, Jul 20, 2023 at 07:39:52PM +0200, Alexander Potapenko wrote:

...

> > > 'GENMASK(nbits - 1, 0) << offset' looks really silly.
> >
> > But you followed the thread to get a clue why it's written in this form, right?
>
> Yes, I did. But I don't expect everyone looking at kernel code would spend
> time recovering discussions that explain why that happened. So, at least it
> would be fine to drop a comment.

See also below.

...

> w = *map & (end < BITS_PER_LONG ? ~GENMASK(end, start) : BITMAP_LAST_WORD_MASK(start));

This GENMASK() may generate worse code as compiler uses more instructions
instead of simple approach with the above..

...

> bitmap_write - 271 +271
> my_bitmap_write - 248 +248
> bitmap_read - 229 +229

my_ -- means your proposal? Do you mean you have it better in size than original one?

--
With Best Regards,
Andy Shevchenko