--- include/linux/percpu.h | 6 +----- mm/allocpercpu.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 7 deletions(-) Index: linux-2.6/mm/allocpercpu.c =================================================================== --- linux-2.6.orig/mm/allocpercpu.c 2007-10-30 16:47:34.000000000 -0700 +++ linux-2.6/mm/allocpercpu.c 2007-10-30 16:47:47.000000000 -0700 @@ -14,9 +14,13 @@ #define FREE 0 #define USED 255 +typedef unsigned long long per_cpu_unit; + static DEFINE_SPINLOCK(cpu_area_lock); static u8 cpu_alloc_map[MAXIMUM_UNITS_PER_CPU]; -DEFINE_PER_CPU(per_cpu_unit, cpu_area)[MAXIMUM_UNITS_PER_CPU]; +static DEFINE_PER_CPU(per_cpu_unit, cpu_area)[MAXIMUM_UNITS_PER_CPU]; + +#define CPU_DATA_OFFSET ((unsigned long)&__get_cpu_var(cpu_area)) static inline int size_to_units(unsigned long size) { @@ -61,7 +65,7 @@ static inline void *cpu_alloc(unsigned l set_map(start, units); spin_unlock(&cpu_area_lock); - return (void *)start; + return (void *)(start * sizeof(per_cpu_unit) + CPU_DATA_OFFSET); } static inline void cpu_free(void *pcpu) @@ -69,6 +73,8 @@ static inline void cpu_free(void *pcpu) unsigned long start = (unsigned long)pcpu; int units; + BUG_ON(start < CPU_DATA_OFFSET); + start = (start - CPU_DATA_OFFSET) / sizeof(per_cpu_unit); units = cpu_alloc_map[start]; BUG_ON(units == FREE || units == USED || start >= MAXIMUM_UNITS_PER_CPU); Index: linux-2.6/include/linux/percpu.h =================================================================== --- linux-2.6.orig/include/linux/percpu.h 2007-10-30 16:47:44.000000000 -0700 +++ linux-2.6/include/linux/percpu.h 2007-10-30 16:47:50.000000000 -0700 @@ -33,10 +33,6 @@ #ifdef CONFIG_SMP -typedef unsigned long long per_cpu_unit; - -DECLARE_PER_CPU(per_cpu_unit, cpu_area)[]; - /* * Use this to get to a cpu's version of the per-cpu object dynamically * allocated. Non-atomic access to the current CPU's version should @@ -44,7 +40,7 @@ DECLARE_PER_CPU(per_cpu_unit, cpu_area)[ */ #define percpu_ptr(ptr, cpu) \ ({ \ - (__typeof__(ptr))((per_cpu(cpu_area, cpu) + (unsigned long)ptr)); \ + (__typeof__(ptr))((unsigned long)ptr + per_cpu_offset(cpu)); \ }) extern void *percpu_populate(void *__pdata, size_t size, gfp_t gfp, int cpu);