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