Page MenuHomeFreeBSD

bhyve could be more precise with vPIT
ClosedPublic

Authored by pmooney_pfmooney.com on May 21 2019, 5:37 PM.

Details

Summary

As part of an investigation into NTP time synchronization issues under bhyve, we found that use of sbintime_t over struct bintime for the vPIT emulation resulted in an unnecessary loss of precision that negatively impacted consumers' ability to use it as an accurate time reference. Ignoring timer/callout implementation details, the lack of precision itself was causing a 59ppm error, a not-so-insignificant fraction of the 500ppm divergence budget which some NTP implementations possess.

The full write-up can be found in OS-6923

Test Plan

During development of the change, APIC timer debugging information from a Linux guest (compare against the expected 838860 ticks) was used to judge performance of the emulated PIT.

Stock:

838753 - 107    (128 ppm)
838776 - 84     (100 ppm)
838774 - 86     (103 ppm)
838706 - 154    (184 ppm)
838768 - 92     (110 ppm)
838769 - 91     (108 ppm)

Patched:

838922 - 62     (74 ppm)
838903 - 43     (51 ppm)
838908 - 48     (57 ppm)
838906 - 46     (55 ppm)
838905 - 45     (54 ppm)
838907 - 47     (56 ppm)

This change has been in SmartOS bhyve for almost a year.

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

Any more little gold mines like this sitting around?

sys/amd64/vmm/io/vatpit.c
187 ↗(On Diff #57640)

These 2 declarations should migrate up to the start of this function, as they are not const so the exception used in prior changes do not apply here, though we should probably go fix style(9) and not this. Final call is jhb@'s if this needs fixed.

jhb accepted this revision.Jul 17 2019, 8:49 PM
This revision is now accepted and ready to land.Jul 17 2019, 8:49 PM
This revision was automatically updated to reflect the committed changes.