]> err.no Git - linux-2.6/commitdiff
[PATCH] i386: Implement "current" with the PDA
authorJeremy Fitzhardinge <jeremy@goop.org>
Thu, 7 Dec 2006 01:14:03 +0000 (02:14 +0100)
committerAndi Kleen <andi@basil.nowhere.org>
Thu, 7 Dec 2006 01:14:03 +0000 (02:14 +0100)
Use the pcurrent field in the PDA to implement the "current" macro.  This ends
up compiling down to a single instruction to get the current task.

Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Chuck Ebbert <76306.1226@compuserve.com>
Cc: Zachary Amsden <zach@vmware.com>
Cc: Jan Beulich <jbeulich@novell.com>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
arch/i386/kernel/asm-offsets.c
arch/i386/kernel/cpu/common.c
arch/i386/kernel/process.c
include/asm-i386/current.h
include/asm-i386/pda.h

index 85f1b038e9c3aa07f6998541867d4135d302b0ef..0666eb0ed7bc2d7f580b0b50348d60a52e50d803 100644 (file)
@@ -15,6 +15,7 @@
 #include <asm/processor.h>
 #include <asm/thread_info.h>
 #include <asm/elf.h>
+#include <asm/pda.h>
 
 #define DEFINE(sym, val) \
         asm volatile("\n->" #sym " %0 " #val : : "i" (val))
@@ -99,4 +100,5 @@ void foo(void)
 
        BLANK();
        OFFSET(PDA_cpu, i386_pda, cpu_number);
+       OFFSET(PDA_pcurrent, i386_pda, pcurrent);
 }
index e476202b887fa7fc59d67804e4ccc845458b6c3e..6958ae5e2fa5e3e931125bb0c9d09486e5acd95f 100644 (file)
@@ -651,6 +651,7 @@ __cpuinit int alloc_gdt(int cpu)
 struct i386_pda boot_pda = {
        ._pda = &boot_pda,
        .cpu_number = 0,
+       .pcurrent = &init_task,
 };
 
 static inline void set_kernel_gs(void)
@@ -696,6 +697,7 @@ __cpuinit int init_gdt(int cpu, struct task_struct *idle)
        memset(pda, 0, sizeof(*pda));
        pda->_pda = pda;
        pda->cpu_number = cpu;
+       pda->pcurrent = idle;
 
        return 1;
 }
index dc427254517981e98e91929956db3685e4e37f54..8749b10d38058d8e6716d904fab51d95f747e662 100644 (file)
@@ -684,6 +684,7 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas
        if (unlikely(prev->fs | next->fs))
                loadsegment(fs, next->fs);
 
+       write_pda(pcurrent, next_p);
 
        /*
         * Restore IOPL if needed.
index 3cbbecd790161babf7fa1df4a7c549d4c2107276..5252ee0f6d7a9ce0fd4825ce4381051334b55aea 100644 (file)
@@ -1,13 +1,14 @@
 #ifndef _I386_CURRENT_H
 #define _I386_CURRENT_H
 
-#include <linux/thread_info.h>
+#include <asm/pda.h>
+#include <linux/compiler.h>
 
 struct task_struct;
 
-static __always_inline struct task_struct * get_current(void)
+static __always_inline struct task_struct *get_current(void)
 {
-       return current_thread_info()->task;
+       return read_pda(pcurrent);
 }
  
 #define current get_current()
index f90fde22566db00f2f18791cd0a515624f8d99a1..08a35c478af231c71022c17528010335631a6f34 100644 (file)
@@ -7,12 +7,14 @@
 #define _I386_PDA_H
 
 #include <linux/stddef.h>
+#include <linux/types.h>
 
 struct i386_pda
 {
        struct i386_pda *_pda;          /* pointer to self */
 
        int cpu_number;
+       struct task_struct *pcurrent;   /* current process */
 };
 
 extern struct i386_pda *_cpu_pda[];