diff options
author | Andy Lutomirski <luto@amacapital.net> | 2014-10-30 17:58:01 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2014-11-03 07:41:53 -0500 |
commit | e76b027e6408f5570dc940b731ec9ae870c6188a (patch) | |
tree | d94287f98ee13c7e2fedd4890499f178079ce6ab /arch/x86 | |
parent | a92f101bc99d17b75021cf29f18cc57f39a37d1f (diff) |
x86,vdso: Use LSL unconditionally for vgetcpu
LSL is faster than RDTSCP and works everywhere; there's no need to
switch between them depending on CPU.
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Cc: Andi Kleen <andi@firstfloor.org>
Link: http://lkml.kernel.org/r/72f73d5ec4514e02bba345b9759177ef03742efb.1414706021.git.luto@amacapital.net
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/include/asm/vgtod.h | 19 | ||||
-rw-r--r-- | arch/x86/include/asm/vsyscall.h | 29 | ||||
-rw-r--r-- | arch/x86/include/asm/vvar.h | 1 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/common.c | 10 | ||||
-rw-r--r-- | arch/x86/kernel/vsyscall_64.c | 2 | ||||
-rw-r--r-- | arch/x86/vdso/vgetcpu.c | 1 |
6 files changed, 19 insertions, 43 deletions
diff --git a/arch/x86/include/asm/vgtod.h b/arch/x86/include/asm/vgtod.h index 3c3366c2e37f..e7e9682a33e9 100644 --- a/arch/x86/include/asm/vgtod.h +++ b/arch/x86/include/asm/vgtod.h | |||
@@ -70,4 +70,23 @@ static inline void gtod_write_end(struct vsyscall_gtod_data *s) | |||
70 | ++s->seq; | 70 | ++s->seq; |
71 | } | 71 | } |
72 | 72 | ||
73 | #ifdef CONFIG_X86_64 | ||
74 | |||
75 | #define VGETCPU_CPU_MASK 0xfff | ||
76 | |||
77 | static inline unsigned int __getcpu(void) | ||
78 | { | ||
79 | unsigned int p; | ||
80 | |||
81 | /* | ||
82 | * Load per CPU data from GDT. LSL is faster than RDTSCP and | ||
83 | * works on all CPUs. | ||
84 | */ | ||
85 | asm("lsl %1,%0" : "=r" (p) : "r" (__PER_CPU_SEG)); | ||
86 | |||
87 | return p; | ||
88 | } | ||
89 | |||
90 | #endif /* CONFIG_X86_64 */ | ||
91 | |||
73 | #endif /* _ASM_X86_VGTOD_H */ | 92 | #endif /* _ASM_X86_VGTOD_H */ |
diff --git a/arch/x86/include/asm/vsyscall.h b/arch/x86/include/asm/vsyscall.h index 2a46ca720afc..34f7d8857542 100644 --- a/arch/x86/include/asm/vsyscall.h +++ b/arch/x86/include/asm/vsyscall.h | |||
@@ -4,15 +4,6 @@ | |||
4 | #include <linux/seqlock.h> | 4 | #include <linux/seqlock.h> |
5 | #include <uapi/asm/vsyscall.h> | 5 | #include <uapi/asm/vsyscall.h> |
6 | 6 | ||
7 | #define VGETCPU_RDTSCP 1 | ||
8 | #define VGETCPU_LSL 2 | ||
9 | |||
10 | /* kernel space (writeable) */ | ||
11 | extern int vgetcpu_mode; | ||
12 | extern struct timezone sys_tz; | ||
13 | |||
14 | #include <asm/vvar.h> | ||
15 | |||
16 | extern void map_vsyscall(void); | 7 | extern void map_vsyscall(void); |
17 | 8 | ||
18 | /* | 9 | /* |
@@ -21,24 +12,4 @@ extern void map_vsyscall(void); | |||
21 | */ | 12 | */ |
22 | extern bool emulate_vsyscall(struct pt_regs *regs, unsigned long address); | 13 | extern bool emulate_vsyscall(struct pt_regs *regs, unsigned long address); |
23 | 14 | ||
24 | #ifdef CONFIG_X86_64 | ||
25 | |||
26 | #define VGETCPU_CPU_MASK 0xfff | ||
27 | |||
28 | static inline unsigned int __getcpu(void) | ||
29 | { | ||
30 | unsigned int p; | ||
31 | |||
32 | if (VVAR(vgetcpu_mode) == VGETCPU_RDTSCP) { | ||
33 | /* Load per CPU data from RDTSCP */ | ||
34 | native_read_tscp(&p); | ||
35 | } else { | ||
36 | /* Load per CPU data from GDT */ | ||
37 | asm("lsl %1,%0" : "=r" (p) : "r" (__PER_CPU_SEG)); | ||
38 | } | ||
39 | |||
40 | return p; | ||
41 | } | ||
42 | #endif /* CONFIG_X86_64 */ | ||
43 | |||
44 | #endif /* _ASM_X86_VSYSCALL_H */ | 15 | #endif /* _ASM_X86_VSYSCALL_H */ |
diff --git a/arch/x86/include/asm/vvar.h b/arch/x86/include/asm/vvar.h index 5f6d40734a3b..3f32dfc2ab73 100644 --- a/arch/x86/include/asm/vvar.h +++ b/arch/x86/include/asm/vvar.h | |||
@@ -44,7 +44,6 @@ extern char __vvar_page; | |||
44 | 44 | ||
45 | /* DECLARE_VVAR(offset, type, name) */ | 45 | /* DECLARE_VVAR(offset, type, name) */ |
46 | 46 | ||
47 | DECLARE_VVAR(16, int, vgetcpu_mode) | ||
48 | DECLARE_VVAR(128, struct vsyscall_gtod_data, vsyscall_gtod_data) | 47 | DECLARE_VVAR(128, struct vsyscall_gtod_data, vsyscall_gtod_data) |
49 | 48 | ||
50 | #undef DECLARE_VVAR | 49 | #undef DECLARE_VVAR |
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 4b4f78c9ba19..175372b854be 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c | |||
@@ -956,14 +956,6 @@ static void identify_cpu(struct cpuinfo_x86 *c) | |||
956 | } | 956 | } |
957 | 957 | ||
958 | #ifdef CONFIG_X86_64 | 958 | #ifdef CONFIG_X86_64 |
959 | static void vgetcpu_set_mode(void) | ||
960 | { | ||
961 | if (cpu_has(&boot_cpu_data, X86_FEATURE_RDTSCP)) | ||
962 | vgetcpu_mode = VGETCPU_RDTSCP; | ||
963 | else | ||
964 | vgetcpu_mode = VGETCPU_LSL; | ||
965 | } | ||
966 | |||
967 | #ifdef CONFIG_IA32_EMULATION | 959 | #ifdef CONFIG_IA32_EMULATION |
968 | /* May not be __init: called during resume */ | 960 | /* May not be __init: called during resume */ |
969 | static void syscall32_cpu_init(void) | 961 | static void syscall32_cpu_init(void) |
@@ -1006,8 +998,6 @@ void __init identify_boot_cpu(void) | |||
1006 | #ifdef CONFIG_X86_32 | 998 | #ifdef CONFIG_X86_32 |
1007 | sysenter_setup(); | 999 | sysenter_setup(); |
1008 | enable_sep_cpu(); | 1000 | enable_sep_cpu(); |
1009 | #else | ||
1010 | vgetcpu_set_mode(); | ||
1011 | #endif | 1001 | #endif |
1012 | cpu_detect_tlb(&boot_cpu_data); | 1002 | cpu_detect_tlb(&boot_cpu_data); |
1013 | } | 1003 | } |
diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c index 2f9ef0c1d112..419e83b58436 100644 --- a/arch/x86/kernel/vsyscall_64.c +++ b/arch/x86/kernel/vsyscall_64.c | |||
@@ -52,8 +52,6 @@ | |||
52 | #define CREATE_TRACE_POINTS | 52 | #define CREATE_TRACE_POINTS |
53 | #include "vsyscall_trace.h" | 53 | #include "vsyscall_trace.h" |
54 | 54 | ||
55 | DEFINE_VVAR(int, vgetcpu_mode); | ||
56 | |||
57 | static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE; | 55 | static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE; |
58 | 56 | ||
59 | static int __init vsyscall_setup(char *str) | 57 | static int __init vsyscall_setup(char *str) |
diff --git a/arch/x86/vdso/vgetcpu.c b/arch/x86/vdso/vgetcpu.c index add1d98d2477..8ec3d1f4ce9a 100644 --- a/arch/x86/vdso/vgetcpu.c +++ b/arch/x86/vdso/vgetcpu.c | |||
@@ -8,7 +8,6 @@ | |||
8 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
9 | #include <linux/getcpu.h> | 9 | #include <linux/getcpu.h> |
10 | #include <linux/time.h> | 10 | #include <linux/time.h> |
11 | #include <asm/vsyscall.h> | ||
12 | #include <asm/vgtod.h> | 11 | #include <asm/vgtod.h> |
13 | 12 | ||
14 | notrace long | 13 | notrace long |