]> err.no Git - linux-2.6/blobdiff - include/linux/percpu.h
PERCPU : __percpu_alloc_mask() can dynamically size percpu_data storage
[linux-2.6] / include / linux / percpu.h
index 600e3d387ffc9b2f5445cc3f2c92e6512524a996..1ac969724bb2fff929c397be1cbdcdf007a61953 100644 (file)
@@ -1,7 +1,7 @@
 #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() */
@@ -9,11 +9,38 @@
 
 #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
+
+#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name)                      \
+       __attribute__((__section__(".data.percpu.shared_aligned")))     \
+       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.
@@ -27,7 +54,7 @@
 #ifdef CONFIG_SMP
 
 struct percpu_data {
-       void *ptrs[NR_CPUS];
+       void *ptrs[1];
 };
 
 #define __percpu_disguise(pdata) (struct percpu_data *)~(unsigned long)(pdata)