From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: [patch 8/7] x86/kvmclock: Avoid TSC recalibration Date: Mon, 9 Jul 2018 11:22:43 +0200 Message-ID: <20180709092243.GG2476@hirez.programming.kicks-ass.net> References: <20180706161307.733337643@linutronix.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: LKML , Paolo Bonzini , Radim Krcmar , Juergen Gross , Pavel Tatashin , steven.sistare@oracle.com, daniel.m.jordan@oracle.com, x86@kernel.org, kvm@vger.kernel.org To: Thomas Gleixner Return-path: Content-Disposition: inline In-Reply-To: <20180706161307.733337643@linutronix.de> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org If the host gives us a TSC rate, assume it is good and don't try and recalibrate things against virtual timer hardware. Signed-off-by: Peter Zijlstra (Intel) --- --- a/arch/x86/kernel/kvmclock.c +++ b/arch/x86/kernel/kvmclock.c @@ -140,7 +140,16 @@ static inline void kvm_sched_clock_init( */ static unsigned long kvm_get_tsc_khz(void) { - return pvclock_tsc_khz(this_cpu_pvti()); + unsigned long tsc_khz = pvclock_tsc_khz(this_cpu_pvti()); + + /* + * TSC frequency is reported by the host; calibration against (virtual) + * HPET/PM-timer in a guest is dodgy and pointless since the host already + * did it for us where required. + */ + setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ); + + return tsc_khz; } static void kvm_get_preset_lpj(void)