Skip to content

Commit 51c4767

Browse files
committed
Merge tag 'bitmap-6.11-rc1' of https://github.com:/norov/linux
Pull bitmap updates from Yury Norov: "Random fixes" * tag 'bitmap-6.11-rc1' of https://github.com:/norov/linux: riscv: Remove unnecessary int cast in variable_fls() radix tree test suite: put definition of bitmap_clear() into lib/bitmap.c bitops: Add a comment explaining the double underscore macros lib: bitmap: add missing MODULE_DESCRIPTION() macros cpumask: introduce assign_cpu() macro
2 parents 1722389 + fb9086e commit 51c4767

File tree

10 files changed

+54
-70
lines changed

10 files changed

+54
-70
lines changed

arch/riscv/include/asm/bitops.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static __always_inline int variable_fls(unsigned int x)
170170
({ \
171171
typeof(x) x_ = (x); \
172172
__builtin_constant_p(x_) ? \
173-
(int)((x_ != 0) ? (32 - __builtin_clz(x_)) : 0) \
173+
((x_ != 0) ? (32 - __builtin_clz(x_)) : 0) \
174174
: \
175175
variable_fls(x_); \
176176
})

include/linux/bitops.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,17 @@ extern unsigned long __sw_hweight64(__u64 w);
4747
__builtin_constant_p(*(const unsigned long *)(addr))) ? \
4848
const##op(nr, addr) : op(nr, addr))
4949

50+
/*
51+
* The following macros are non-atomic versions of their non-underscored
52+
* counterparts.
53+
*/
5054
#define __set_bit(nr, addr) bitop(___set_bit, nr, addr)
5155
#define __clear_bit(nr, addr) bitop(___clear_bit, nr, addr)
5256
#define __change_bit(nr, addr) bitop(___change_bit, nr, addr)
5357
#define __test_and_set_bit(nr, addr) bitop(___test_and_set_bit, nr, addr)
5458
#define __test_and_clear_bit(nr, addr) bitop(___test_and_clear_bit, nr, addr)
5559
#define __test_and_change_bit(nr, addr) bitop(___test_and_change_bit, nr, addr)
60+
5661
#define test_bit(nr, addr) bitop(_test_bit, nr, addr)
5762
#define test_bit_acquire(nr, addr) bitop(_test_bit_acquire, nr, addr)
5863

include/linux/cpumask.h

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,53 +1033,17 @@ void init_cpu_present(const struct cpumask *src);
10331033
void init_cpu_possible(const struct cpumask *src);
10341034
void init_cpu_online(const struct cpumask *src);
10351035

1036-
static inline void
1037-
set_cpu_possible(unsigned int cpu, bool possible)
1038-
{
1039-
if (possible)
1040-
cpumask_set_cpu(cpu, &__cpu_possible_mask);
1041-
else
1042-
cpumask_clear_cpu(cpu, &__cpu_possible_mask);
1043-
}
1036+
#define assign_cpu(cpu, mask, val) \
1037+
assign_bit(cpumask_check(cpu), cpumask_bits(mask), (val))
10441038

1045-
static inline void
1046-
set_cpu_enabled(unsigned int cpu, bool can_be_onlined)
1047-
{
1048-
if (can_be_onlined)
1049-
cpumask_set_cpu(cpu, &__cpu_enabled_mask);
1050-
else
1051-
cpumask_clear_cpu(cpu, &__cpu_enabled_mask);
1052-
}
1053-
1054-
static inline void
1055-
set_cpu_present(unsigned int cpu, bool present)
1056-
{
1057-
if (present)
1058-
cpumask_set_cpu(cpu, &__cpu_present_mask);
1059-
else
1060-
cpumask_clear_cpu(cpu, &__cpu_present_mask);
1061-
}
1039+
#define set_cpu_possible(cpu, possible) assign_cpu((cpu), &__cpu_possible_mask, (possible))
1040+
#define set_cpu_enabled(cpu, enabled) assign_cpu((cpu), &__cpu_possible_mask, (enabled))
1041+
#define set_cpu_present(cpu, present) assign_cpu((cpu), &__cpu_present_mask, (present))
1042+
#define set_cpu_active(cpu, active) assign_cpu((cpu), &__cpu_active_mask, (active))
1043+
#define set_cpu_dying(cpu, dying) assign_cpu((cpu), &__cpu_dying_mask, (dying))
10621044

10631045
void set_cpu_online(unsigned int cpu, bool online);
10641046

