Re: [PATCH v2] lib/sbitmap: add KUnit test suite
From: Keith Teeple
Date: Wed Oct 21 2026 - 00:11:07 EST
On Fri, 16 Oct 2026 15:32:53 +0800, Wang Yibo wrote:
> v2:
> - Test sb.alloc_hint as a plain boolean: KUNIT_EXPECT_NOT_NULL() passes
> its argument through a const void *, which a __percpu pointer cannot do
> on architectures that keep percpu data in a separate address space, so
> the test did not build on x86 (David Gow).
> - Use a BITS_PER_LONG-relative bit number in sbitmap_test_iterate_set().
> The hardcoded 130 lies past the end of the test bitmap when
> BITS_PER_LONG is 32, so that bit was never visited and the test failed;
> assert the precondition while at it (David Gow).
I am new here and trying to be helpful by testing others' patches. I
reproduced both v1 failures and confirmed the v2 fixes, applied on the
stated base (4056b3c9d3c9) and built with gcc 16.2.1:
- x86_64 under QEMU: v1 fails to build at sbitmap_kunit.c:38,
same as you saw with gcc 15.2. v2 builds and passes 8/8.
One detail: this needs CONFIG_SMP=y as well as
CONFIG_USE_X86_SEG_SUPPORT=y. Without SMP, __percpu has no address space and v1
builds and passes. The kunit.py x64_64 QEMU config leaves SMP off by default.
- i386 under QEMU: v1 fails sbitmap_test_iterate_set with
nr_visited == 5 (expected 6). v2 passes 8/8.
- UML: v2 passes 8/8.
Tested-by: Keith Teeple <keithrteeple@xxxxxxxxx>