use nonatomic bitops for cpumask_t
RFC PATCH 1/1 use nonatomic bitops for cpumask_t
Hi,
The default implementation for cpumasks in <asm-generic/cpumask*> uses atomic bitops for the operations that affect a single cpu and nonatomic operations for the rest. What about switching to nonatomic operations for all operations? I'm checking for callers that rely on the atomicity of the bitops, but so far everyone has it's own locks.
--
Manfred
include/asm-generic/cpumask_arith.h +3 -3
@@ -6,10 +6,10 @@* to contain the whole cpu bitmap. */ -#define cpu_set (cpu, map) set_bit(cpu, &(map)) -#define cpu_clear (cpu, map) clear_bit(cpu, &(map)) +#define cpu_set (cpu, map) __set_bit(cpu, &(map)) +#define cpu_clear (cpu, map) __clear_bit(cpu, &(map))#define cpu_isset (cpu, map) test_bit(cpu, &(map)) -#define cpu_test_and_set (cpu, map) test_and_set_bit(cpu, &(map)) +#define cpu_test_and_set (cpu, map) __test_and_set_bit(cpu, &(map))#define cpus_and (dst,src1,src2) do { dst = (src1) & (src2); } while (0)#define cpus_or (dst,src1,src2) do { dst = (src1) | (src2); } while (0)
include/asm-generic/cpumask_array.h +4 -4
@@ -9,10 +9,10 @@#define CPU_ARRAY_SIZE BITS_TO_LONGS(NR_CPUS) -#define cpu_set (cpu, map) set_bit(cpu, (map).mask) -#define cpu_clear (cpu, map) clear_bit(cpu, (map).mask) -#define cpu_isset (cpu, map) test_bit(cpu, (map).mask) -#define cpu_test_and_set (cpu, map) test_and_set_bit(cpu, (map).mask) +#define cpu_set (cpu, map) __set_bit(cpu, (map).mask) +#define cpu_clear (cpu, map) __clear_bit(cpu, (map).mask) +#define cpu_isset (cpu, map) __test_bit(cpu, (map).mask) +#define cpu_test_and_set (cpu, map) __test_and_set_bit(cpu, (map).mask)#define cpus_and (dst,src1,src2) bitmap_and((dst).mask,(src1).mask, (src2).mask, NR_CPUS)#define cpus_or (dst,src1,src2) bitmap_or((dst).mask, (src1).mask, (src2).mask, NR_CPUS)
include/asm-generic/cpumask_up.h +1 -1
@@ -6,7 +6,7 @@#define cpu_set (cpu, map) do { (void)(cpu); cpus_coerce(map) = 1UL; } while (0)#define cpu_clear (cpu, map) do { (void)(cpu); cpus_coerce(map) = 0UL; } while (0)#define cpu_isset (cpu, map) ((void)(cpu), cpus_coerce(map) != 0UL) -#define cpu_test_and_set (cpu, map) ((void)(cpu), test_and_set_bit(0, &(map))) +#define cpu_test_and_set (cpu, map) ((void)(cpu), __test_and_set_bit(0, &(map)))#define cpus_and (dst, src1, src2) \ do { \
Quoted 3 lines · Manfred Spraul
Hi,
I'm checking for callers that rely on the atomicity of the bitops, but so far everyone has it's own locks.
One exception is the x86 tlb flush code, thus my patch is wrong. We could add nonatomic __cpu_set and __cpu_clear bitops, but I'm not sure if it's worth the effort, cpu bitops aren't that common (kernel/rcupdate.c and balance_node could use the __ versions).
Sorry for the noise (and don't check who wrote the x86 tlb flush code) --
Manfred