]> git.hungrycats.org Git - linux/commitdiff
[PATCH] per-cpu cleanup
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 9 Apr 2002 07:46:00 +0000 (00:46 -0700)
committerLinus Torvalds <torvalds@penguin.transmeta.com>
Tue, 9 Apr 2002 07:46:00 +0000 (00:46 -0700)
As per David Mosberger's request, splits into per-arch files (solves the
#include mess), and fixes my "was not an lvalue" bug.

include/asm-generic/percpu.h [new file with mode: 0644]
include/asm-i386/percpu.h [new file with mode: 0644]
include/asm-ppc/percpu.h [new file with mode: 0644]
include/linux/compiler.h
include/linux/percpu.h [new file with mode: 0644]
include/linux/smp.h
init/main.c

diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h
new file mode 100644 (file)
index 0000000..0ad91ae
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef _ASM_GENERIC_PERCPU_H_
+#define _ASM_GENERIC_PERCPU_H_
+
+#define __GENERIC_PER_CPU
+#include <linux/compiler.h>
+
+extern unsigned long __per_cpu_offset[NR_CPUS];
+
+/* var is in discarded region: offset to particular copy we want */
+#define per_cpu(var, cpu) (*RELOC_HIDE(&var, __per_cpu_offset[cpu]))
+#define this_cpu(var) per_cpu(var, smp_processor_id())
+
+#endif /* _ASM_GENERIC_PERCPU_H_ */
diff --git a/include/asm-i386/percpu.h b/include/asm-i386/percpu.h
new file mode 100644 (file)
index 0000000..5764afa
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef __ARCH_I386_PERCPU__
+#define __ARCH_I386_PERCPU__
+
+#include <asm-generic/percpu.h>
+
+#endif /* __ARCH_I386_PERCPU__ */
diff --git a/include/asm-ppc/percpu.h b/include/asm-ppc/percpu.h
new file mode 100644 (file)
index 0000000..d66667c
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef __ARCH_PPC_PERCPU__
+#define __ARCH_PPC_PERCPU__
+
+#include <asm-generic/percpu.h>
+
+#endif /* __ARCH_PPC_PERCPU__ */
index ccaabc24e367f22f211881cf4353a2066f9ba017..eea3d3636e2afae2058ef6853d1c33beeb454cc9 100644 (file)
@@ -15,8 +15,8 @@
 
 /* This macro obfuscates arithmetic on a variable address so that gcc
    shouldn't recognize the original var, and make assumptions about it */
-#define RELOC_HIDE(var, off)                                   \
-  ({ __typeof__(&(var)) __ptr;                                 \
-    __asm__ ("" : "=g"(__ptr) : "0"((void *)&(var) + (off)));  \
-    *__ptr; })
+#define RELOC_HIDE(ptr, off)                                   \
+  ({ __typeof__(ptr) __ptr;                                    \
+    __asm__ ("" : "=g"(__ptr) : "0"((void *)(ptr) + (off)));   \
+    __ptr; })
 #endif /* __LINUX_COMPILER_H */
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
new file mode 100644 (file)
index 0000000..577df0f
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef __LINUX_PERCPU_H
+#define __LINUX_PERCPU_H
+#include <linux/config.h>
+
+#ifdef CONFIG_SMP
+#define __per_cpu_data __attribute__((section(".data.percpu")))
+#include <asm/percpu.h>
+#else
+#define __per_cpu_data
+#define per_cpu(var, cpu)                      var
+#define this_cpu(var)                          var
+#endif
+
+#endif /* __LINUX_PERCPU_H */
index 5290555e81011de329079c19a096ce9a9d977fec..8fa9b49f0961195663ae49f3a92af02d44bfe001 100644 (file)
@@ -72,16 +72,6 @@ extern volatile int smp_msg_id;
 #define MSG_RESCHEDULE         0x0003  /* Reschedule request from master CPU*/
 #define MSG_CALL_FUNCTION       0x0004  /* Call function on all other CPUs */
 
-#define __per_cpu_data __attribute__((section(".data.percpu")))
-
-#ifndef __HAVE_ARCH_PER_CPU
-extern unsigned long __per_cpu_offset[NR_CPUS];
-
-/* var is in discarded region: offset to particular copy we want */
-#define per_cpu(var, cpu) RELOC_HIDE(var, per_cpu_offset(cpu))
-
-#define this_cpu(var) per_cpu(var, smp_processor_id())
-#endif /* !__HAVE_ARCH_PER_CPU */
 #else /* !SMP */
 
 /*
index e5f17bfb5c98d273ad2e25a68d7523de0e80555f..e4f0d32230954532d096e5e485d27ba221950985 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/iobuf.h>
 #include <linux/bootmem.h>
 #include <linux/tty.h>
+#include <linux/percpu.h>
 
 #include <asm/io.h>
 #include <asm/bugs.h>
@@ -270,12 +271,9 @@ static void __init smp_init(void)
 #define smp_init()     do { } while (0)
 #endif
 
-static inline void setup_per_cpu_areas(void)
-{
-}
 #else
 
-#ifndef __HAVE_ARCH_PER_CPU
+#ifdef __GENERIC_PER_CPU
 unsigned long __per_cpu_offset[NR_CPUS];
 
 static void __init setup_per_cpu_areas(void)
@@ -297,7 +295,11 @@ static void __init setup_per_cpu_areas(void)
                memcpy(ptr, __per_cpu_start, size);
        }
 }
-#endif /* !__HAVE_ARCH_PER_CPU */
+#else
+static inline void setup_per_cpu_areas(void)
+{
+}
+#endif /* !__GENERIC_PER_CPU */
 
 /* Called by boot processor to activate the rest. */
 static void __init smp_init(void)