Page MenuHomeFreeBSD

hyperv: register hv_timecounter in SI_SUB_HYPERVISOR

Authored by on Mar 30 2016, 3:46 AM.



hv_timecounter only needs rdmsr() and doesn't depend on the infrastructure
suppied by the whole vmbus driver (i.e., interrupt, channel, etc.), so we
can move it to an earlier place. This way, we can reliably use DELAY() in
probe_tsc_freq() -> DELAY().

Note: the i8254 PIT counter emulated by Hyper-V is not reliable and it even
doesn't exist in a Hyper-V Generation-2 VM (UEFI VM):

With this patch, the TSC frequency is properly calibrated and the below
warnings will go away:

calcru: runtime went backwards from 18 usec to 9 usec for pid 0 (kernel)
calcru: runtime went backwards from 46204978 usec to 23362331 usec for pid 0 (kernel)

Test Plan

Boot the kernel with boot_verbose="YES", and check dmesg:

dmesg | grep "TSC clock"
Calibrating TSC clock ... TSC clock: 2500003082 Hz
(This is the correct TSC frequency. Without the patch, the detected TSC
frequency is only ~1.3GHz in my test.)

Diff Detail

rS FreeBSD src repository - subversion
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline retitled this revision from to hyperv: regiter hv_timecounter in SI_SUB_HYPERVISOR. updated this object. edited the test plan for this revision. (Show Details) retitled this revision from hyperv: regiter hv_timecounter in SI_SUB_HYPERVISOR to hyperv: register hv_timecounter in SI_SUB_HYPERVISOR.Mar 30 2016, 4:48 AM
This revision is now accepted and ready to land.Mar 30 2016, 5:01 AM
kib edited edge metadata.

I successfully run with the change for some time.

This revision was automatically updated to reflect the committed changes.