Page MenuHomeFreeBSD

hyperv: register hv_timecounter in SI_SUB_HYPERVISOR
ClosedPublic

Authored by decui_microsoft.com on Mar 30 2016, 3:46 AM.
Tags
None
Referenced Files
F81921502: D5778.id.diff
Tue, Apr 23, 5:28 AM
F81921467: D5778.diff
Tue, Apr 23, 5:27 AM
Unknown Object (File)
Fri, Apr 19, 2:33 PM
Unknown Object (File)
Fri, Apr 19, 2:33 PM
Unknown Object (File)
Fri, Apr 19, 2:33 PM
Unknown Object (File)
Tue, Apr 16, 10:00 PM
Unknown Object (File)
Tue, Apr 16, 6:17 PM
Unknown Object (File)
Sun, Mar 31, 12:46 PM
Subscribers

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 - subversion
Lint
Lint Not Applicable
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
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.