From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Jay Zhou <jianjay.zhou@huawei.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org,
wangxinxin.wang@huawei.com, weidong.huang@huawei.com,
arei.gonglei@huawei.com
Subject: Re: [Qemu-devel] [PATCH RFC] migration: kvmclock: save and load the PVCLOCK_TSC_UNSTABLE_BIT flag when migration
Date: Mon, 12 Jun 2017 22:03:15 +0200 [thread overview]
Message-ID: <20170612200315.GB16151@potion> (raw)
In-Reply-To: <1497274251-26448-1-git-send-email-jianjay.zhou@huawei.com>
2017-06-12 21:30+0800, Jay Zhou:
> Guest using kvmclock will be hanged when migrating from unstable
> tsc host to stable tsc host occasionally.
> Sometimes, the tsc timestamp saved at the source side will be
> backward when the guest stopped, and this value is transferred
> to the destination side. The guest at the destination side thought
> kvmclock is stable, so the protection mechanism against time
> going backwards is not used.
> When the first time vcpu0 enters the guest at the destination
> side to update the wall clock, the result of
> pvclock_clocksource_read will be backward occasionally,
> which results in the wall clock drift.
>
> Signed-off-by: Jay Zhou <jianjay.zhou@huawei.com>
> ---
> diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c
>
> if (running) {
> struct kvm_clock_data data = {};
> + uint8_t flags_at_migration;
>
> /*
> * If the host where s->clock was read did not support reliable
> * KVM_GET_CLOCK, read kvmclock value from memory.
> */
> if (!s->clock_is_reliable) {
'clock_is_reliable = true' on all newer KVMs (v4.9+), so I don't see a
reason to add a feature that can't be used.
> - uint64_t pvclock_via_mem = kvmclock_current_nsec(s);
> + uint64_t pvclock_via_mem = kvmclock_current_nsec(s,
> + &flags_at_migration);
kvmclock_current_nsec() was introduced to work around the problem with
backward time, so we should understand why it returns a time that is
backwards if we want to do something for old KVMs ...
Is pvclock_via_mem < s->clock?
Thanks.
> /* We can't rely on the saved clock value, just discard it */
> if (pvclock_via_mem) {
> s->clock = pvclock_via_mem;
> + /* whether src kvmclock has PVCLOCK_TSC_STABLE_BIT flag */
> + if (!(flags_at_migration & PVCLOCK_TSC_STABLE_BIT)) {
> + data.flags |= MIGRATION_PVCLOCK_TSC_UNSTABLE_BIT;
> + }
> }
> }
next prev parent reply other threads:[~2017-06-12 20:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-12 13:30 [Qemu-devel] [PATCH RFC] migration: kvmclock: save and load the PVCLOCK_TSC_UNSTABLE_BIT flag when migration Jay Zhou
2017-06-12 20:03 ` Radim Krčmář [this message]
2017-06-13 13:41 ` Jay Zhou
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=20170612200315.GB16151@potion \
--to=rkrcmar@redhat.com \
--cc=arei.gonglei@huawei.com \
--cc=jianjay.zhou@huawei.com \
--cc=kvm@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
--cc=wangxinxin.wang@huawei.com \
--cc=weidong.huang@huawei.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).