aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Hao <peng.hao2@zte.com.cn>2018-07-14 23:28:29 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-08-24 13:07:12 +0200
commit1ba4f24d19bd636537859226086c63ec73a50a6c (patch)
treeb34e4dd803fa0f525a06c45a37fb15404fa8eafb
parent80e3c217d1ba398f204a6e84d7be3a2ec066b696 (diff)
downloadlinux-1ba4f24d19bd636537859226086c63ec73a50a6c.tar.gz
kvmclock: fix TSC calibration for nested guests
[ Upstream commit e10f7805032365cc11c739a97f226ebb48aee042 ] Inside a nested guest, access to hardware can be slow enough that tsc_read_refs always return ULLONG_MAX, causing tsc_refine_calibration_work to be called periodically and the nested guest to spend a lot of time reading the ACPI timer. However, if the TSC frequency is available from the pvclock page, we can just set X86_FEATURE_TSC_KNOWN_FREQ and avoid the recalibration. 'refine' operation. Suggested-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Peng Hao <peng.hao2@zte.com.cn> [Commit message rewritten. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--arch/x86/kernel/kvmclock.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index d79a18b4cf9d9c..4c53d12ca93382 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -138,6 +138,7 @@ static unsigned long kvm_get_tsc_khz(void)
src = &hv_clock[cpu].pvti;
tsc_khz = pvclock_tsc_khz(src);
put_cpu();
+ setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
return tsc_khz;
}