TSC calibration in virtual machines

Stephen J. Kiernan stevek at freebsd.org
Wed Jun 27 17:21:36 UTC 2018


On Wed, Jun 27, 2018, 12:48 PM Alan Somers <asomers at freebsd.org> wrote:

> On Wed, Jun 27, 2018 at 10:36 AM, Jung-uk Kim <jkim at freebsd.org> wrote:
>
> > On 06/27/2018 03:14, Andriy Gapon wrote:
> > >
> > > It seems that TSC calibration in virtual machines sometimes can do more
> > harm
> > > than good.  Should we default to trusting the information provided by a
> > hypervisor?
> > >
> > > Specifically, I am observing a problem on GCE instances where
> calibrated
> > TSC
> > > frequency is about 10% lower than advertised frequency.  And apparently
> > the
> > > advertised frequency is the right one.
> > >
> > > I found this thread with similar reports and a variety of workarounds
> > from
> > > administratively disabling the calibration to switching to a different
> > timecounter:
> > > https://lists.freebsd.org/pipermail/freebsd-cloud/2017-
> > January/000080.html
> >
> > We already do that for VMware hosts since r221214.
> >
> > https://svnweb.freebsd.org/changeset/base/221214
> >
> > We should do the same for each hypervisor.
> >
> > Jung-uk Kim
> >
> >
> We probably should.  But why does calibration fail in the first place?  If
> it can fail in a VM, then it can probably fail on bare metal too.  It would
> be worth investigating.
>

The main problem is you can't be assured that the DELAY call will be
accurate in those cases. Also the way that some VMs implement the rdtsc
insrruction may not be as accurate as we would need. In some cases it can
compound the issue.

-Steve


More information about the freebsd-current mailing list