[PATCH 0/2] bitmap: add bitmap_all_set()/bitmap_all_clear() and use in virtio-mem
From: Alessio Maroni
Date: Sun Dec 06 2026 - 08:52:30 EST
This series introduces bitmap_all_set() and bitmap_all_clear() to check
whether all bits in an arbitrary [start, start + nbits) range are set
or clear, and uses them to clean up open-coded find_next_*_bit() checks
in virtio-mem.
Patch 1 adds the two helpers in include/linux/bitmap.h (with compile-time
fast paths for zero, single-bit, and small single-word ranges) along
with selftest coverage in lib/test_bitmap.c.
Patch 2 replaces the manual find_next_zero_bit() / find_next_bit()
expressions in drivers/virtio/virtio_mem.c, resolving the existing TODO
comments.
Tested with lib/test_bitmap selftests (all 454551 tests passed) and
memory hotplug/unplug cycles on QEMU x86_64 with virtio-mem-pci, as
well as W=1 builds and checkpatch.pl --strict.
Alessio Maroni (2):
bitmap: add bitmap_all_set() and bitmap_all_clear()
virtio-mem: use bitmap_all_set() and bitmap_all_clear()
drivers/virtio/virtio_mem.c | 11 ++-------
include/linux/bitmap.h | 47 +++++++++++++++++++++++++++++++++++++
lib/test_bitmap.c | 38 ++++++++++++++++++++++++++++++
3 files changed, 87 insertions(+), 9 deletions(-)
--
2.56.1