Do not adjust clock gradually to avoid clock speed mismatch in VMs

Do not adjust clock gradually even if it is close enough to the right
time, to avoid clock speed mismatch between VMs and the host.

Monotonic clocks (CLOCK_BOOTTIME / CLOCK_MONOTONIC) are used in both
host and guest for performance tracing and other high-resolution
timestamps. However, the speed of those clocks can be changed by adjtime
syscall to apply the small changes to catch up with the clock provided
via NTP/TLS. This is done in the kernel so that the host and the guest
maintains the clocks separately and applying such changes individually.
This makes it hard to sync the clocks between host and guest, which
indirectly breaks the matching of tracing events between them.

The call to adjtime was added to make timestamps in logs show fewer jumps
in crrev/c/1344802 but this doesn't justify the clock deviation between
guest and host. Instead, this CL adds logging to make it clear when the
adjustment is happend.

BUG=b:197780049
TEST=built

Change-Id: I4c965d55a4132bb5c1bc95bcdbc92b69e4e8b28e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/tlsdate/+/4573202
Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
Tested-by: Hikaru Nishida <hikalium@chromium.org>
Auto-Submit: Hikaru Nishida <hikalium@chromium.org>
Reviewed-by: Suleiman Souhlal <suleiman@chromium.org>
Reviewed-by: Hugo Benichi <hugobenichi@google.com>
Commit-Queue: Hikaru Nishida <hikalium@chromium.org>
2 files changed