1065-
static inline void
1066-
set_cpu_active(unsigned int cpu, bool active)
1067-
{
1068-
if (active)
1069-
cpumask_set_cpu(cpu, &__cpu_active_mask);
1070-
else
1071-
cpumask_clear_cpu(cpu, &__cpu_active_mask);
1072-
}
1073-
1074-
static inline void
1075-
set_cpu_dying(unsigned int cpu, bool dying)
1076-
{
1077-
if (dying)
1078-
cpumask_set_cpu(cpu, &__cpu_dying_mask);
1079-
else
1080-
cpumask_clear_cpu(cpu, &__cpu_dying_mask);
1081-
}
1082-
10831047
/**
10841048
* to_cpumask - convert a NR_CPUS bitmap to a struct cpumask *
10851049
* @bitmap: the bitmap

lib/cpumask_kunit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,5 @@ static struct kunit_suite test_cpumask_suite = {
152152
};
153153
kunit_test_suite(test_cpumask_suite);
154154

155+
MODULE_DESCRIPTION("KUnit tests for cpumask");
155156
MODULE_LICENSE("GPL");

lib/find_bit_benchmark.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,5 @@ static int __init find_bit_test(void)
194194
}
195195
module_init(find_bit_test);
196196

197+
MODULE_DESCRIPTION("Test for find_*_bit functions");
197198
MODULE_LICENSE("GPL");

lib/test_bitmap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,4 +1486,5 @@ static void __init selftest(void)
14861486

14871487
KSTM_MODULE_LOADERS(test_bitmap);
14881488
MODULE_AUTHOR("david decotigny <[email protected]>");
1489+
MODULE_DESCRIPTION("Test cases for bitmap API");
14891490
MODULE_LICENSE("GPL");

tools/include/linux/bitmap.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ bool __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
1919
const unsigned long *bitmap2, unsigned int bits);
2020
bool __bitmap_equal(const unsigned long *bitmap1,
2121
const unsigned long *bitmap2, unsigned int bits);
22-
void bitmap_clear(unsigned long *map, unsigned int start, int len);
22+
void __bitmap_clear(unsigned long *map, unsigned int start, int len);
2323
bool __bitmap_intersects(const unsigned long *bitmap1,
2424
const unsigned long *bitmap2, unsigned int bits);
2525

@@ -150,4 +150,19 @@ static inline bool bitmap_intersects(const unsigned long *src1,
150150
return __bitmap_intersects(src1, src2, nbits);
151151
}
152152

153+
static inline void bitmap_clear(unsigned long *map, unsigned int start,
154+
unsigned int nbits)
155+
{
156+
if (__builtin_constant_p(nbits) && nbits == 1)
157+
__clear_bit(start, map);
158+
else if (small_const_nbits(start + nbits))
159+
*map &= ~GENMASK(start + nbits - 1, start);
160+
else if (__builtin_constant_p(start & BITMAP_MEM_MASK) &&
161+
IS_ALIGNED(start, BITMAP_MEM_ALIGNMENT) &&
162+
__builtin_constant_p(nbits & BITMAP_MEM_MASK) &&
163+
IS_ALIGNED(nbits, BITMAP_MEM_ALIGNMENT))
164+
memset((char *)map + start / 8, 0, nbits / 8);
165+
else
166+
__bitmap_clear(map, start, nbits);
167+
}
153168
#endif /* _TOOLS_LINUX_BITMAP_H */

tools/lib/bitmap.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,23 @@ bool __bitmap_intersects(const unsigned long *bitmap1,
100100
return true;
101101
return false;
102102
}
103+
104+
void __bitmap_clear(unsigned long *map, unsigned int start, int len)
105+
{
106+
unsigned long *p = map + BIT_WORD(start);
107+
const unsigned int size = start + len;
108+
int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
109+
unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
110+
111+
while (len - bits_to_clear >= 0) {
112+
*p &= ~mask_to_clear;
113+
len -= bits_to_clear;
114+
bits_to_clear = BITS_PER_LONG;
115+
mask_to_clear = ~0UL;
116+
p++;
117+
}
118+
if (len) {
119+
mask_to_clear &= BITMAP_LAST_WORD_MASK(size);
120+
*p &= ~mask_to_clear;
121+
}
122+
}

tools/testing/radix-tree/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ CFLAGS += -I. -I../../include -I../../../lib -g -Og -Wall \
55
LDFLAGS += -fsanitize=address -fsanitize=undefined
66
LDLIBS+= -lpthread -lurcu
77
TARGETS = main idr-test multiorder xarray maple
8-
CORE_OFILES := xarray.o radix-tree.o idr.o linux.o test.o find_bit.o bitmap.o \
9-
slab.o maple.o
8+
LIBS := slab.o find_bit.o bitmap.o hweight.o vsprintf.o
9+
CORE_OFILES := xarray.o radix-tree.o idr.o linux.o test.o maple.o $(LIBS)
1010
OFILES = main.o $(CORE_OFILES) regression1.o regression2.o regression3.o \
1111
regression4.o tag_check.o multiorder.o idr-test.o iteration_check.o \
1212
iteration_check_2.o benchmark.o

tools/testing/radix-tree/bitmap.c

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)