Re: [Patch] Skip cpu_calibrate for kernel running under hypervisors.

H. Peter Anvin
2010-08-16T23:56:44Z

On 08/16/2010 12:25 PM, Alok Kataria wrote:
> Hi,
>
> This is a trivial change to fix the cpu_khz value returned when running
> on a virtualized environment. We have seen instances when the cpu_khz
> value is off by couple of MHz's when running on VMware's platform on AMD
> hardware.
>
> --
> Since the TSC frequency read from hypervisor is accurate for the guest, and
> since the hypervisor will always clock the vcpu at the TSC frequency, there is
> no need to calibrate it again. To avoid any calibration errors through
> calibrate_cpu this patch skips calling calibrate_cpu for kernel running
> under hypervisors.
>

I'm somewhat reluctant to take this one, since it assumes all the
hypervisors act the same. This seems rather inherently wrong. In fact,
the whole statement is fishy as heck... instead of being dependent on
AMD and so on, this should either be a function pointer or a CPU
(mis)feature bit.

Can we do this saner?

-hpa