aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/include/asm/current.h24
-rw-r--r--arch/x86/include/asm/pda.h4
-rw-r--r--arch/x86/include/asm/system.h4
-rw-r--r--arch/x86/kernel/asm-offsets_64.c1
-rw-r--r--arch/x86/kernel/cpu/common.c5
-rw-r--r--arch/x86/kernel/dumpstack_64.c2
-rw-r--r--arch/x86/kernel/process_64.c5
-rw-r--r--arch/x86/kernel/smpboot.c3
-rw-r--r--arch/x86/xen/smp.c3
9 files changed, 15 insertions, 36 deletions
diff --git a/arch/x86/include/asm/current.h b/arch/x86/include/asm/current.h
index 0728480f5c56..c68c361697e1 100644
--- a/arch/x86/include/asm/current.h
+++ b/arch/x86/include/asm/current.h
@@ -1,39 +1,21 @@
1#ifndef _ASM_X86_CURRENT_H 1#ifndef _ASM_X86_CURRENT_H
2#define _ASM_X86_CURRENT_H 2#define _ASM_X86_CURRENT_H
3 3
4#ifdef CONFIG_X86_32
5#include <linux/compiler.h> 4#include <linux/compiler.h>
6#include <asm/percpu.h> 5#include <asm/percpu.h>
7 6
7#ifndef __ASSEMBLY__
8struct task_struct; 8struct task_struct;
9 9
10DECLARE_PER_CPU(struct task_struct *, current_task); 10DECLARE_PER_CPU(struct task_struct *, current_task);
11static __always_inline struct task_struct *get_current(void)
12{
13 return percpu_read(current_task);
14}
15
16#else /* X86_32 */
17
18#ifndef __ASSEMBLY__
19#include <asm/pda.h>
20
21struct task_struct;
22 11
23static __always_inline struct task_struct *get_current(void) 12static __always_inline struct task_struct *get_current(void)
24{ 13{
25 return read_pda(pcurrent); 14 return percpu_read(current_task);
26} 15}
27 16
28#else /* __ASSEMBLY__ */ 17#define current get_current()
29
30#include <asm/asm-offsets.h>
31#define GET_CURRENT(reg) movq %gs:(pda_pcurrent),reg
32 18
33#endif /* __ASSEMBLY__ */ 19#endif /* __ASSEMBLY__ */
34 20
35#endif /* X86_32 */
36
37#define current get_current()
38
39#endif /* _ASM_X86_CURRENT_H */ 21#endif /* _ASM_X86_CURRENT_H */
diff --git a/arch/x86/include/asm/pda.h b/arch/x86/include/asm/pda.h
index 668d5a5b6f70..7209302d9227 100644
--- a/arch/x86/include/asm/pda.h
+++ b/arch/x86/include/asm/pda.h
@@ -11,8 +11,8 @@
11 11
12/* Per processor datastructure. %gs points to it while the kernel runs */ 12/* Per processor datastructure. %gs points to it while the kernel runs */
13struct x8664_pda { 13struct x8664_pda {
14 struct task_struct *pcurrent; /* 0 Current process */ 14 unsigned long unused1;
15 unsigned long dummy; 15 unsigned long unused2;
16 unsigned long kernelstack; /* 16 top of kernel stack for current */ 16 unsigned long kernelstack; /* 16 top of kernel stack for current */
17 unsigned long oldrsp; /* 24 user rsp for system call */ 17 unsigned long oldrsp; /* 24 user rsp for system call */
18 int irqcount; /* 32 Irq nesting counter. Starts -1 */ 18 int irqcount; /* 32 Irq nesting counter. Starts -1 */
diff --git a/arch/x86/include/asm/system.h b/arch/x86/include/asm/system.h
index 8e626ea33a1a..4399aac680e9 100644
--- a/arch/x86/include/asm/system.h
+++ b/arch/x86/include/asm/system.h
@@ -94,7 +94,7 @@ do { \
94 "call __switch_to\n\t" \ 94 "call __switch_to\n\t" \
95 ".globl thread_return\n" \ 95 ".globl thread_return\n" \
96 "thread_return:\n\t" \ 96 "thread_return:\n\t" \
97 "movq %%gs:%P[pda_pcurrent],%%rsi\n\t" \ 97 "movq "__percpu_seg_str"%P[current_task],%%rsi\n\t" \
98 "movq %P[thread_info](%%rsi),%%r8\n\t" \ 98 "movq %P[thread_info](%%rsi),%%r8\n\t" \
99 LOCK_PREFIX "btr %[tif_fork],%P[ti_flags](%%r8)\n\t" \ 99 LOCK_PREFIX "btr %[tif_fork],%P[ti_flags](%%r8)\n\t" \
100 "movq %%rax,%%rdi\n\t" \ 100 "movq %%rax,%%rdi\n\t" \
@@ -106,7 +106,7 @@ do { \
106 [ti_flags] "i" (offsetof(struct thread_info, flags)), \ 106 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
107 [tif_fork] "i" (TIF_FORK), \ 107 [tif_fork] "i" (TIF_FORK), \
108 [thread_info] "i" (offsetof(struct task_struct, stack)), \ 108 [thread_info] "i" (offsetof(struct task_struct, stack)), \
109 [pda_pcurrent] "i" (offsetof(struct x8664_pda, pcurrent)) \ 109 [current_task] "m" (per_cpu_var(current_task)) \
110 : "memory", "cc" __EXTRA_CLOBBER) 110 : "memory", "cc" __EXTRA_CLOBBER)
111#endif 111#endif
112 112
diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
index cae6697c0991..4f7a210e1e58 100644
--- a/arch/x86/kernel/asm-offsets_64.c
+++ b/arch/x86/kernel/asm-offsets_64.c
@@ -51,7 +51,6 @@ int main(void)
51#define ENTRY(entry) DEFINE(pda_ ## entry, offsetof(struct x8664_pda, entry)) 51#define ENTRY(entry) DEFINE(pda_ ## entry, offsetof(struct x8664_pda, entry))
52 ENTRY(kernelstack); 52 ENTRY(kernelstack);
53 ENTRY(oldrsp); 53 ENTRY(oldrsp);
54 ENTRY(pcurrent);
55 ENTRY(irqcount); 54 ENTRY(irqcount);
56 DEFINE(pda_size, sizeof(struct x8664_pda)); 55 DEFINE(pda_size, sizeof(struct x8664_pda));
57 BLANK(); 56 BLANK();
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 4221e920886d..b50e38d16888 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -903,10 +903,7 @@ void __cpuinit pda_init(int cpu)
903 pda->kernelstack = (unsigned long)stack_thread_info() - 903 pda->kernelstack = (unsigned long)stack_thread_info() -
904 PDA_STACKOFFSET + THREAD_SIZE; 904 PDA_STACKOFFSET + THREAD_SIZE;
905 905
906 if (cpu == 0) { 906 if (cpu != 0) {
907 /* others are initialized in smpboot.c */
908 pda->pcurrent = &init_task;
909 } else {
910 if (pda->nodenumber == 0 && cpu_to_node(cpu) != NUMA_NO_NODE) 907 if (pda->nodenumber == 0 && cpu_to_node(cpu) != NUMA_NO_NODE)
911 pda->nodenumber = cpu_to_node(cpu); 908 pda->nodenumber = cpu_to_node(cpu);
912 } 909 }
diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
index 28e26a4315df..d35db5993fd6 100644
--- a/arch/x86/kernel/dumpstack_64.c
+++ b/arch/x86/kernel/dumpstack_64.c
@@ -242,7 +242,7 @@ void show_registers(struct pt_regs *regs)
242 int i; 242 int i;
243 unsigned long sp; 243 unsigned long sp;
244 const int cpu = smp_processor_id(); 244 const int cpu = smp_processor_id();
245 struct task_struct *cur = cpu_pda(cpu)->pcurrent; 245 struct task_struct *cur = current;
246 246
247 sp = regs->sp; 247 sp = regs->sp;
248 printk("CPU %d ", cpu); 248 printk("CPU %d ", cpu);
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 416fb9282f4f..e00c31a4b3c0 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -57,6 +57,9 @@
57 57
58asmlinkage extern void ret_from_fork(void); 58asmlinkage extern void ret_from_fork(void);
59 59
60DEFINE_PER_CPU(struct task_struct *, current_task) = &init_task;
61EXPORT_PER_CPU_SYMBOL(current_task);
62
60unsigned long kernel_thread_flags = CLONE_VM | CLONE_UNTRACED; 63unsigned long kernel_thread_flags = CLONE_VM | CLONE_UNTRACED;
61 64
62static ATOMIC_NOTIFIER_HEAD(idle_notifier); 65static ATOMIC_NOTIFIER_HEAD(idle_notifier);
@@ -615,7 +618,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
615 */ 618 */
616 prev->usersp = read_pda(oldrsp); 619 prev->usersp = read_pda(oldrsp);
617 write_pda(oldrsp, next->usersp); 620 write_pda(oldrsp, next->usersp);
618 write_pda(pcurrent, next_p); 621 percpu_write(current_task, next_p);
619 622
620 write_pda(kernelstack, 623 write_pda(kernelstack,
621 (unsigned long)task_stack_page(next_p) + 624 (unsigned long)task_stack_page(next_p) +
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 2f0e0f1090f6..5854be0fb804 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -790,13 +790,12 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu)
790 790
791 set_idle_for_cpu(cpu, c_idle.idle); 791 set_idle_for_cpu(cpu, c_idle.idle);
792do_rest: 792do_rest:
793#ifdef CONFIG_X86_32
794 per_cpu(current_task, cpu) = c_idle.idle; 793 per_cpu(current_task, cpu) = c_idle.idle;
794#ifdef CONFIG_X86_32
795 init_gdt(cpu); 795 init_gdt(cpu);
796 /* Stack for startup_32 can be just as for start_secondary onwards */ 796 /* Stack for startup_32 can be just as for start_secondary onwards */
797 irq_ctx_init(cpu); 797 irq_ctx_init(cpu);
798#else 798#else
799 cpu_pda(cpu)->pcurrent = c_idle.idle;
800 clear_tsk_thread_flag(c_idle.idle, TIF_FORK); 799 clear_tsk_thread_flag(c_idle.idle, TIF_FORK);
801 initial_gs = per_cpu_offset(cpu); 800 initial_gs = per_cpu_offset(cpu);
802#endif 801#endif
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
index 9ff3b0999cfb..72c2eb9b64cd 100644
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -279,12 +279,11 @@ static int __cpuinit xen_cpu_up(unsigned int cpu)
279 struct task_struct *idle = idle_task(cpu); 279 struct task_struct *idle = idle_task(cpu);
280 int rc; 280 int rc;
281 281
282 per_cpu(current_task, cpu) = idle;
282#ifdef CONFIG_X86_32 283#ifdef CONFIG_X86_32
283 init_gdt(cpu); 284 init_gdt(cpu);
284 per_cpu(current_task, cpu) = idle;
285 irq_ctx_init(cpu); 285 irq_ctx_init(cpu);
286#else 286#else
287 cpu_pda(cpu)->pcurrent = idle;
288 clear_tsk_thread_flag(idle, TIF_FORK); 287 clear_tsk_thread_flag(idle, TIF_FORK);
289#endif 288#endif
290 xen_setup_timer(cpu); 289 xen_setup_timer(cpu);