mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-04-13 09:59:31 +00:00
bitmap-6.11-rc1
Random fixes for v6.11. -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEi8GdvG6xMhdgpu/4sUSA/TofvsgFAmahKbIACgkQsUSA/Tof vsh8zQwAvguyeNubDFqdMe3E/Vp1J3WqXsBFzbE1rGLCyI2S0cgJFL5BlW51zY47 70wLt9EmroEobwj1qHSQlzejNp31kSBQ1Sqq25oivfJqEF1elDT5PQxYqBbU1C9Y kVWnxtb+oKaoFd5jiBK8+iTl8dXjT6H2RoV0zpPab/JPcqsjwFfkUvtENt/Kpo5c aRrGTFwshdp5eT4sEZQv57VKroBcwZOvv2//qrklFHrJHl4pjMT8eaX3twcQysoy umTVt+TK6NErLnht+VRQJ2/L02FKi7b+bHePVgNzaT+1FSDMT4FltmZd96Xwbzah hSkwWtqy0N2gaTcqie9nwdEiCJGjF39M7k2wangUS91CeDsbIUSsJgDCESUCm+zK hRqleGOnoeg4+jZBci7M53lKa/pADlmLhnU8iAc3BSKozsaioltkT+hHn8vAkstk h/kHlbfkzasufUWAhduBpIn384gWWEY6RACffgCsOuvbT+ZyDKUJpKYaEwVx+Pri l72j0hs9 =RbET -----END PGP SIGNATURE----- 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
This commit is contained in:
commit
51c4767503
10 changed files with 54 additions and 70 deletions
|
@ -170,7 +170,7 @@ legacy:
|
||||||
({ \
|
({ \
|
||||||
typeof(x) x_ = (x); \
|
typeof(x) x_ = (x); \
|
||||||
__builtin_constant_p(x_) ? \
|
__builtin_constant_p(x_) ? \
|
||||||
(int)((x_ != 0) ? (32 - __builtin_clz(x_)) : 0) \
|
((x_ != 0) ? (32 - __builtin_clz(x_)) : 0) \
|
||||||
: \
|
: \
|
||||||
variable_fls(x_); \
|
variable_fls(x_); \
|
||||||
})
|
})
|
||||||
|
|
|
@ -47,12 +47,17 @@ extern unsigned long __sw_hweight64(__u64 w);
|
||||||
__builtin_constant_p(*(const unsigned long *)(addr))) ? \
|
__builtin_constant_p(*(const unsigned long *)(addr))) ? \
|
||||||
const##op(nr, addr) : op(nr, addr))
|
const##op(nr, addr) : op(nr, addr))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following macros are non-atomic versions of their non-underscored
|
||||||
|
* counterparts.
|
||||||
|
*/
|
||||||
#define __set_bit(nr, addr) bitop(___set_bit, nr, addr)
|
#define __set_bit(nr, addr) bitop(___set_bit, nr, addr)
|
||||||
#define __clear_bit(nr, addr) bitop(___clear_bit, nr, addr)
|
#define __clear_bit(nr, addr) bitop(___clear_bit, nr, addr)
|
||||||
#define __change_bit(nr, addr) bitop(___change_bit, nr, addr)
|
#define __change_bit(nr, addr) bitop(___change_bit, nr, addr)
|
||||||
#define __test_and_set_bit(nr, addr) bitop(___test_and_set_bit, nr, addr)
|
#define __test_and_set_bit(nr, addr) bitop(___test_and_set_bit, nr, addr)
|
||||||
#define __test_and_clear_bit(nr, addr) bitop(___test_and_clear_bit, nr, addr)
|
#define __test_and_clear_bit(nr, addr) bitop(___test_and_clear_bit, nr, addr)
|
||||||
#define __test_and_change_bit(nr, addr) bitop(___test_and_change_bit, nr, addr)
|
#define __test_and_change_bit(nr, addr) bitop(___test_and_change_bit, nr, addr)
|
||||||
|
|
||||||
#define test_bit(nr, addr) bitop(_test_bit, nr, addr)
|
#define test_bit(nr, addr) bitop(_test_bit, nr, addr)
|
||||||
#define test_bit_acquire(nr, addr) bitop(_test_bit_acquire, nr, addr)
|
#define test_bit_acquire(nr, addr) bitop(_test_bit_acquire, nr, addr)
|
||||||
|
|
||||||
|
|
|
@ -1033,53 +1033,17 @@ void init_cpu_present(const struct cpumask *src);
|
||||||
void init_cpu_possible(const struct cpumask *src);
|
void init_cpu_possible(const struct cpumask *src);
|
||||||
void init_cpu_online(const struct cpumask *src);
|
void init_cpu_online(const struct cpumask *src);
|
||||||
|
|
||||||
static inline void
|
#define assign_cpu(cpu, mask, val) \
|
||||||
set_cpu_possible(unsigned int cpu, bool possible)
|
assign_bit(cpumask_check(cpu), cpumask_bits(mask), (val))
|
||||||
{
|
|
||||||
if (possible)
|
|
||||||
cpumask_set_cpu(cpu, &__cpu_possible_mask);
|
|
||||||
else
|
|
||||||
cpumask_clear_cpu(cpu, &__cpu_possible_mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
#define set_cpu_possible(cpu, possible) assign_cpu((cpu), &__cpu_possible_mask, (possible))
|
||||||
set_cpu_enabled(unsigned int cpu, bool can_be_onlined)
|
#define set_cpu_enabled(cpu, enabled) assign_cpu((cpu), &__cpu_possible_mask, (enabled))
|
||||||
{
|
#define set_cpu_present(cpu, present) assign_cpu((cpu), &__cpu_present_mask, (present))
|
||||||
if (can_be_onlined)
|
#define set_cpu_active(cpu, active) assign_cpu((cpu), &__cpu_active_mask, (active))
|
||||||
cpumask_set_cpu(cpu, &__cpu_enabled_mask);
|
#define set_cpu_dying(cpu, dying) assign_cpu((cpu), &__cpu_dying_mask, (dying))
|
||||||
else
|
|
||||||
cpumask_clear_cpu(cpu, &__cpu_enabled_mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
set_cpu_present(unsigned int cpu, bool present)
|
|
||||||
{
|
|
||||||
if (present)
|
|
||||||
cpumask_set_cpu(cpu, &__cpu_present_mask);
|
|
||||||
else
|
|
||||||
cpumask_clear_cpu(cpu, &__cpu_present_mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_cpu_online(unsigned int cpu, bool online);
|
void set_cpu_online(unsigned int cpu, bool online);
|
||||||
|
|
||||||
static inline void
|
|
||||||
set_cpu_active(unsigned int cpu, bool active)
|
|
||||||
{
|
|
||||||
if (active)
|
|
||||||
cpumask_set_cpu(cpu, &__cpu_active_mask);
|
|
||||||
else
|
|
||||||
cpumask_clear_cpu(cpu, &__cpu_active_mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
set_cpu_dying(unsigned int cpu, bool dying)
|
|
||||||
{
|
|
||||||
if (dying)
|
|
||||||
cpumask_set_cpu(cpu, &__cpu_dying_mask);
|
|
||||||
else
|
|
||||||
cpumask_clear_cpu(cpu, &__cpu_dying_mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* to_cpumask - convert a NR_CPUS bitmap to a struct cpumask *
|
* to_cpumask - convert a NR_CPUS bitmap to a struct cpumask *
|
||||||
* @bitmap: the bitmap
|
* @bitmap: the bitmap
|
||||||
|
|
|
@ -152,4 +152,5 @@ static struct kunit_suite test_cpumask_suite = {
|
||||||
};
|
};
|
||||||
kunit_test_suite(test_cpumask_suite);
|
kunit_test_suite(test_cpumask_suite);
|
||||||
|
|
||||||
|
MODULE_DESCRIPTION("KUnit tests for cpumask");
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
|
|
|
@ -194,4 +194,5 @@ static int __init find_bit_test(void)
|
||||||
}
|
}
|
||||||
module_init(find_bit_test);
|
module_init(find_bit_test);
|
||||||
|
|
||||||
|
MODULE_DESCRIPTION("Test for find_*_bit functions");
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
|
|
|
@ -1486,4 +1486,5 @@ static void __init selftest(void)
|
||||||
|
|
||||||
KSTM_MODULE_LOADERS(test_bitmap);
|
KSTM_MODULE_LOADERS(test_bitmap);
|
||||||
MODULE_AUTHOR("david decotigny <david.decotigny@googlers.com>");
|
MODULE_AUTHOR("david decotigny <david.decotigny@googlers.com>");
|
||||||
|
MODULE_DESCRIPTION("Test cases for bitmap API");
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
|
|
|
@ -19,7 +19,7 @@ bool __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
|
||||||
const unsigned long *bitmap2, unsigned int bits);
|
const unsigned long *bitmap2, unsigned int bits);
|
||||||
bool __bitmap_equal(const unsigned long *bitmap1,
|
bool __bitmap_equal(const unsigned long *bitmap1,
|
||||||
const unsigned long *bitmap2, unsigned int bits);
|
const unsigned long *bitmap2, unsigned int bits);
|
||||||
void bitmap_clear(unsigned long *map, unsigned int start, int len);
|
void __bitmap_clear(unsigned long *map, unsigned int start, int len);
|
||||||
bool __bitmap_intersects(const unsigned long *bitmap1,
|
bool __bitmap_intersects(const unsigned long *bitmap1,
|
||||||
const unsigned long *bitmap2, unsigned int bits);
|
const unsigned long *bitmap2, unsigned int bits);
|
||||||
|
|
||||||
|
@ -150,4 +150,19 @@ static inline bool bitmap_intersects(const unsigned long *src1,
|
||||||
return __bitmap_intersects(src1, src2, nbits);
|
return __bitmap_intersects(src1, src2, nbits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void bitmap_clear(unsigned long *map, unsigned int start,
|
||||||
|
unsigned int nbits)
|
||||||
|
{
|
||||||
|
if (__builtin_constant_p(nbits) && nbits == 1)
|
||||||
|
__clear_bit(start, map);
|
||||||
|
else if (small_const_nbits(start + nbits))
|
||||||
|
*map &= ~GENMASK(start + nbits - 1, start);
|
||||||
|
else if (__builtin_constant_p(start & BITMAP_MEM_MASK) &&
|
||||||
|
IS_ALIGNED(start, BITMAP_MEM_ALIGNMENT) &&
|
||||||
|
__builtin_constant_p(nbits & BITMAP_MEM_MASK) &&
|
||||||
|
IS_ALIGNED(nbits, BITMAP_MEM_ALIGNMENT))
|
||||||
|
memset((char *)map + start / 8, 0, nbits / 8);
|
||||||
|
else
|
||||||
|
__bitmap_clear(map, start, nbits);
|
||||||
|
}
|
||||||
#endif /* _TOOLS_LINUX_BITMAP_H */
|
#endif /* _TOOLS_LINUX_BITMAP_H */
|
||||||
|
|
|
@ -100,3 +100,23 @@ bool __bitmap_intersects(const unsigned long *bitmap1,
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __bitmap_clear(unsigned long *map, unsigned int start, int len)
|
||||||
|
{
|
||||||
|
unsigned long *p = map + BIT_WORD(start);
|
||||||
|
const unsigned int size = start + len;
|
||||||
|
int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
|
||||||
|
unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
|
||||||
|
|
||||||
|
while (len - bits_to_clear >= 0) {
|
||||||
|
*p &= ~mask_to_clear;
|
||||||
|
len -= bits_to_clear;
|
||||||
|
bits_to_clear = BITS_PER_LONG;
|
||||||
|
mask_to_clear = ~0UL;
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
if (len) {
|
||||||
|
mask_to_clear &= BITMAP_LAST_WORD_MASK(size);
|
||||||
|
*p &= ~mask_to_clear;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@ CFLAGS += -I. -I../../include -I../../../lib -g -Og -Wall \
|
||||||
LDFLAGS += -fsanitize=address -fsanitize=undefined
|
LDFLAGS += -fsanitize=address -fsanitize=undefined
|
||||||
LDLIBS+= -lpthread -lurcu
|
LDLIBS+= -lpthread -lurcu
|
||||||
TARGETS = main idr-test multiorder xarray maple
|
TARGETS = main idr-test multiorder xarray maple
|
||||||
CORE_OFILES := xarray.o radix-tree.o idr.o linux.o test.o find_bit.o bitmap.o \
|
LIBS := slab.o find_bit.o bitmap.o hweight.o vsprintf.o
|
||||||
slab.o maple.o
|
CORE_OFILES := xarray.o radix-tree.o idr.o linux.o test.o maple.o $(LIBS)
|
||||||
OFILES = main.o $(CORE_OFILES) regression1.o regression2.o regression3.o \
|
OFILES = main.o $(CORE_OFILES) regression1.o regression2.o regression3.o \
|
||||||
regression4.o tag_check.o multiorder.o idr-test.o iteration_check.o \
|
regression4.o tag_check.o multiorder.o idr-test.o iteration_check.o \
|
||||||
iteration_check_2.o benchmark.o
|
iteration_check_2.o benchmark.o
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
/* lib/bitmap.c pulls in at least two other files. */
|
|
||||||
|
|
||||||
#include <linux/bitmap.h>
|
|
||||||
|
|
||||||
void bitmap_clear(unsigned long *map, unsigned int start, int len)
|
|
||||||
{
|
|
||||||
unsigned long *p = map + BIT_WORD(start);
|
|
||||||
const unsigned int size = start + len;
|
|
||||||
int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
|
|
||||||
unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
|
|
||||||
|
|
||||||
while (len - bits_to_clear >= 0) {
|
|
||||||
*p &= ~mask_to_clear;
|
|
||||||
len -= bits_to_clear;
|
|
||||||
bits_to_clear = BITS_PER_LONG;
|
|
||||||
mask_to_clear = ~0UL;
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
if (len) {
|
|
||||||
mask_to_clear &= BITMAP_LAST_WORD_MASK(size);
|
|
||||||
*p &= ~mask_to_clear;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue