]> Git Repo - linux.git/commitdiff
kvmclock: fix TSC calibration for nested guests
authorPeng Hao <[email protected]>
Sat, 14 Jul 2018 15:28:29 +0000 (23:28 +0800)
committerPaolo Bonzini <[email protected]>
Wed, 18 Jul 2018 09:43:17 +0000 (11:43 +0200)
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 <[email protected]>
Signed-off-by: Peng Hao <[email protected]>
[Commit message rewritten. - Paolo]
Signed-off-by: Paolo Bonzini <[email protected]>
arch/x86/kernel/kvmclock.c

index d79a18b4cf9d9cf27bf3e943fa17483b835ebe0f..4c53d12ca933824126563f8babf31fd35cfe705b 100644 (file)
@@ -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;
 }
 
This page took 0.057986 seconds and 4 git commands to generate.