GCE: significant clock drift - the solution

Bruce Walker bruce.walker at gmail.com
Thu Jan 19 01:10:24 UTC 2017


Hi gang, first message. I am developing on Google Cloud Engine, I'm using
the FreeBSD community image, and so far it's been pretty painless. Thank
you!

But I noticed that the system clock on one of my two instances was drifting
fast over time, and I mean really fast. I estimate about 1 second ahead for
every 20-30 seconds of elapsed time.

So I would stop and restart ntpd and that would reset the time. Then the
creep again ...

Long story short: I searched the Google gce-discussion group and found
another FreeBSD user with the same issue, and a solution was provided by
one Andy Carrel. In a nutshell two system boot files need tweaks:

/boot/loader.conf
    machdep.disable_tsc_calibration=1
    kern.timecounter.invariant_tsc=1

/etc/sysctl.conf
    kern.timecounter.hardware=TSC-low

Andy further explains: "The loader.conf changes instruct the kernel to not
try to do calibration of the TSC, since this calibration could give bad
results due to the virtualization, and to ignore the fact that the
"invariant TSC" feature is not advertised by the CPU and just assume the
CPU has this feature.

The sysctl.conf change instructs the kernel to use the TSC-low timecounter
which was made available by the loader.conf changes."

For reference, here's a link to the posting:
https://groups.google.com/forum/#!msg/gce-discussion/NKhl1QOVucQ/EDyLd_FxCAAJ


Maybe these can make it back into the community cloud image.

-- 
-bmw


More information about the freebsd-cloud mailing list