Re: [RFC PATCH v1 2/6] lib: Implement find_{first,next,nth}_nor_bit, find_first_andnot_bit

From: Yury Norov
Date: Wed Aug 28 2024 - 14:42:04 EST


On Wed, Aug 28, 2024 at 02:24:28PM -0400, Mathieu Desnoyers wrote:
> On 2024-08-23 21:19, Yury Norov wrote:
>
> [...]
> >
> > If it comes to v2, can you also add some sanity tests for the new API?
>
> I don't mind extending existing tests to cover my new APIs, but
> I could not find any selftests for the linux/find.h API within the
> kernel tree. Am I missing something ?
>
> Thanks,
>
> Mathieu

There's a very poor coverage indeed. Mostly because old find_bit API
is actively used since very long ago, and if broken, the kernel will
likely crash on boot.

For a new API, I try to keep it tested. You can find test_find_nth_bit
in lib/test_bitmap.c as an example.

Also, if you think your new helpers would have a performance impact,
or will be used in hot paths, you can add performance tests in
lib/find_bit_benchmark.c.

Thanks,
Yury