Re: 答复: [PATCH v3 1/2] lib: bitmap: add find_last_bit_from() and _find_last_bit_from()
From: Yury Norov
Date: Wed May 27 2026 - 16:55:11 EST
On Wed, May 27, 2026 at 09:32:49AM +0000, 孙毅 (Yi Sun) wrote:
...
> > On the previous round I suggested the implementation based on
> > find_last_bit(), so that you don't need to create an outline
> > _find_last_bit_from() function and expose it. Can you compare the
> > implementations for the performance impact. If they are on par,
> > I'd stick to one re-using the existing code.
>
> Using the new API find_last_bit_from() is about 4% faster than using find_last_bit().
> This is likely because find_last_bit() requires additional offset calculations.
> as shown below:
> index_bits_align = round_down(index, BITS_PER_LONG);
> index_idx = index / BITS_PER_LONG;
> i = find_last_bit(map + index_idx, end - index_bits_align) + index_bits_align;
>
>
> So which approach do you prefer? Using the new API or not?
> I will send patch v4 (including testing code) based on your suggestion.
I'd prefer you to send the new iteration with the proper test that I
can run, then collect feedback from testers and then make a decision.
Thanks,
Yury