x86,vdso: Use LSL unconditionally for vgetcpu
authorAndy Lutomirski <luto@amacapital.net>
Thu, 30 Oct 2014 21:58:01 +0000 (14:58 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 3 Nov 2014 12:41:53 +0000 (13:41 +0100)
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>
arch/x86/include/asm/vgtod.h
arch/x86/include/asm/vsyscall.h
arch/x86/include/asm/vvar.h
arch/x86/kernel/cpu/common.c
arch/x86/kernel/vsyscall_64.c
arch/x86/vdso/vgetcpu.c

index 3c3366c2e37f5e52f1022a5ae401aea99c6425a9..e7e9682a33e90f350e0ce5f99c61480755614221 100644 (file)
@@ -70,4 +70,23 @@ static inline void gtod_write_end(struct vsyscall_gtod_data *s)
        ++s->seq;
 }
 
+#ifdef CONFIG_X86_64
+
+#define VGETCPU_CPU_MASK 0xfff
+
+static inline unsigned int __getcpu(void)
+{
+       unsigned int p;
+
+       /*
+        * Load per CPU data from GDT.  LSL is faster than RDTSCP and
+        * works on all CPUs.
+        */
+       asm("lsl %1,%0" : "=r" (p) : "r" (__PER_CPU_SEG));
+
+       return p;
+}
+
+#endif /* CONFIG_X86_64 */
+
 #endif /* _ASM_X86_VGTOD_H */
index 2a46ca720afca5fd6f5e5010698e8eea56748837..34f7d8857542c7653865fffb97f6ee00e38753bd 100644 (file)
@@ -4,15 +4,6 @@
 #include <linux/seqlock.h>
 #include <uapi/asm/vsyscall.h>
 
-#define VGETCPU_RDTSCP 1
-#define VGETCPU_LSL    2
-
-/* kernel space (writeable) */
-extern int vgetcpu_mode;
-extern struct timezone sys_tz;
-
-#include <asm/vvar.h>
-
 extern void map_vsyscall(void);
 
 /*
@@ -21,24 +12,4 @@ extern void map_vsyscall(void);
  */
 extern bool emulate_vsyscall(struct pt_regs *regs, unsigned long address);
 
-#ifdef CONFIG_X86_64
-
-#define VGETCPU_CPU_MASK 0xfff
-
-static inline unsigned int __getcpu(void)
-{
-       unsigned int p;
-
-       if (VVAR(vgetcpu_mode) == VGETCPU_RDTSCP) {
-               /* Load per CPU data from RDTSCP */
-               native_read_tscp(&p);
-       } else {
-               /* Load per CPU data from GDT */
-               asm("lsl %1,%0" : "=r" (p) : "r" (__PER_CPU_SEG));
-       }
-
-       return p;
-}
-#endif /* CONFIG_X86_64 */
-
 #endif /* _ASM_X86_VSYSCALL_H */
index 5f6d40734a3b75154747cb47b33a002d33c2df18..3f32dfc2ab7350b6130bcfca317932f431d6cb99 100644 (file)
@@ -44,7 +44,6 @@ extern char __vvar_page;
 
 /* DECLARE_VVAR(offset, type, name) */
 
-DECLARE_VVAR(16, int, vgetcpu_mode)
 DECLARE_VVAR(128, struct vsyscall_gtod_data, vsyscall_gtod_data)
 
 #undef DECLARE_VVAR
index 4b4f78c9ba1902ed87127738052135ed54071088..175372b854beb757fdded144220a871dcf87c7a8 100644 (file)
@@ -956,14 +956,6 @@ static void identify_cpu(struct cpuinfo_x86 *c)
 }
 
 #ifdef CONFIG_X86_64
-static void vgetcpu_set_mode(void)
-{
-       if (cpu_has(&boot_cpu_data, X86_FEATURE_RDTSCP))
-               vgetcpu_mode = VGETCPU_RDTSCP;
-       else
-               vgetcpu_mode = VGETCPU_LSL;
-}
-
 #ifdef CONFIG_IA32_EMULATION
 /* May not be __init: called during resume */
 static void syscall32_cpu_init(void)
@@ -1006,8 +998,6 @@ void __init identify_boot_cpu(void)
 #ifdef CONFIG_X86_32
        sysenter_setup();
        enable_sep_cpu();
-#else
-       vgetcpu_set_mode();
 #endif
        cpu_detect_tlb(&boot_cpu_data);
 }
index 2f9ef0c1d112649271fcb28b83fc0a39ede308df..419e83b58436451e51929f2d1fec154b2d9bad49 100644 (file)
@@ -52,8 +52,6 @@
 #define CREATE_TRACE_POINTS
 #include "vsyscall_trace.h"
 
-DEFINE_VVAR(int, vgetcpu_mode);
-
 static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
 
 static int __init vsyscall_setup(char *str)
index add1d98d2477a1c9ad2ef3ff47e187d255deff85..8ec3d1f4ce9a4d378d6042650177d4b32a9808e8 100644 (file)
@@ -8,7 +8,6 @@
 #include <linux/kernel.h>
 #include <linux/getcpu.h>
 #include <linux/time.h>
-#include <asm/vsyscall.h>
 #include <asm/vgtod.h>
 
 notrace long
This page took 0.055726 seconds and 5 git commands to generate.