Replace all uses of __per_cpu_offset with CPU_PTR. This will avoid a lot
of lookups for per cpu offset calculations.

Keep per_cpu_offset() itself because lockdep uses it.

Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]>

---
 arch/x86/kernel/smpboot_64.c |    8 +++-----
 include/asm-x86/percpu_64.h  |   14 ++++++--------
 2 files changed, 9 insertions(+), 13 deletions(-)

Index: linux-2.6/include/asm-x86/percpu_64.h
===================================================================
--- linux-2.6.orig/include/asm-x86/percpu_64.h  2007-11-19 16:07:43.153640561 
-0800
+++ linux-2.6/include/asm-x86/percpu_64.h       2007-11-19 16:12:01.977139696 
-0800
@@ -11,10 +11,8 @@
 
 #include <asm/pda.h>
 
-#define __per_cpu_offset(cpu) (cpu_pda(cpu)->data_offset)
-#define __my_cpu_offset() read_pda(data_offset)
-
-#define per_cpu_offset(x) (__per_cpu_offset(x))
+/* Legacy: lockdep in the core kernel uses this */
+#define per_cpu_offset(cpu) CPU_OFFSET(cpu)
 
 /* Separate out the type, so (int[3], foo) works. */
 #define DEFINE_PER_CPU(type, name) \
@@ -32,20 +30,20 @@
 /* var is in discarded region: offset to particular copy we want */
 #define per_cpu(var, cpu) (*({                         \
        extern int simple_identifier_##var(void);       \
-       RELOC_HIDE(&per_cpu__##var, __per_cpu_offset(cpu)); }))
+       CPU_PTR(&per_cpu__##var, (cpu)); }))
 #define __get_cpu_var(var) (*({                                \
        extern int simple_identifier_##var(void);       \
-       RELOC_HIDE(&per_cpu__##var, __my_cpu_offset()); }))
+       THIS_CPU(&per_cpu__##var); }))
 #define __raw_get_cpu_var(var) (*({                    \
        extern int simple_identifier_##var(void);       \
-       RELOC_HIDE(&per_cpu__##var, __my_cpu_offset()); }))
+       __THIS_CPU(&per_cpu__##var); }))
 
 /* A macro to avoid #include hell... */
 #define percpu_modcopy(pcpudst, src, size)                     \
 do {                                                           \
        unsigned int __i;                                       \
        for_each_possible_cpu(__i)                              \
-               memcpy((pcpudst)+__per_cpu_offset(__i),         \
+               memcpy(CPU_PTR(pcpudst, __i),                   \
                       (src), (size));                          \
 } while (0)
 
Index: linux-2.6/arch/x86/kernel/smpboot_64.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/smpboot_64.c 2007-11-19 16:06:15.301390091 
-0800
+++ linux-2.6/arch/x86/kernel/smpboot_64.c      2007-11-19 16:10:23.998889835 
-0800
@@ -835,11 +835,9 @@ void __init smp_set_apicids(void)
 {
        int cpu;
 
-       for_each_cpu_mask(cpu, cpu_possible_map) {
-               if (per_cpu_offset(cpu))
-                       per_cpu(x86_cpu_to_apicid, cpu) =
-                                               x86_cpu_to_apicid_init[cpu];
-       }
+       for_each_cpu_mask(cpu, cpu_possible_map)
+               per_cpu(x86_cpu_to_apicid, cpu) =
+                                       x86_cpu_to_apicid_init[cpu];
 
        /* indicate the static array will be going away soon */
        x86_cpu_to_apicid_ptr = NULL;

-- 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to