Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e76b027e authored by Andy Lutomirski's avatar Andy Lutomirski Committed by Thomas Gleixner
Browse files

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: default avatarAndy 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: default avatarThomas Gleixner <tglx@linutronix.de>
parent a92f101b
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -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 */
+0 −29
Original line number Diff line number Diff line
@@ -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 */
+0 −1
Original line number Diff line number Diff line
@@ -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
+0 −10
Original line number Diff line number Diff line
@@ -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);
}
+0 −2
Original line number Diff line number Diff line
@@ -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)
Loading