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

Configure Feed

Select the types of activity you want to include in your feed.

bitmap: test bitmap_weight() for more

Test the function for correctness when some bits are set in the last word
of bitmap beyond nbits. This is motivated by commit a9dadc1c512807f9
("powerpc/xive: Fix the size of the cpumask used in
xive_find_target_in_mask()").

Signed-off-by: Yury Norov <ynorov@nvidia.com>

+19
+19
lib/test_bitmap.c
··· 858 858 { 859 859 unsigned int bit, w1, w2, w; 860 860 DECLARE_BITMAP(b, 30); 861 + DECLARE_BITMAP(b1, 128); 861 862 862 863 bitmap_parselist("all:1/2", b, 30); 863 864 ··· 878 877 w2 = bitmap_weight_from(exp1, bit, EXP1_IN_BITS); 879 878 expect_eq_uint(w1 + w2, w); 880 879 } 880 + 881 + /* Test out-of-range */ 882 + w = bitmap_weight_from(b, 31, 30); 883 + expect_eq_uint(0, !!(w < 30)); 884 + 885 + /* 886 + * Test bitmap_weight() for correctness in case of some bits set between 887 + * nbits and end of the last word. 888 + */ 889 + bitmap_fill(b1, 128); 890 + 891 + /* Inline */ 892 + expect_eq_uint(30, bitmap_weight(b1, 30)); 893 + expect_eq_uint(100, bitmap_weight(b1, 100)); 894 + 895 + /* Outline */ 896 + for (int i = 1; i < 128; i++) 897 + expect_eq_uint(i, bitmap_weight(b1, i)); 881 898 } 882 899 883 900 static void __init test_for_each_clear_bit(void)