[PATCH 00/12] bitmap: rework bitmap_{bit,}remap()

From: Yury Norov
Date: Mon Aug 28 2023 - 14:44:47 EST


This series adds a test, const-time optimizaton and fixes O(N^2)
complexity problem for the functions. It's based on discussion in
bitmap: optimize bitmap_remap() series [1], but there's much more work
here, so I decided to give it a separete run, and don't name it as v2.

bitmap_remap() API has just one user in generic code, and few more in
drivers, so this may look like an overkill. But the work gives ~10x
better performance for a 1000-bit bitmaps, which is typical for nodemasks
in major distros like Ubuntu.

Anyways, the work is done, so guys please review.

[1] https://lore.kernel.org/lkml/20230815235934.47782-1-yury.norov@xxxxxxxxx/T/
Yury Norov (12):
bitmap: add find_nth_bit_from()
bitmap: add bitmap_weight_from()
bitmap: add test for bitmap_remap()
bitmap: add test for bitmap_bitremap()
bitmap: update comment for bitmap_{bit,}remap()
bitmap: add small_cont_nbits() optimization for bitmap_remap()
bitmap: add small_const_nbits() optimization for bitmap_bitremap()
bitmap: optiimze bitmap_bitremap()
bitmap: optimize bitmap_remap() when 'new' is empty map
bitmap: separate handling of identity and remapping parts in
bitmap_remap()
bitmap: defer calculating weight of 'new' in bitmap_remap()
bitmap: don't count bits from the beginning in bitmap_remap()

include/linux/bitmap.h | 116 +++++++++++++++++++++++++++++++--
include/linux/find.h | 37 +++++++++++
lib/bitmap.c | 145 ++++++++++++++++++++---------------------
lib/find_bit.c | 29 +++++++++
lib/test_bitmap.c | 142 +++++++++++++++++++++++++++++++++++++++-
5 files changed, 388 insertions(+), 81 deletions(-)

--
2.39.2