Skip to content

Commit e76b027

Browse files
amlutoKAGA-KOKO
authored andcommitted
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>
1 parent a92f101 commit e76b027

File tree

6 files changed

+19
-43
lines changed

6 files changed

+19
-43
lines changed

arch/x86/include/asm/vgtod.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,23 @@ static inline void gtod_write_end(struct vsyscall_gtod_data *s)
7070
++s->seq;
7171
}
7272

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+
7392
#endif /* _ASM_X86_VGTOD_H */

arch/x86/include/asm/vsyscall.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,6 @@
44
#include <linux/seqlock.h>
55
#include <uapi/asm/vsyscall.h>
66

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-
167
extern void map_vsyscall(void);
178

189
/*
@@ -21,24 +12,4 @@ extern void map_vsyscall(void);
2112
*/
2213
extern bool emulate_vsyscall(struct pt_regs *regs, unsigned long address);
2314

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-
4415
#endif /* _ASM_X86_VSYSCALL_H */

arch/x86/include/asm/vvar.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ extern char __vvar_page;
4444

4545
/* DECLARE_VVAR(offset, type, name) */
4646

47-
DECLARE_VVAR(16, int, vgetcpu_mode)
4847
DECLARE_VVAR(128, struct vsyscall_gtod_data, vsyscall_gtod_data)
4948

5049
#undef DECLARE_VVAR

arch/x86/kernel/cpu/common.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -956,14 +956,6 @@ static void identify_cpu(struct cpuinfo_x86 *c)
956956
}
957957

958958
#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-
967959
#ifdef CONFIG_IA32_EMULATION
968960
/* May not be __init: called during resume */
969961
static void syscall32_cpu_init(void)
@@ -1006,8 +998,6 @@ void __init identify_boot_cpu(void)
1006998
#ifdef CONFIG_X86_32
1007999
sysenter_setup();
10081000
enable_sep_cpu();
1009-
#else
1010-
vgetcpu_set_mode();
10111001
#endif
10121002
cpu_detect_tlb(&boot_cpu_data);
10131003
}

arch/x86/kernel/vsyscall_64.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252
#define CREATE_TRACE_POINTS
5353
#include "vsyscall_trace.h"
5454

55-
DEFINE_VVAR(int, vgetcpu_mode);
56-
5755
static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
5856

5957
static int __init vsyscall_setup(char *str)

arch/x86/vdso/vgetcpu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <linux/kernel.h>
99
#include <linux/getcpu.h>
1010
#include <linux/time.h>
11-
#include <asm/vsyscall.h>
1211
#include <asm/vgtod.h>
1312

1413
notrace long

0 commit comments

Comments
 (0)