Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'bitmap-6.0-rc3' of github.com:/norov/linux

Pull bitmap fixes from Yury Norov:
"Fix the reported issues, and implements the suggested improvements,
for the version of the cpumask tests [1] that was merged with commit
c41e8866c28c ("lib/test: introduce cpumask KUnit test suite").

These changes include fixes for the tests, and better alignment with
the KUnit style guidelines"

* tag 'bitmap-6.0-rc3' of github.com:/norov/linux:
lib/cpumask_kunit: add tests file to MAINTAINERS
lib/cpumask_kunit: log mask contents
lib/test_cpumask: follow KUnit style guidelines
lib/test_cpumask: fix cpu_possible_mask last test
lib/test_cpumask: drop cpu_possible_mask full test

+37 -23
+1
MAINTAINERS
··· 3612 F: include/linux/nodemask.h 3613 F: lib/bitmap.c 3614 F: lib/cpumask.c 3615 F: lib/find_bit.c 3616 F: lib/find_bit_benchmark.c 3617 F: lib/test_bitmap.c
··· 3612 F: include/linux/nodemask.h 3613 F: lib/bitmap.c 3614 F: lib/cpumask.c 3615 + F: lib/cpumask_kunit.c 3616 F: lib/find_bit.c 3617 F: lib/find_bit_benchmark.c 3618 F: lib/test_bitmap.c
+5 -2
lib/Kconfig.debug
··· 2029 Documentation on how to use the module can be found in 2030 Documentation/fault-injection/provoke-crashes.rst 2031 2032 - config TEST_CPUMASK 2033 - tristate "cpumask tests" if !KUNIT_ALL_TESTS 2034 depends on KUNIT 2035 default KUNIT_ALL_TESTS 2036 help 2037 Enable to turn on cpumask tests, running at boot or module load time. 2038 2039 If unsure, say N. 2040
··· 2029 Documentation on how to use the module can be found in 2030 Documentation/fault-injection/provoke-crashes.rst 2031 2032 + config CPUMASK_KUNIT_TEST 2033 + tristate "KUnit test for cpumask" if !KUNIT_ALL_TESTS 2034 depends on KUNIT 2035 default KUNIT_ALL_TESTS 2036 help 2037 Enable to turn on cpumask tests, running at boot or module load time. 2038 + 2039 + For more information on KUnit and unit tests in general, please refer 2040 + to the KUnit documentation in Documentation/dev-tools/kunit/. 2041 2042 If unsure, say N. 2043
+1 -1
lib/Makefile
··· 60 obj-$(CONFIG_TEST_FIRMWARE) += test_firmware.o 61 obj-$(CONFIG_TEST_BITOPS) += test_bitops.o 62 CFLAGS_test_bitops.o += -Werror 63 obj-$(CONFIG_TEST_SYSCTL) += test_sysctl.o 64 obj-$(CONFIG_TEST_SIPHASH) += test_siphash.o 65 obj-$(CONFIG_HASH_KUNIT_TEST) += test_hash.o ··· 101 obj-$(CONFIG_TEST_FREE_PAGES) += test_free_pages.o 102 obj-$(CONFIG_KPROBES_SANITY_TEST) += test_kprobes.o 103 obj-$(CONFIG_TEST_REF_TRACKER) += test_ref_tracker.o 104 - obj-$(CONFIG_TEST_CPUMASK) += test_cpumask.o 105 CFLAGS_test_fprobe.o += $(CC_FLAGS_FTRACE) 106 obj-$(CONFIG_FPROBE_SANITY_TEST) += test_fprobe.o 107 #
··· 60 obj-$(CONFIG_TEST_FIRMWARE) += test_firmware.o 61 obj-$(CONFIG_TEST_BITOPS) += test_bitops.o 62 CFLAGS_test_bitops.o += -Werror 63 + obj-$(CONFIG_CPUMASK_KUNIT_TEST) += cpumask_kunit.o 64 obj-$(CONFIG_TEST_SYSCTL) += test_sysctl.o 65 obj-$(CONFIG_TEST_SIPHASH) += test_siphash.o 66 obj-$(CONFIG_HASH_KUNIT_TEST) += test_hash.o ··· 100 obj-$(CONFIG_TEST_FREE_PAGES) += test_free_pages.o 101 obj-$(CONFIG_KPROBES_SANITY_TEST) += test_kprobes.o 102 obj-$(CONFIG_TEST_REF_TRACKER) += test_ref_tracker.o 103 CFLAGS_test_fprobe.o += $(CC_FLAGS_FTRACE) 104 obj-$(CONFIG_FPROBE_SANITY_TEST) += test_fprobe.o 105 #
+30 -20
lib/test_cpumask.c lib/cpumask_kunit.c
··· 9 #include <linux/cpu.h> 10 #include <linux/cpumask.h> 11 12 #define EXPECT_FOR_EACH_CPU_EQ(test, mask) \ 13 do { \ 14 const cpumask_t *m = (mask); \ ··· 20 int cpu, iter = 0; \ 21 for_each_cpu(cpu, m) \ 22 iter++; \ 23 - KUNIT_EXPECT_EQ((test), mask_weight, iter); \ 24 } while (0) 25 26 #define EXPECT_FOR_EACH_CPU_NOT_EQ(test, mask) \ ··· 30 int cpu, iter = 0; \ 31 for_each_cpu_not(cpu, m) \ 32 iter++; \ 33 - KUNIT_EXPECT_EQ((test), nr_cpu_ids - mask_weight, iter); \ 34 } while (0) 35 36 #define EXPECT_FOR_EACH_CPU_WRAP_EQ(test, mask) \ ··· 40 int cpu, iter = 0; \ 41 for_each_cpu_wrap(cpu, m, nr_cpu_ids / 2) \ 42 iter++; \ 43 - KUNIT_EXPECT_EQ((test), mask_weight, iter); \ 44 } while (0) 45 46 #define EXPECT_FOR_EACH_CPU_BUILTIN_EQ(test, name) \ ··· 49 int cpu, iter = 0; \ 50 for_each_##name##_cpu(cpu) \ 51 iter++; \ 52 - KUNIT_EXPECT_EQ((test), mask_weight, iter); \ 53 } while (0) 54 55 static cpumask_t mask_empty; ··· 57 58 static void test_cpumask_weight(struct kunit *test) 59 { 60 - KUNIT_EXPECT_TRUE(test, cpumask_empty(&mask_empty)); 61 - KUNIT_EXPECT_TRUE(test, cpumask_full(cpu_possible_mask)); 62 - KUNIT_EXPECT_TRUE(test, cpumask_full(&mask_all)); 63 64 - KUNIT_EXPECT_EQ(test, 0, cpumask_weight(&mask_empty)); 65 - KUNIT_EXPECT_EQ(test, nr_cpu_ids, cpumask_weight(cpu_possible_mask)); 66 - KUNIT_EXPECT_EQ(test, nr_cpumask_bits, cpumask_weight(&mask_all)); 67 } 68 69 static void test_cpumask_first(struct kunit *test) 70 { 71 - KUNIT_EXPECT_LE(test, nr_cpu_ids, cpumask_first(&mask_empty)); 72 - KUNIT_EXPECT_EQ(test, 0, cpumask_first(cpu_possible_mask)); 73 74 - KUNIT_EXPECT_EQ(test, 0, cpumask_first_zero(&mask_empty)); 75 - KUNIT_EXPECT_LE(test, nr_cpu_ids, cpumask_first_zero(cpu_possible_mask)); 76 } 77 78 static void test_cpumask_last(struct kunit *test) 79 { 80 - KUNIT_EXPECT_LE(test, nr_cpumask_bits, cpumask_last(&mask_empty)); 81 - KUNIT_EXPECT_EQ(test, nr_cpumask_bits - 1, cpumask_last(cpu_possible_mask)); 82 } 83 84 static void test_cpumask_next(struct kunit *test) 85 { 86 - KUNIT_EXPECT_EQ(test, 0, cpumask_next_zero(-1, &mask_empty)); 87 - KUNIT_EXPECT_LE(test, nr_cpu_ids, cpumask_next_zero(-1, cpu_possible_mask)); 88 89 - KUNIT_EXPECT_LE(test, nr_cpu_ids, cpumask_next(-1, &mask_empty)); 90 - KUNIT_EXPECT_EQ(test, 0, cpumask_next(-1, cpu_possible_mask)); 91 } 92 93 static void test_cpumask_iterators(struct kunit *test)
··· 9 #include <linux/cpu.h> 10 #include <linux/cpumask.h> 11 12 + #define MASK_MSG(m) \ 13 + "%s contains %sCPUs %*pbl", #m, (cpumask_weight(m) ? "" : "no "), \ 14 + nr_cpumask_bits, cpumask_bits(m) 15 + 16 #define EXPECT_FOR_EACH_CPU_EQ(test, mask) \ 17 do { \ 18 const cpumask_t *m = (mask); \ ··· 16 int cpu, iter = 0; \ 17 for_each_cpu(cpu, m) \ 18 iter++; \ 19 + KUNIT_EXPECT_EQ_MSG((test), mask_weight, iter, MASK_MSG(mask)); \ 20 } while (0) 21 22 #define EXPECT_FOR_EACH_CPU_NOT_EQ(test, mask) \ ··· 26 int cpu, iter = 0; \ 27 for_each_cpu_not(cpu, m) \ 28 iter++; \ 29 + KUNIT_EXPECT_EQ_MSG((test), nr_cpu_ids - mask_weight, iter, MASK_MSG(mask)); \ 30 } while (0) 31 32 #define EXPECT_FOR_EACH_CPU_WRAP_EQ(test, mask) \ ··· 36 int cpu, iter = 0; \ 37 for_each_cpu_wrap(cpu, m, nr_cpu_ids / 2) \ 38 iter++; \ 39 + KUNIT_EXPECT_EQ_MSG((test), mask_weight, iter, MASK_MSG(mask)); \ 40 } while (0) 41 42 #define EXPECT_FOR_EACH_CPU_BUILTIN_EQ(test, name) \ ··· 45 int cpu, iter = 0; \ 46 for_each_##name##_cpu(cpu) \ 47 iter++; \ 48 + KUNIT_EXPECT_EQ_MSG((test), mask_weight, iter, MASK_MSG(cpu_##name##_mask)); \ 49 } while (0) 50 51 static cpumask_t mask_empty; ··· 53 54 static void test_cpumask_weight(struct kunit *test) 55 { 56 + KUNIT_EXPECT_TRUE_MSG(test, cpumask_empty(&mask_empty), MASK_MSG(&mask_empty)); 57 + KUNIT_EXPECT_TRUE_MSG(test, cpumask_full(&mask_all), MASK_MSG(&mask_all)); 58 59 + KUNIT_EXPECT_EQ_MSG(test, 0, cpumask_weight(&mask_empty), MASK_MSG(&mask_empty)); 60 + KUNIT_EXPECT_EQ_MSG(test, nr_cpu_ids, cpumask_weight(cpu_possible_mask), 61 + MASK_MSG(cpu_possible_mask)); 62 + KUNIT_EXPECT_EQ_MSG(test, nr_cpumask_bits, cpumask_weight(&mask_all), MASK_MSG(&mask_all)); 63 } 64 65 static void test_cpumask_first(struct kunit *test) 66 { 67 + KUNIT_EXPECT_LE_MSG(test, nr_cpu_ids, cpumask_first(&mask_empty), MASK_MSG(&mask_empty)); 68 + KUNIT_EXPECT_EQ_MSG(test, 0, cpumask_first(cpu_possible_mask), MASK_MSG(cpu_possible_mask)); 69 70 + KUNIT_EXPECT_EQ_MSG(test, 0, cpumask_first_zero(&mask_empty), MASK_MSG(&mask_empty)); 71 + KUNIT_EXPECT_LE_MSG(test, nr_cpu_ids, cpumask_first_zero(cpu_possible_mask), 72 + MASK_MSG(cpu_possible_mask)); 73 } 74 75 static void test_cpumask_last(struct kunit *test) 76 { 77 + KUNIT_EXPECT_LE_MSG(test, nr_cpumask_bits, cpumask_last(&mask_empty), 78 + MASK_MSG(&mask_empty)); 79 + KUNIT_EXPECT_EQ_MSG(test, nr_cpu_ids - 1, cpumask_last(cpu_possible_mask), 80 + MASK_MSG(cpu_possible_mask)); 81 } 82 83 static void test_cpumask_next(struct kunit *test) 84 { 85 + KUNIT_EXPECT_EQ_MSG(test, 0, cpumask_next_zero(-1, &mask_empty), MASK_MSG(&mask_empty)); 86 + KUNIT_EXPECT_LE_MSG(test, nr_cpu_ids, cpumask_next_zero(-1, cpu_possible_mask), 87 + MASK_MSG(cpu_possible_mask)); 88 89 + KUNIT_EXPECT_LE_MSG(test, nr_cpu_ids, cpumask_next(-1, &mask_empty), 90 + MASK_MSG(&mask_empty)); 91 + KUNIT_EXPECT_EQ_MSG(test, 0, cpumask_next(-1, cpu_possible_mask), 92 + MASK_MSG(cpu_possible_mask)); 93 } 94 95 static void test_cpumask_iterators(struct kunit *test)