--- include/asm-x86/current_64.h | 2 include/asm-x86/pda.h | 81 +++------------------------------------ include/asm-x86/percpu.h | 9 ++-- include/asm-x86/thread_info_64.h | 2 4 files changed, 15 insertions(+), 79 deletions(-) Index: linux-2.6/include/asm-x86/pda.h =================================================================== --- linux-2.6.orig/include/asm-x86/pda.h 2007-11-24 23:31:37.433100882 -0800 +++ linux-2.6/include/asm-x86/pda.h 2007-11-24 23:45:49.213350568 -0800 @@ -42,85 +42,18 @@ extern struct x8664_pda *_cpu_pda[]; #define cpu_pda(i) (_cpu_pda[i]) -/* - * There is no fast way to get the base address of the PDA, all the accesses - * have to mention %fs/%gs. So it needs to be done this Torvaldian way. - */ -extern void __bad_pda_field(void) __attribute__((noreturn)); - -/* - * proxy_pda doesn't actually exist, but tell gcc it is accessed for - * all PDA accesses so it gets read/write dependencies right. - */ -extern struct x8664_pda _proxy_pda; - -#define pda_offset(field) offsetof(struct x8664_pda, field) - -#define pda_to_op(op,field,val) do { \ - typedef typeof(_proxy_pda.field) T__; \ - if (0) { T__ tmp__; tmp__ = (val); } /* type checking */ \ - switch (sizeof(_proxy_pda.field)) { \ - case 2: \ - asm(op "w %1,%%gs:%c2" : \ - "+m" (_proxy_pda.field) : \ - "ri" ((T__)val), \ - "i"(pda_offset(field))); \ - break; \ - case 4: \ - asm(op "l %1,%%gs:%c2" : \ - "+m" (_proxy_pda.field) : \ - "ri" ((T__)val), \ - "i" (pda_offset(field))); \ - break; \ - case 8: \ - asm(op "q %1,%%gs:%c2": \ - "+m" (_proxy_pda.field) : \ - "ri" ((T__)val), \ - "i"(pda_offset(field))); \ - break; \ - default: \ - __bad_pda_field(); \ - } \ - } while (0) - -#define pda_from_op(op,field) ({ \ - typeof(_proxy_pda.field) ret__; \ - switch (sizeof(_proxy_pda.field)) { \ - case 2: \ - asm(op "w %%gs:%c1,%0" : \ - "=r" (ret__) : \ - "i" (pda_offset(field)), \ - "m" (_proxy_pda.field)); \ - break; \ - case 4: \ - asm(op "l %%gs:%c1,%0": \ - "=r" (ret__): \ - "i" (pda_offset(field)), \ - "m" (_proxy_pda.field)); \ - break; \ - case 8: \ - asm(op "q %%gs:%c1,%0": \ - "=r" (ret__) : \ - "i" (pda_offset(field)), \ - "m" (_proxy_pda.field)); \ - break; \ - default: \ - __bad_pda_field(); \ - } \ - ret__; }) - -#define read_pda(field) pda_from_op("mov",field) -#define write_pda(field,val) pda_to_op("mov",field,val) -#define add_pda(field,val) pda_to_op("add",field,val) -#define sub_pda(field,val) pda_to_op("sub",field,val) -#define or_pda(field,val) pda_to_op("or",field,val) +#define read_pda(field) x86_read_percpu(pda.field) +#define write_pda(field,val) x86_write_percpu(pda.field,val) +#define add_pda(field,val) x86_add_percpu(pda.field,val) +#define sub_pda(field,val) x86_sub_percpu(pda.field,val) +#define or_pda(field,val) x86_or_percpu(pda.field,val) /* This is not atomic against other CPUs -- CPU preemption needs to be off */ #define test_and_clear_bit_pda(bit,field) ({ \ int old__; \ asm volatile("btr %2,%%gs:%c3\n\tsbbl %0,%0" \ - : "=r" (old__), "+m" (_proxy_pda.field) \ - : "dIr" (bit), "i" (pda_offset(field)) : "memory"); \ + : "=r" (old__), "+m" (&per_cpu__pda.field) \ + : "dIr" (bit), "i" (&per_cpu__pda.field)) : "memory"); \ old__; \ }) Index: linux-2.6/include/asm-x86/current_64.h =================================================================== --- linux-2.6.orig/include/asm-x86/current_64.h 2007-11-24 23:39:02.180351232 -0800 +++ linux-2.6/include/asm-x86/current_64.h 2007-11-24 23:39:13.268350807 -0800 @@ -4,7 +4,7 @@ #if !defined(__ASSEMBLY__) struct task_struct; -#include +#include static inline struct task_struct *get_current(void) { Index: linux-2.6/include/asm-x86/percpu.h =================================================================== --- linux-2.6.orig/include/asm-x86/percpu.h 2007-11-24 23:36:38.313350988 -0800 +++ linux-2.6/include/asm-x86/percpu.h 2007-11-24 23:43:03.115840885 -0800 @@ -11,6 +11,7 @@ #ifdef CONFIG_SMP #include +#ifndef __ASSEMBLY__ #define __per_cpu_offset(cpu) (cpu_pda(cpu)->data_offset) #define __my_cpu_offset read_pda(data_offset) @@ -23,7 +24,7 @@ #include DECLARE_PER_CPU(struct x8664_pda, pda); - +#endif #else /* CONFIG_X86_64 */ #ifdef __ASSEMBLY__ @@ -77,12 +78,14 @@ DECLARE_PER_CPU(struct x8664_pda, pda); #define __percpu_seg "" #endif /* SMP */ - #include +#endif /* ASSEMBLY */ +#endif /* !CONFIG_X86_64 */ +#ifndef __ASSEMBLY__ /* We can use this directly for local CPU (faster). */ DECLARE_PER_CPU(unsigned long, this_cpu_off); -#endif + /* For arch-specific code, we can use direct single-insn ops (they * don't give an lvalue though). */ Index: linux-2.6/include/asm-x86/thread_info_64.h =================================================================== --- linux-2.6.orig/include/asm-x86/thread_info_64.h 2007-11-24 23:39:42.944350541 -0800 +++ linux-2.6/include/asm-x86/thread_info_64.h 2007-11-24 23:39:49.808600549 -0800 @@ -11,7 +11,7 @@ #include #include -#include +#include /* * low level task data that entry.S needs immediate access to