[PATCH 00/16] Introduce DEBUG_BITMAP config option and bitmap_check_params()

Yury Norov
2022-07-18T19:28:56Z

Bitmap functions are often a part of hot paths, and we can't put argument
sanity checks inside them. Sometimes wrong parameters combination cause
bug reports that are pretty hard to investigate:
https://lore.kernel.org/linux-mm/YsbpTNmDaam8pl+f@xsang-OptiPlex-9020/

And sometimes we can optimize caller code. For example, to avoid copying
of bitmap if source and destination are the same.

It's quite tricky to detect such places unless we've covered all bitmap
API calls with the parameters checker.

This series:
- introduces bitmap_check_params() with a couple of common-used wrappers;
- clears all bitmap warnings found for x86_64, arm64 and powerpc64 in
boot test.

Yury Norov (16):
lib/bitmap: add bitmap_check_params()
lib/bitmap: don't call bitmap_set() with len == 0
lib/test_bitmap: don't test bitmap_set if nbits == 0
lib/test_bitmap: test test_bitmap_arr{32,64} starting from nbits == 1
lib/test_bitmap: disable compile-time test if DEBUG_BITMAP() is
enabled
lib/test_bitmap: delete meaningless test for bitmap_cut
smp: optimize smp_call_function_many_cond()
smp: optimize smp_call_function_many_cond() for more
irq: don't copy cpu affinity mask if source is equal to destination
sched: optimize __set_cpus_allowed_ptr_locked()
time: optimize tick_check_preferred()
time: optimize tick_check_percpu()
time: optimize tick_setup_device()
mm/percpu: optimize pcpu_alloc_area()
sched/topology: optimize topology_span_sane()
lib: create CONFIG_DEBUG_BITMAP parameter

include/linux/bitmap.h | 95 +++++++++++++++++++++++++++
kernel/irq/manage.c | 3 +-
kernel/sched/core.c | 3 +-
kernel/sched/topology.c | 10 ++-
kernel/smp.c | 35 ++++++++--
kernel/time/tick-common.c | 18 ++++--
lib/Kconfig.debug | 7 ++
lib/bitmap.c | 132 ++++++++++++++++++++++++++++++++++----
lib/test_bitmap.c | 12 ++--
mm/percpu.c | 3 +-
10 files changed, 281 insertions(+), 37 deletions(-)

--
2.34.1