* [RFC,PATCH] use nonatomic bitops for cpumask_t
@ 2004-05-29 8:57 Manfred Spraul
2004-05-29 9:46 ` Manfred Spraul
0 siblings, 1 reply; 3+ messages in thread
From: Manfred Spraul @ 2004-05-29 8:57 UTC (permalink / raw)
To: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 365 bytes --]
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
[-- Attachment #2: patch-nonatomic-cpumask --]
[-- Type: text/plain, Size: 2574 bytes --]
diff -u 2.6/include/asm-generic/cpumask_arith.h build-2.6/include/asm-generic/cpumask_arith.h
--- 2.6/include/asm-generic/cpumask_arith.h 2004-05-23 21:08:51.000000000 +0200
+++ build-2.6/include/asm-generic/cpumask_arith.h 2004-05-29 10:34:53.000000000 +0200
@@ -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)
diff -u 2.6/include/asm-generic/cpumask_array.h build-2.6/include/asm-generic/cpumask_array.h
--- 2.6/include/asm-generic/cpumask_array.h 2004-05-23 21:08:51.000000000 +0200
+++ build-2.6/include/asm-generic/cpumask_array.h 2004-05-29 10:35:19.000000000 +0200
@@ -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)
diff -u 2.6/include/asm-generic/cpumask_up.h build-2.6/include/asm-generic/cpumask_up.h
--- 2.6/include/asm-generic/cpumask_up.h 2004-01-09 07:59:19.000000000 +0100
+++ build-2.6/include/asm-generic/cpumask_up.h 2004-05-29 10:41:25.000000000 +0200
@@ -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 { \
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [RFC,PATCH] use nonatomic bitops for cpumask_t
2004-05-29 8:57 [RFC,PATCH] use nonatomic bitops for cpumask_t Manfred Spraul
@ 2004-05-29 9:46 ` Manfred Spraul
0 siblings, 0 replies; 3+ messages in thread
From: Manfred Spraul @ 2004-05-29 9:46 UTC (permalink / raw)
To: linux-kernel
Manfred Spraul wrote:
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC,PATCH] use nonatomic bitops for cpumask_t
@ 2004-05-29 11:02 Mikael Pettersson
0 siblings, 0 replies; 3+ messages in thread
From: Mikael Pettersson @ 2004-05-29 11:02 UTC (permalink / raw)
To: linux-kernel, manfred
On Sat, 29 May 2004 10:57:21 +0200, Manfred Spraul wrote:
>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.
The perfctr kernel extension (not yet merged) calls
cpu_set() from a function invoked via smp_call_function(),
relying on cpu_set() being atomic.
I can take a spinlock there, but it seems ugly when an
atomic set_bit would suffice.
Also, may I request that when changing a fundamental aspect
of the semantics of an operation, you also change its name?
That way, unconverted code will get a compile or link error
rather than breaking at runtime.
/Mikael
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-05-29 11:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-29 8:57 [RFC,PATCH] use nonatomic bitops for cpumask_t Manfred Spraul
2004-05-29 9:46 ` Manfred Spraul
-- strict thread matches above, loose matches on Subject: below --
2004-05-29 11:02 Mikael Pettersson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox