Skip to content

bitops: optimize fns() for more

Yury Norov lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 8 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4lib: make test_bitops compilable into the kernel imagelib/Kconfig.debug+0 -15 replies
2/4bitmap: relax find_nth_bit() limitation on return valueinclude/linux/find.h lib/find_bit.c lib/test_bitmap.c+4 -40 replies
3/4bitops: squeeze even more out of fns()include/linux/bitops.h+37 -53 replies
4/4MAINTAINERS: add BITOPS API recordMAINTAINERS+14 -00 replies

Reviews trailers per patch

2 of 4 patches have a Reviewed-by or Acked-by.

PatchKuan-Wei Chiu
1/4R-b
2/4
3/4R-b
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/4] bitops: optimize fns() for more

This series follows up [1].

[1] improves performance by switching from __ffs() + __clear_bit() in fns() to the equivalent but much faster expression that searches and clears first N-1 bits:

	while (word && n--)
		word &= word - 1;

We can squeeze out of fns() even more by replacing linear walk over all the bits in a word with a binary search.

Patch #3 implements it by adding fns8(), fns16(), fns32() and fns64(), and patches 1 and 2 are cleanups related to fns().

The last patch creates a MAINTAINERS record for bitops. Currently they aren't maintained. I add Rasmus and myself as a reviewer and maintainer, accordingly, just like for bitmaps. Rasmus, please let me know if you don't want to review it.

[1] https://lore.kernel.org/linux-kernel/[email protected]/T/

Yury Norov (4):
lib: make test_bitops compilable into the kernel image
bitmap: relax find_nth_bit() limitation on return value
bitops: squeeze even more out of fns()
MAINTAINERS: add BITOPS API record

 MAINTAINERS            | 13 +++++++++++++
 include/linux/bitops.h | 42 +++++++++++++++++++++++++++++++++++++-----
 include/linux/find.h   |  2 +-
 lib/Kconfig.debug      |  1 -
 lib/find_bit.c         |  2 +-
 lib/test_bitmap.c      |  4 ++--
 6 files changed, 54 insertions(+), 10 deletions(-)
Signature · 1 line
2.40.1