[PATCH v2 0/2] x86/topology: add bitmap_weight_from() and use it in topo_unit_count()

From: Yury Norov (NVIDIA)

Date: Mon Dec 22 2025 - 14:11:43 EST


Currently the function open-codes the missing bitmap_weight_from() with
a for-loop, which is known to be less effective. Add the helper and
switch topo_unit_count() to using it.

v1: https://lore.kernel.org/all/20251214235437.244125-1-yury.norov@xxxxxxxxx/
v2:
- rename 'nbits' to 'end' (Ingo);
- leverage bitmap_weight() in inline implementation;
- drop outline implementation;
- don't handle 'start >= end' case explititly, leave it to user.

Yury Norov (NVIDIA) (2):
bitmap: add bitmap_weight_from()
x86/topology: use bitmap_weight_from()

arch/x86/kernel/cpu/topology.c | 8 ++------
include/linux/bitmap.h | 30 ++++++++++++++++++++++++++++++
lib/test_bitmap.c | 26 ++++++++++++++++++++++++++
3 files changed, 58 insertions(+), 6 deletions(-)

--
2.43.0