Page MenuHomeFreeBSD

hyperv: register hv_timecounter in SI_SUB_HYPERVISOR
ClosedPublic

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

Details

Summary

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):
https://reviews.freebsd.org/D5174

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

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

decui_microsoft.com retitled this revision from to hyperv: regiter hv_timecounter in SI_SUB_HYPERVISOR.
decui_microsoft.com updated this object.
decui_microsoft.com edited the test plan for this revision. (Show Details)
decui_microsoft.com 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
sepherosa_gmail.com edited edge metadata.
This revision is now accepted and ready to land.Mar 30 2016, 5:01 AM
kib accepted this revision.Mar 30 2016, 8:48 AM
kib edited edge metadata.

I successfully run with the change for some time.

This revision was automatically updated to reflect the committed changes.