diff mbox

[v3,02/18] x86/msr/kvm: Remove vget_cycles()

Message ID 20615df14ae2eb713ea7a5f5123c1dc4c7ca993d.1434501121.git.luto@kernel.org (mailing list archive)
State New, archived
Headers show

Commit Message

Andy Lutomirski June 17, 2015, 12:35 a.m. UTC
The only caller was kvm's read_tsc.  The only difference between
vget_cycles and native_read_tsc was that vget_cycles returned zero
instead of crashing on TSC-less systems.  KVM's already checks
vclock_mode before calling that function, so the extra check is
unnecessary.

(Off-topic, but the whole KVM clock host implementation is gross.
 IMO it should be rewritten.)

Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
 arch/x86/include/asm/tsc.h | 13 -------------
 arch/x86/kvm/x86.c         |  2 +-
 2 files changed, 1 insertion(+), 14 deletions(-)

Comments

Borislav Petkov June 17, 2015, 9:42 a.m. UTC | #1
On Tue, Jun 16, 2015 at 05:35:50PM -0700, Andy Lutomirski wrote:
> The only caller was kvm's read_tsc.  The only difference between
> vget_cycles and native_read_tsc was that vget_cycles returned zero
> instead of crashing on TSC-less systems.  KVM's already checks
> vclock_mode before calling that function, so the extra check is
> unnecessary.
> 
> (Off-topic, but the whole KVM clock host implementation is gross.
>  IMO it should be rewritten.)
> 
> Signed-off-by: Andy Lutomirski <luto@kernel.org>
> ---
>  arch/x86/include/asm/tsc.h | 13 -------------
>  arch/x86/kvm/x86.c         |  2 +-
>  2 files changed, 1 insertion(+), 14 deletions(-)

Acked-by: Borislav Petkov <bp@suse.de>
Paolo Bonzini June 17, 2015, 1:34 p.m. UTC | #2
On 17/06/2015 02:35, Andy Lutomirski wrote:
> The only caller was kvm's read_tsc.  The only difference between
> vget_cycles and native_read_tsc was that vget_cycles returned zero
> instead of crashing on TSC-less systems.  KVM's already checks
> vclock_mode before calling that function, so the extra check is
> unnecessary.

Or more simply, KVM (host-side) requires the TSC to exist.

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

> (Off-topic, but the whole KVM clock host implementation is gross.
>  IMO it should be rewritten.)
> 
> Signed-off-by: Andy Lutomirski <luto@kernel.org>
> ---
>  arch/x86/include/asm/tsc.h | 13 -------------
>  arch/x86/kvm/x86.c         |  2 +-
>  2 files changed, 1 insertion(+), 14 deletions(-)
> 
> diff --git a/arch/x86/include/asm/tsc.h b/arch/x86/include/asm/tsc.h
> index fd11128faf25..3da1cc1218ac 100644
> --- a/arch/x86/include/asm/tsc.h
> +++ b/arch/x86/include/asm/tsc.h
> @@ -32,19 +32,6 @@ static inline cycles_t get_cycles(void)
>  	return ret;
>  }
>  
> -static __always_inline cycles_t vget_cycles(void)
> -{
> -	/*
> -	 * We only do VDSOs on TSC capable CPUs, so this shouldn't
> -	 * access boot_cpu_data (which is not VDSO-safe):
> -	 */
> -#ifndef CONFIG_X86_TSC
> -	if (!cpu_has_tsc)
> -		return 0;
> -#endif
> -	return (cycles_t)native_read_tsc();
> -}
> -
>  extern void tsc_init(void);
>  extern void mark_tsc_unstable(char *reason);
>  extern int unsynchronized_tsc(void);
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 26eaeb522cab..c26faf408bce 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -1430,7 +1430,7 @@ static cycle_t read_tsc(void)
>  	 * but no one has ever seen it happen.
>  	 */
>  	rdtsc_barrier();
> -	ret = (cycle_t)vget_cycles();
> +	ret = (cycle_t)native_read_tsc();
>  
>  	last = pvclock_gtod_data.clock.cycle_last;
>  
> 
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/x86/include/asm/tsc.h b/arch/x86/include/asm/tsc.h
index fd11128faf25..3da1cc1218ac 100644
--- a/arch/x86/include/asm/tsc.h
+++ b/arch/x86/include/asm/tsc.h
@@ -32,19 +32,6 @@  static inline cycles_t get_cycles(void)
 	return ret;
 }
 
-static __always_inline cycles_t vget_cycles(void)
-{
-	/*
-	 * We only do VDSOs on TSC capable CPUs, so this shouldn't
-	 * access boot_cpu_data (which is not VDSO-safe):
-	 */
-#ifndef CONFIG_X86_TSC
-	if (!cpu_has_tsc)
-		return 0;
-#endif
-	return (cycles_t)native_read_tsc();
-}
-
 extern void tsc_init(void);
 extern void mark_tsc_unstable(char *reason);
 extern int unsynchronized_tsc(void);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 26eaeb522cab..c26faf408bce 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1430,7 +1430,7 @@  static cycle_t read_tsc(void)
 	 * but no one has ever seen it happen.
 	 */
 	rdtsc_barrier();
-	ret = (cycle_t)vget_cycles();
+	ret = (cycle_t)native_read_tsc();
 
 	last = pvclock_gtod_data.clock.cycle_last;