Commit ec7fcaab authored by Jeremy Fitzhardinge's avatar Jeremy Fitzhardinge Committed by Andi Kleen

[PATCH] i386: Implement "current" with the PDA

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: default avatarJeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: default avatarAndi 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: default avatarAndrew Morton <akpm@osdl.org>
parent b2938f88
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/thread_info.h> #include <asm/thread_info.h>
#include <asm/elf.h> #include <asm/elf.h>
#include <asm/pda.h>
#define DEFINE(sym, val) \ #define DEFINE(sym, val) \
asm volatile("\n->" #sym " %0 " #val : : "i" (val)) asm volatile("\n->" #sym " %0 " #val : : "i" (val))
...@@ -99,4 +100,5 @@ void foo(void) ...@@ -99,4 +100,5 @@ void foo(void)
BLANK(); BLANK();
OFFSET(PDA_cpu, i386_pda, cpu_number); OFFSET(PDA_cpu, i386_pda, cpu_number);
OFFSET(PDA_pcurrent, i386_pda, pcurrent);
} }
...@@ -651,6 +651,7 @@ __cpuinit int alloc_gdt(int cpu) ...@@ -651,6 +651,7 @@ __cpuinit int alloc_gdt(int cpu)
struct i386_pda boot_pda = { struct i386_pda boot_pda = {
._pda = &boot_pda, ._pda = &boot_pda,
.cpu_number = 0, .cpu_number = 0,
.pcurrent = &init_task,
}; };
static inline void set_kernel_gs(void) static inline void set_kernel_gs(void)
...@@ -696,6 +697,7 @@ __cpuinit int init_gdt(int cpu, struct task_struct *idle) ...@@ -696,6 +697,7 @@ __cpuinit int init_gdt(int cpu, struct task_struct *idle)
memset(pda, 0, sizeof(*pda)); memset(pda, 0, sizeof(*pda));
pda->_pda = pda; pda->_pda = pda;
pda->cpu_number = cpu; pda->cpu_number = cpu;
pda->pcurrent = idle;
return 1; return 1;
} }
......
...@@ -684,6 +684,7 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas ...@@ -684,6 +684,7 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas
if (unlikely(prev->fs | next->fs)) if (unlikely(prev->fs | next->fs))
loadsegment(fs, next->fs); loadsegment(fs, next->fs);
write_pda(pcurrent, next_p);
/* /*
* Restore IOPL if needed. * Restore IOPL if needed.
......
#ifndef _I386_CURRENT_H #ifndef _I386_CURRENT_H
#define _I386_CURRENT_H #define _I386_CURRENT_H
#include <linux/thread_info.h> #include <asm/pda.h>
#include <linux/compiler.h>
struct task_struct; 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() #define current get_current()
......
...@@ -7,12 +7,14 @@ ...@@ -7,12 +7,14 @@
#define _I386_PDA_H #define _I386_PDA_H
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/types.h>
struct i386_pda struct i386_pda
{ {
struct i386_pda *_pda; /* pointer to self */ struct i386_pda *_pda; /* pointer to self */
int cpu_number; int cpu_number;
struct task_struct *pcurrent; /* current process */
}; };
extern struct i386_pda *_cpu_pda[]; extern struct i386_pda *_cpu_pda[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment