Skip to content
Snippets Groups Projects
Commit ae65b676 authored by Nadav Har'El's avatar Nadav Har'El Committed by Pekka Enberg
Browse files

Document clock::time() and fix its implementation on kvmclock


Our clock::time() function returns the current wall-clock time (number of
nanoseconds since the Unix epoch). We never clearly documented this, so this
patch adds this documentation.

Moreover, in kvmclock, we assumed that the host never adjusts its
wall-clock time, which is not a good assumption because it prevents us
from benefiting from NTP running on the host. As Avi Kivity explains:

   "For the wall clock, you need to sample the wall clock base every time,
    since it can be changed by the host."

So this patch changes kvmclock::time() to sample the wall-clock-at-boot
reported by the paravirtual clock, on every time() call, and not just once.

The downsite of this patch is that clock::get::time(), and therefore
nanotime(), become a bit slower on kvmclock, as they need to sample
the wall_clock_boot() every time, require a couple of barriers and
arithmetic operations. But note that we shouldn't even be using the
non-monotonic clock::get::time() for our timers - we should be using the
monotonic clock::get::uptime() - and when we switch to using that we'll
get back the bit of performance lost in this patch.

Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent 402d70b2
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment