--- include/linux/percpu.h | 8 ++------ mm/allocpercpu.c | 15 +++++++++------ 2 files changed, 11 insertions(+), 12 deletions(-) Index: linux-2.6/mm/allocpercpu.c =================================================================== --- linux-2.6.orig/mm/allocpercpu.c 2007-10-30 21:24:01.000000000 -0700 +++ linux-2.6/mm/allocpercpu.c 2007-10-30 21:29:04.000000000 -0700 @@ -17,12 +17,13 @@ static DEFINE_SPINLOCK(cpu_area_lock); static u8 cpu_alloc_map[MAXIMUM_UNITS_PER_CPU] = { 1, }; -DEFINE_PER_CPU(per_cpu_unit, cpu_area)[MAXIMUM_UNITS_PER_CPU]; -EXPORT_PER_CPU_SYMBOL(cpu_area); +static DEFINE_PER_CPU(int, cpu_area)[MAXIMUM_UNITS_PER_CPU]; + +#define CPU_DATA_OFFSET ((unsigned long)&per_cpu__cpu_area) static inline int size_to_units(unsigned long size) { - return (size + sizeof(per_cpu_unit) - 1) / sizeof(per_cpu_unit); + return (size + sizeof(int) - 1) / sizeof(int); } static inline void set_map(int start, int length) @@ -69,10 +70,10 @@ static inline void *cpu_alloc(unsigned l } while (1); set_map(start, units); - __count_vm_events(ALLOC_PERCPU, units * sizeof(per_cpu_unit)); + __count_vm_events(ALLOC_PERCPU, units * sizeof(int)); spin_unlock(&cpu_area_lock); // printk("cpu_alloc(%ld) = %ld free=%ld\n", size, start, free); - return (void *)start; + return (void *)(start * sizeof(int) + CPU_DATA_OFFSET); } static inline void cpu_free(void *pcpu) @@ -80,12 +81,14 @@ 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(int); BUG_ON(cpu_alloc_map[start] == FREE || start >= MAXIMUM_UNITS_PER_CPU); spin_lock(&cpu_area_lock); units = clear_map(start); - __count_vm_events(ALLOC_PERCPU, -units * sizeof(per_cpu_unit)); + __count_vm_events(ALLOC_PERCPU, -units * sizeof(int)); spin_unlock(&cpu_area_lock); // printk("cpu_free(%ld) free=%d\n", start, units); } Index: linux-2.6/include/linux/percpu.h =================================================================== --- linux-2.6.orig/include/linux/percpu.h 2007-10-30 21:23:44.000000000 -0700 +++ linux-2.6/include/linux/percpu.h 2007-10-30 21:26:38.000000000 -0700 @@ -33,10 +33,6 @@ #ifdef CONFIG_SMP -typedef unsigned long long per_cpu_unit; - -DECLARE_PER_CPU(per_cpu_unit, cpu_area)[]; - #define __percpu_disguise(pdata) (struct percpu_data *)~(unsigned long)(pdata) /* * Use this to get to a cpu's version of the per-cpu object dynamically @@ -45,8 +41,8 @@ DECLARE_PER_CPU(per_cpu_unit, cpu_area)[ */ #define percpu_ptr(ptr, cpu) \ ({ \ - void *p = __percpu_disguise(ptr); \ - void *q = per_cpu(cpu_area, cpu) + (unsigned long)p; \ + void *p = __percpu_disguise(ptr); \ + void *q = p + per_cpu_offset(cpu); \ (__typeof__(ptr))(q); \ })