USB: implement "soft" unbinding
[safe/jmp/linux-2.6] / include / linux / percpu.h
index 46ec72f..4cdd393 100644 (file)
@@ -1,25 +1,57 @@
 #ifndef __LINUX_PERCPU_H
 #define __LINUX_PERCPU_H
 
-#include <linux/spinlock.h> /* For preempt_disable() */
+#include <linux/preempt.h>
 #include <linux/slab.h> /* For kmalloc() */
 #include <linux/smp.h>
-#include <linux/string.h> /* For memset() */
 #include <linux/cpumask.h>
 
 #include <asm/percpu.h>
 
+#ifdef CONFIG_SMP
+#define DEFINE_PER_CPU(type, name)                                     \
+       __attribute__((__section__(".data.percpu")))                    \
+       PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name
+
+#ifdef MODULE
+#define SHARED_ALIGNED_SECTION ".data.percpu"
+#else
+#define SHARED_ALIGNED_SECTION ".data.percpu.shared_aligned"
+#endif
+
+#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name)                      \
+       __attribute__((__section__(SHARED_ALIGNED_SECTION)))            \
+       PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name             \
+       ____cacheline_aligned_in_smp
+#else
+#define DEFINE_PER_CPU(type, name)                                     \
+       PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name
+
+#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name)                    \
+       DEFINE_PER_CPU(type, name)
+#endif
+
+#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
+#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
+
 /* Enough to cover all DEFINE_PER_CPUs in kernel, including modules. */
 #ifndef PERCPU_ENOUGH_ROOM
-#define PERCPU_ENOUGH_ROOM 32768
+#ifdef CONFIG_MODULES
+#define PERCPU_MODULE_RESERVE  8192
+#else
+#define PERCPU_MODULE_RESERVE  0
 #endif
 
+#define PERCPU_ENOUGH_ROOM                                             \
+       (__per_cpu_end - __per_cpu_start + PERCPU_MODULE_RESERVE)
+#endif /* PERCPU_ENOUGH_ROOM */
+
 /*
  * Must be an lvalue. Since @var must be a simple identifier,
  * we force a syntax error here if it isn't.
  */
 #define get_cpu_var(var) (*({                          \
-       extern int simple_indentifier_##var(void);      \
+       extern int simple_identifier_##var(void);       \
        preempt_disable();                              \
        &__get_cpu_var(var); }))
 #define put_cpu_var(var) preempt_enable()
@@ -27,7 +59,7 @@
 #ifdef CONFIG_SMP
 
 struct percpu_data {
-       void *ptrs[NR_CPUS];
+       void *ptrs[1];
 };
 
 #define __percpu_disguise(pdata) (struct percpu_data *)~(unsigned long)(pdata)