From: Marcelo Tosatti <mtosatti@redhat.com>
To: "Nadav Har'El" <nyh@math.technion.ac.il>
Cc: kvm@vger.kernel.org
Subject: Re: Monotonic clock with KVM pv-clock
Date: Mon, 20 Jan 2014 11:33:17 -0200 [thread overview]
Message-ID: <20140120133317.GA7509@amt.cnet> (raw)
In-Reply-To: <20140120095656.GA1282@fermat.math.technion.ac.il>
On Mon, Jan 20, 2014 at 11:56:56AM +0200, Nadav Har'El wrote:
> Hi,
>
> I'm trying to figure out how a guest OS can get a monotonic clock using
> KVM's paravirtual clock.
>
> At first, I thought that the clock I get using KVM_SYSTEM_TIME is a
> monotonic clock, based on the host's monotonic clock.
It is. However, it is used in conjunction with TSC delta, part
of the structure which is written at KVM_SYSTEM_TIME GPA. See
pvclock_clocksource_read at arch/x86/kernel/pvclock.c.
> But I'm no longer sure this is actually done correctly:
>
> 1. What happens on live migration? On the new host, will the
> KVM_SYSTEM_TIME continue from the same point?
Yes, from the same point where the VM was stopped on the source.
> Or will it jump because
> KVM_WALL_CLOCK (the wall time during boot) is different on the new host?
No, it won't, see the kernel commit which introduces
KVM_SET_CLOCK/KVM_GET_CLOCK.
> 2. What happens when the wall-clock time is set on the host? I was
> hoping that only KVM_WALL_CLOCK changes and KVM_SYSTEM_TIME doesn't,
> but am no longer sure this is actually the case.
Yes, it is the case. The host clock which backs system_timestamp field
of pvclock structure is
CLOCK_MONOTONIC
Clock that cannot be set and represents monotonic time
since some unspecified starting point. This clock is not affected by
discontinuous jumps in the system time (e.g., if the system
administrator manually changes the clock), but is affected by the
incremental adjustments per‐formed by adjtime(3) and NTP.
> If KVM_SYSTEM_TIME is not a correct way to get a monotonic paravirtual clock
> from KVM, is there a correct way?
Inside a Linux guest? Can use sched_clock().
If not a Linux guest, either implement kvmclock-like driver
(kvm-unit-test contains one).
>
> Thanks,
> Nadav.
>
> --
> Nadav Har'El | Monday, Jan 20 2014, 19 Shevat 5774
> nyh@math.technion.ac.il |-----------------------------------------
> Phone +972-523-790466, ICQ 13349191 |Diplomat: A man who always remembers a
> http://nadav.harel.org.il |woman's birthday but never her age.
next prev parent reply other threads:[~2014-01-20 13:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-20 9:56 Monotonic clock with KVM pv-clock Nadav Har'El
2014-01-20 13:33 ` Marcelo Tosatti [this message]
2014-01-20 14:59 ` Fernando Luis Vazquez Cao
2014-01-21 0:19 ` Marcelo Tosatti
2014-01-21 14:23 ` Fernando Luis Vazquez Cao
2014-01-22 15:41 ` Marcelo Tosatti
2014-01-21 13:24 ` Nadav Har'El
2014-01-21 15:27 ` Marcelo Tosatti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140120133317.GA7509@amt.cnet \
--to=mtosatti@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=nyh@math.technion.ac.il \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.