diff options
author | Andi Kleen <ak@suse.de> | 2007-05-02 13:27:21 -0400 |
---|---|---|
committer | Andi Kleen <andi@basil.nowhere.org> | 2007-05-02 13:27:21 -0400 |
commit | c5bcb5635a03da3158f121ae20ccbbf72b4fc62a (patch) | |
tree | a69fff3138ad14a7949d979f2d2e5893c5cb77de /include/asm-i386 | |
parent | 9bccb23dc5fc2d268ab676e2d4212d29e230fd86 (diff) |
[PATCH] x86: Use RDTSCP for synchronous get_cycles if possible
RDTSCP is already synchronous and doesn't need an explicit CPUID.
This is a little faster and more importantly avoids VMEXITs on Hypervisors.
Original patch from Joerg Roedel, but reworked by AK
Also includes miscompilation fix by Eric Biederman
Cc: "Joerg Roedel" <joerg.roedel@amd.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Diffstat (limited to 'include/asm-i386')
-rw-r--r-- | include/asm-i386/tsc.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/asm-i386/tsc.h b/include/asm-i386/tsc.h index 0181f9df7539..3f3c1fa000b4 100644 --- a/include/asm-i386/tsc.h +++ b/include/asm-i386/tsc.h | |||
@@ -38,6 +38,15 @@ static __always_inline cycles_t get_cycles_sync(void) | |||
38 | unsigned eax; | 38 | unsigned eax; |
39 | 39 | ||
40 | /* | 40 | /* |
41 | * Use RDTSCP if possible; it is guaranteed to be synchronous | ||
42 | * and doesn't cause a VMEXIT on Hypervisors | ||
43 | */ | ||
44 | alternative_io(ASM_NOP3, ".byte 0x0f,0x01,0xf9", X86_FEATURE_RDTSCP, | ||
45 | "=A" (ret), "0" (0ULL) : "ecx", "memory"); | ||
46 | if (ret) | ||
47 | return ret; | ||
48 | |||
49 | /* | ||
41 | * Don't do an additional sync on CPUs where we know | 50 | * Don't do an additional sync on CPUs where we know |
42 | * RDTSC is already synchronous: | 51 | * RDTSC is already synchronous: |
43 | */ | 52 | */ |