From fa188edc671d4e2b9d88c1b48d2f4e577d6e6983 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 16 Dec 2025 17:21:53 -0800 Subject: [PATCH 1/8] linux/bitfield.h: replace __auto_type with auto Replace "__auto_type" as described in commit: 2fb6915fa22d compiler_types.h: add "auto" as a macro for "__auto_type" [Yury: keep inclusions alphabetically ordered] Cc: Rasmus Villemoes (reviewer:BITMAP API) Signed-off-by: H. Peter Anvin (Intel) Signed-off-by: Yury Norov (NVIDIA) --- include/linux/bitfield.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/bitfield.h b/include/linux/bitfield.h index 126dc5b380af..54aeeef1f0ec 100644 --- a/include/linux/bitfield.h +++ b/include/linux/bitfield.h @@ -8,6 +8,7 @@ #define _LINUX_BITFIELD_H #include +#include #include #include @@ -243,7 +244,7 @@ __MAKE_OP(64) #define __field_prep(mask, val) \ ({ \ - __auto_type __mask = (mask); \ + auto __mask = (mask); \ typeof(__mask) __val = (val); \ unsigned int __shift = BITS_PER_TYPE(__mask) <= 32 ? \ __ffs(__mask) : __ffs64(__mask); \ @@ -252,7 +253,7 @@ __MAKE_OP(64) #define __field_get(mask, reg) \ ({ \ - __auto_type __mask = (mask); \ + auto __mask = (mask); \ typeof(__mask) __reg = (reg); \ unsigned int __shift = BITS_PER_TYPE(__mask) <= 32 ? \ __ffs(__mask) : __ffs64(__mask); \ From ac3dc186df4eb53f20bf519b352b8a76328bea12 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Wed, 17 Dec 2025 13:51:29 +0000 Subject: [PATCH 2/8] rust: bitmap: add __rust_helper to helpers This is needed to inline these helpers into Rust code. Reviewed-by: Boqun Feng Reviewed-by: Gary Guo Signed-off-by: Alice Ryhl Signed-off-by: Yury Norov (NVIDIA) --- rust/helpers/bitmap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/rust/helpers/bitmap.c b/rust/helpers/bitmap.c index a50e2f082e47..e4e9f4361270 100644 --- a/rust/helpers/bitmap.c +++ b/rust/helpers/bitmap.c @@ -2,6 +2,7 @@ #include +__rust_helper void rust_helper_bitmap_copy_and_extend(unsigned long *to, const unsigned long *from, unsigned int count, unsigned int size) { From 8618307b52ef2fa5caa87f1b7938125cb410e777 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Wed, 17 Dec 2025 13:51:30 +0000 Subject: [PATCH 3/8] rust: bitops: add __rust_helper to helpers This is needed to inline these helpers into Rust code. Reviewed-by: Boqun Feng Reviewed-by: Gary Guo Signed-off-by: Alice Ryhl Signed-off-by: Yury Norov (NVIDIA) --- rust/helpers/bitops.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rust/helpers/bitops.c b/rust/helpers/bitops.c index 5d0861d29d3f..f875692ead30 100644 --- a/rust/helpers/bitops.c +++ b/rust/helpers/bitops.c @@ -2,21 +2,25 @@ #include +__rust_helper void rust_helper___set_bit(unsigned long nr, unsigned long *addr) { __set_bit(nr, addr); } +__rust_helper void rust_helper___clear_bit(unsigned long nr, unsigned long *addr) { __clear_bit(nr, addr); } +__rust_helper void rust_helper_set_bit(unsigned long nr, volatile unsigned long *addr) { set_bit(nr, addr); } +__rust_helper void rust_helper_clear_bit(unsigned long nr, volatile unsigned long *addr) { clear_bit(nr, addr); From b4f1ffd63266d9a8785622074b12339535db6a7c Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Wed, 17 Dec 2025 13:51:31 +0000 Subject: [PATCH 4/8] rust: cpumask: add __rust_helper to helpers This is needed to inline these helpers into Rust code. Reviewed-by: Boqun Feng Reviewed-by: Gary Guo Signed-off-by: Alice Ryhl Signed-off-by: Yury Norov (NVIDIA) --- rust/helpers/cpumask.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/rust/helpers/cpumask.c b/rust/helpers/cpumask.c index eb10598a0242..5deced5b975e 100644 --- a/rust/helpers/cpumask.c +++ b/rust/helpers/cpumask.c @@ -2,67 +2,80 @@ #include +__rust_helper void rust_helper_cpumask_set_cpu(unsigned int cpu, struct cpumask *dstp) { cpumask_set_cpu(cpu, dstp); } +__rust_helper void rust_helper___cpumask_set_cpu(unsigned int cpu, struct cpumask *dstp) { __cpumask_set_cpu(cpu, dstp); } +__rust_helper void rust_helper_cpumask_clear_cpu(int cpu, struct cpumask *dstp) { cpumask_clear_cpu(cpu, dstp); } +__rust_helper void rust_helper___cpumask_clear_cpu(int cpu, struct cpumask *dstp) { __cpumask_clear_cpu(cpu, dstp); } +__rust_helper bool rust_helper_cpumask_test_cpu(int cpu, struct cpumask *srcp) { return cpumask_test_cpu(cpu, srcp); } +__rust_helper void rust_helper_cpumask_setall(struct cpumask *dstp) { cpumask_setall(dstp); } +__rust_helper bool rust_helper_cpumask_empty(struct cpumask *srcp) { return cpumask_empty(srcp); } +__rust_helper bool rust_helper_cpumask_full(struct cpumask *srcp) { return cpumask_full(srcp); } +__rust_helper unsigned int rust_helper_cpumask_weight(struct cpumask *srcp) { return cpumask_weight(srcp); } +__rust_helper void rust_helper_cpumask_copy(struct cpumask *dstp, const struct cpumask *srcp) { cpumask_copy(dstp, srcp); } +__rust_helper bool rust_helper_alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags) { return alloc_cpumask_var(mask, flags); } +__rust_helper bool rust_helper_zalloc_cpumask_var(cpumask_var_t *mask, gfp_t flags) { return zalloc_cpumask_var(mask, flags); } #ifndef CONFIG_CPUMASK_OFFSTACK +__rust_helper void rust_helper_free_cpumask_var(cpumask_var_t mask) { free_cpumask_var(mask); From 4101b3b571701cdf1081b2f96124b1daaeaebbf1 Mon Sep 17 00:00:00 2001 From: Ryota Sakamoto Date: Sun, 11 Jan 2026 02:38:07 +0900 Subject: [PATCH 5/8] lib/tests: add KUnit test for bitops Add a KUnit test suite for the bitops API. The existing 'lib/test_bitops.c' is preserved as-is because it contains ad-hoc micro-benchmarks 'test_fns' and is intended to ensure no compiler warnings from C=1 sparse checker or -Wextra compilations. Introduce 'lib/tests/bitops_kunit.c' for functional regression testing. It ports the test logic and data patterns from 'lib/test_bitops.c' to KUnit, verifying correct behavior across various input patterns and architecture-specific edge cases using isolated stack-allocated bitmaps. The following test logic has been ported from test_bitops_startup() in lib/test_bitops.c: - set_bit() / clear_bit() / find_first_bit() validation -> test_set_bit_clear_bit() - get_count_order() validation -> test_get_count_order() - get_count_order_long() validation -> test_get_count_order_long() Also improve the find_first_bit() test to check the full bitmap length (BITOPS_LENGTH) instead of omitting the last bit, ensuring the bitmap is completely empty after cleanup. Verified on x86_64, i386, and arm64 architectures. Sample KUnit output: KTAP version 1 # Subtest: bitops # module: bitops_kunit 1..3 KTAP version 1 # Subtest: test_set_bit_clear_bit ok 1 BITOPS_4 ok 2 BITOPS_7 ok 3 BITOPS_11 ok 4 BITOPS_31 ok 5 BITOPS_88 # test_set_bit_clear_bit: pass:5 fail:0 skip:0 total:5 ok 1 test_set_bit_clear_bit KTAP version 1 # Subtest: test_get_count_order ok 1 0x00000003 ok 2 0x00000004 ok 3 0x00001fff ok 4 0x00002000 ok 5 0x50000000 ok 6 0x80000000 ok 7 0x80003000 # test_get_count_order: pass:7 fail:0 skip:0 total:7 ok 2 test_get_count_order KTAP version 1 # Subtest: test_get_count_order_long ok 1 0x0000000300000000 ok 2 0x0000000400000000 ok 3 0x00001fff00000000 ok 4 0x0000200000000000 ok 5 0x5000000000000000 ok 6 0x8000000000000000 ok 7 0x8000300000000000 # test_get_count_order_long: pass:7 fail:0 skip:0 total:7 ok 3 test_get_count_order_long [Yury: trim Kconfig help message] CC: Jesse Brandeburg CC: Wei Yang Signed-off-by: Ryota Sakamoto Signed-off-by: Yury Norov --- MAINTAINERS | 1 + lib/Kconfig.debug | 13 ++++ lib/tests/Makefile | 1 + lib/tests/bitops_kunit.c | 142 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 157 insertions(+) create mode 100644 lib/tests/bitops_kunit.c diff --git a/MAINTAINERS b/MAINTAINERS index a0dd762f5648..ad978698deed 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4468,6 +4468,7 @@ F: include/asm-generic/bitops.h F: include/linux/bitops.h F: lib/hweight.c F: lib/test_bitops.c +F: lib/tests/bitops_kunit.c F: tools/*/bitops* BITOPS API BINDINGS [RUST] diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index ba36939fda79..e4f8ba2f9f32 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2652,6 +2652,19 @@ config TEST_SYSCTL If unsure, say N. +config BITOPS_KUNIT + tristate "KUnit test for bitops" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + This option enables the KUnit test for the bitops library + which provides functions for bit operations. + + Note that this is a partial copy of the original test_bitops module. + For the full coverage, enable TEST_BITOPS. + + If unsure, say N. + config BITFIELD_KUNIT tristate "KUnit test bitfield functions at runtime" if !KUNIT_ALL_TESTS depends on KUNIT diff --git a/lib/tests/Makefile b/lib/tests/Makefile index 601dba4b7d96..0f24048f3684 100644 --- a/lib/tests/Makefile +++ b/lib/tests/Makefile @@ -5,6 +5,7 @@ # KUnit tests CFLAGS_bitfield_kunit.o := $(DISABLE_STRUCTLEAK_PLUGIN) obj-$(CONFIG_BASE64_KUNIT) += base64_kunit.o +obj-$(CONFIG_BITOPS_KUNIT) += bitops_kunit.o obj-$(CONFIG_BITFIELD_KUNIT) += bitfield_kunit.o obj-$(CONFIG_BITS_TEST) += test_bits.o obj-$(CONFIG_BLACKHOLE_DEV_KUNIT_TEST) += blackhole_dev_kunit.o diff --git a/lib/tests/bitops_kunit.c b/lib/tests/bitops_kunit.c new file mode 100644 index 000000000000..5c47a1276061 --- /dev/null +++ b/lib/tests/bitops_kunit.c @@ -0,0 +1,142 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2020 Intel Corporation + * Copyright (C) 2026 Ryota Sakamoto + */ + +#include +#include +#include + +/* use an enum because that's the most common BITMAP usage */ +enum bitops_fun { + BITOPS_4 = 4, + BITOPS_7 = 7, + BITOPS_11 = 11, + BITOPS_31 = 31, + BITOPS_88 = 88, + BITOPS_LENGTH = 256 +}; + +struct bitops_test_case { + const char *str; + const long nr; +}; + +static struct bitops_test_case bitops_cases[] = { + { + .str = "BITOPS_4", + .nr = BITOPS_4, + }, + { + .str = "BITOPS_7", + .nr = BITOPS_7, + }, + { + .str = "BITOPS_11", + .nr = BITOPS_11, + }, + { + .str = "BITOPS_31", + .nr = BITOPS_31, + }, + { + .str = "BITOPS_88", + .nr = BITOPS_88, + }, +}; + +KUNIT_ARRAY_PARAM_DESC(bitops, bitops_cases, str); + +static void test_set_bit_clear_bit(struct kunit *test) +{ + const struct bitops_test_case *params = test->param_value; + DECLARE_BITMAP(bitmap, BITOPS_LENGTH); + int bit_set; + + bitmap_zero(bitmap, BITOPS_LENGTH); + + set_bit(params->nr, bitmap); + KUNIT_EXPECT_TRUE(test, test_bit(params->nr, bitmap)); + + clear_bit(params->nr, bitmap); + KUNIT_EXPECT_FALSE(test, test_bit(params->nr, bitmap)); + + bit_set = find_first_bit(bitmap, BITOPS_LENGTH); + KUNIT_EXPECT_EQ(test, bit_set, BITOPS_LENGTH); +} + +struct order_test_case { + const char *str; + const unsigned int count; + const int expected; +}; + +static struct order_test_case order_test_cases[] = { + {"0x00000003", 0x00000003, 2}, + {"0x00000004", 0x00000004, 2}, + {"0x00001fff", 0x00001fff, 13}, + {"0x00002000", 0x00002000, 13}, + {"0x50000000", 0x50000000, 31}, + {"0x80000000", 0x80000000, 31}, + {"0x80003000", 0x80003000, 32}, +}; + +KUNIT_ARRAY_PARAM_DESC(order, order_test_cases, str); + +static void test_get_count_order(struct kunit *test) +{ + const struct order_test_case *params = test->param_value; + + KUNIT_EXPECT_EQ(test, get_count_order(params->count), params->expected); + KUNIT_EXPECT_EQ(test, get_count_order_long(params->count), params->expected); +} + +#ifdef CONFIG_64BIT +struct order_long_test_case { + const char *str; + const unsigned long count; + const int expected; +}; + +static struct order_long_test_case order_long_test_cases[] = { + {"0x0000000300000000", 0x0000000300000000, 34}, + {"0x0000000400000000", 0x0000000400000000, 34}, + {"0x00001fff00000000", 0x00001fff00000000, 45}, + {"0x0000200000000000", 0x0000200000000000, 45}, + {"0x5000000000000000", 0x5000000000000000, 63}, + {"0x8000000000000000", 0x8000000000000000, 63}, + {"0x8000300000000000", 0x8000300000000000, 64}, +}; + +KUNIT_ARRAY_PARAM_DESC(order_long, order_long_test_cases, str); + +static void test_get_count_order_long(struct kunit *test) +{ + const struct order_long_test_case *params = test->param_value; + + KUNIT_EXPECT_EQ(test, get_count_order_long(params->count), params->expected); +} +#endif + +static struct kunit_case bitops_test_cases[] = { + KUNIT_CASE_PARAM(test_set_bit_clear_bit, bitops_gen_params), + KUNIT_CASE_PARAM(test_get_count_order, order_gen_params), +#ifdef CONFIG_64BIT + KUNIT_CASE_PARAM(test_get_count_order_long, order_long_gen_params), +#endif + {}, +}; + +static struct kunit_suite bitops_test_suite = { + .name = "bitops", + .test_cases = bitops_test_cases, +}; + +kunit_test_suite(bitops_test_suite); + +MODULE_AUTHOR("Jesse Brandeburg "); +MODULE_AUTHOR("Wei Yang "); +MODULE_AUTHOR("Ryota Sakamoto "); +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Bit testing module"); From 92010ab6dbacc0e0f3566d92a84ff00a939e7fd4 Mon Sep 17 00:00:00 2001 From: Lee Yongjun Date: Tue, 20 Jan 2026 22:18:27 +0900 Subject: [PATCH 6/8] lib/find_bit: fix uninitialized variable use in FIND_NTH_BIT In the FIND_NTH_BIT macro, if the 'size' parameter is 0, both the loop conditions and the modulo condition are not met. Consequently, the 'tmp' variable remains uninitialized before being used in the 'found' label. This results in the following smatch errors: lib/find_bit.c:164 __find_nth_bit() error: uninitialized symbol 'tmp'. lib/find_bit.c:171 __find_nth_and_bit() error: uninitialized symbol 'tmp'. lib/find_bit.c:178 __find_nth_andnot_bit() error: uninitialized symbol 'tmp'. lib/find_bit.c:187 __find_nth_and_andnot_bit() error: uninitialized symbol 'tmp'. Initialize 'tmp' to 0 to ensure that fns() operates on a zeroed value (no bits set) when size is 0, preventing the use of garbage values. [Yury: size == 0 is generally a sign of error on client side, and in this case, any returned value is OK because the returned value would be greater than 'size'. Applying the patch to reduce the checker noise.] Signed-off-by: Lee Yongjun Signed-off-by: Yury Norov --- lib/find_bit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/find_bit.c b/lib/find_bit.c index d4b5a29e3e72..5a0066c26d9a 100644 --- a/lib/find_bit.c +++ b/lib/find_bit.c @@ -71,7 +71,7 @@ out: \ #define FIND_NTH_BIT(FETCH, size, num) \ ({ \ - unsigned long sz = (size), nr = (num), idx, w, tmp; \ + unsigned long sz = (size), nr = (num), idx, w, tmp = 0; \ \ for (idx = 0; (idx + 1) * BITS_PER_LONG <= sz; idx++) { \ if (idx * BITS_PER_LONG + nr >= sz) \ From 9d6f6764939f9594d2de24ab3b2701d6ee592c0a Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 22 Jan 2026 11:31:08 +0100 Subject: [PATCH 7/8] bitops: Add more files to the MAINTAINERS It seems we have at least one more file to be added to the MAINTAINERS that corresponds to bit operations. Signed-off-by: Andy Shevchenko Signed-off-by: Yury Norov --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index ad978698deed..ba9c81f1cb64 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4466,6 +4466,7 @@ F: arch/*/lib/bitops.c F: include/asm-generic/bitops F: include/asm-generic/bitops.h F: include/linux/bitops.h +F: include/linux/count_zeros.h F: lib/hweight.c F: lib/test_bitops.c F: lib/tests/bitops_kunit.c From 6711069dd72fcbafe010fb16be504364e5ced190 Mon Sep 17 00:00:00 2001 From: Ryota Sakamoto Date: Fri, 23 Jan 2026 00:40:41 +0900 Subject: [PATCH 8/8] lib/tests: extend KUnit test for bitops with more cases Extend a KUnit test suite for the bitops API to cover more APIs from include/asm-generic/bitops/instrumented-atomic.h. - change_bit() - test_and_set_bit() - test_and_clear_bit() - test_and_change_bit() Verified on x86_64, i386, and arm64 architectures. Sample KUnit output: KTAP version 1 # Subtest: test_change_bit ok 1 BITOPS_4 ok 2 BITOPS_7 ok 3 BITOPS_11 ok 4 BITOPS_31 ok 5 BITOPS_88 # test_change_bit: pass:5 fail:0 skip:0 total:5 ok 2 test_change_bit KTAP version 1 # Subtest: test_test_and_set_bit_test_and_clear_bit ok 1 BITOPS_4 ok 2 BITOPS_7 ok 3 BITOPS_11 ok 4 BITOPS_31 ok 5 BITOPS_88 # test_test_and_set_bit_test_and_clear_bit: pass:5 fail:0 skip:0 total:5 ok 3 test_test_and_set_bit_test_and_clear_bit KTAP version 1 # Subtest: test_test_and_change_bit ok 1 BITOPS_4 ok 2 BITOPS_7 ok 3 BITOPS_11 ok 4 BITOPS_31 ok 5 BITOPS_88 # test_test_and_change_bit: pass:5 fail:0 skip:0 total:5 ok 4 test_test_and_change_bit Signed-off-by: Ryota Sakamoto Signed-off-by: Yury Norov --- lib/Kconfig.debug | 4 +-- lib/tests/bitops_kunit.c | 63 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index e4f8ba2f9f32..c59b12cf633a 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2660,8 +2660,8 @@ config BITOPS_KUNIT This option enables the KUnit test for the bitops library which provides functions for bit operations. - Note that this is a partial copy of the original test_bitops module. - For the full coverage, enable TEST_BITOPS. + Note that this is derived from the original test_bitops module. + For micro-benchmarks and compiler warning checks, enable TEST_BITOPS. If unsure, say N. diff --git a/lib/tests/bitops_kunit.c b/lib/tests/bitops_kunit.c index 5c47a1276061..7fd9d697f131 100644 --- a/lib/tests/bitops_kunit.c +++ b/lib/tests/bitops_kunit.c @@ -66,6 +66,66 @@ static void test_set_bit_clear_bit(struct kunit *test) KUNIT_EXPECT_EQ(test, bit_set, BITOPS_LENGTH); } +static void test_change_bit(struct kunit *test) +{ + const struct bitops_test_case *params = test->param_value; + DECLARE_BITMAP(bitmap, BITOPS_LENGTH); + int bit_set; + + bitmap_zero(bitmap, BITOPS_LENGTH); + + change_bit(params->nr, bitmap); + KUNIT_EXPECT_TRUE(test, test_bit(params->nr, bitmap)); + + change_bit(params->nr, bitmap); + KUNIT_EXPECT_FALSE(test, test_bit(params->nr, bitmap)); + + bit_set = find_first_bit(bitmap, BITOPS_LENGTH); + KUNIT_EXPECT_EQ(test, bit_set, BITOPS_LENGTH); +} + +static void test_test_and_set_bit_test_and_clear_bit(struct kunit *test) +{ + const struct bitops_test_case *params = test->param_value; + DECLARE_BITMAP(bitmap, BITOPS_LENGTH); + int bit_set; + + bitmap_zero(bitmap, BITOPS_LENGTH); + + KUNIT_EXPECT_FALSE(test, test_and_set_bit(params->nr, bitmap)); + KUNIT_EXPECT_TRUE(test, test_bit(params->nr, bitmap)); + + KUNIT_EXPECT_TRUE(test, test_and_set_bit(params->nr, bitmap)); + KUNIT_EXPECT_TRUE(test, test_bit(params->nr, bitmap)); + + KUNIT_EXPECT_TRUE(test, test_and_clear_bit(params->nr, bitmap)); + KUNIT_EXPECT_FALSE(test, test_bit(params->nr, bitmap)); + + KUNIT_EXPECT_FALSE(test, test_and_clear_bit(params->nr, bitmap)); + KUNIT_EXPECT_FALSE(test, test_bit(params->nr, bitmap)); + + bit_set = find_first_bit(bitmap, BITOPS_LENGTH); + KUNIT_EXPECT_EQ(test, bit_set, BITOPS_LENGTH); +} + +static void test_test_and_change_bit(struct kunit *test) +{ + const struct bitops_test_case *params = test->param_value; + DECLARE_BITMAP(bitmap, BITOPS_LENGTH); + int bit_set; + + bitmap_zero(bitmap, BITOPS_LENGTH); + + KUNIT_EXPECT_FALSE(test, test_and_change_bit(params->nr, bitmap)); + KUNIT_EXPECT_TRUE(test, test_bit(params->nr, bitmap)); + + KUNIT_EXPECT_TRUE(test, test_and_change_bit(params->nr, bitmap)); + KUNIT_EXPECT_FALSE(test, test_bit(params->nr, bitmap)); + + bit_set = find_first_bit(bitmap, BITOPS_LENGTH); + KUNIT_EXPECT_EQ(test, bit_set, BITOPS_LENGTH); +} + struct order_test_case { const char *str; const unsigned int count; @@ -121,6 +181,9 @@ static void test_get_count_order_long(struct kunit *test) static struct kunit_case bitops_test_cases[] = { KUNIT_CASE_PARAM(test_set_bit_clear_bit, bitops_gen_params), + KUNIT_CASE_PARAM(test_change_bit, bitops_gen_params), + KUNIT_CASE_PARAM(test_test_and_set_bit_test_and_clear_bit, bitops_gen_params), + KUNIT_CASE_PARAM(test_test_and_change_bit, bitops_gen_params), KUNIT_CASE_PARAM(test_get_count_order, order_gen_params), #ifdef CONFIG_64BIT KUNIT_CASE_PARAM(test_get_count_order_long, order_long_gen_params),