Re: [PATCH v6 1/5] lib/bitmap: add bitmap_{read,write}()

From: Rasmus Villemoes
Date: Tue Oct 10 2023 - 07:03:35 EST


On 10/10/2023 11.17, Alexander Potapenko wrote:

>> 'behaves similarly' sounds like an understatement. I think, it behaves
>> much faster because it can assign up to 64 bits at once, not mentioning
>> the pressure on cache lines traffic.
>
> My intent was to describe the visible behavior, of course the
> generated code is better, and the number of memory accesses lower.
>
> How about the following description:
>
> * The result of bitmap_write() is similar to @nbits calls of assign_bit(), i.e.
> * bits beyond @nbits are ignored:
> *
> * for (bit = 0; bit < nbits; bit++)
> * assign_bit(start + bit, bitmap, val & BIT(bit));
>
> ?

C programmers should know the meaning of the term "as-if". Perhaps use
that. Smth like "bitmap_write() behaves as-if implemented as @nbits
calls of __assign_bit()".

Rasmus