From: Paolo Bonzini <pbonzini@redhat.com>
To: Pavel Tatashin <pasha.tatashin@soleen.com>,
rkrcmar@redhat.com, tglx@linutronix.de, mingo@redhat.com,
bp@alien8.de, hpa@zytor.com, x86@kernel.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, nuxi@vault24.org,
carnil@debian.org, t.glaser@tarent.de, asmadeus@codewreck.org
Subject: Re: [PATCH] x86/kvmclock: set offset for kvm unstable clock
Date: Mon, 28 Jan 2019 10:15:53 +0100 [thread overview]
Message-ID: <90ff0ec7-7afa-d719-1b32-09e4bdaecb75@redhat.com> (raw)
In-Reply-To: <20190126174956.22769-1-pasha.tatashin@soleen.com>
On 26/01/19 18:49, Pavel Tatashin wrote:
> VMs may show incorrect uptime and dmesg printk offsets on hypervisors with
> unstable clock. The problem is produced when VM is rebooted without exiting
> from qemu.
>
> The fix is to calculate clock offset not only for stable clock but for
> unstable clock as well, and use kvm_sched_clock_read() which substracts
> the offset for both clocks.
>
> This is safe, because pvclock_clocksource_read() does the right thing and
> makes sure that clock always goes forward, so once offset is calculated
> with unstable clock, we won't get new reads that are smaller than offset,
> and thus won't get negative results.
>
> Thank you Jon DeVree for helping to reproduce this issue.
>
> Fixes: 857baa87b642 ("sched/clock: Enable sched clock early")
>
> Reported-by: Dominique Martinet <asmadeus@codewreck.org>
> Signed-off-by: Pavel Tatashin <pasha.tatashin@soleen.com>
> ---
> arch/x86/kernel/kvmclock.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
> index e811d4d1c824..d908a37bf3f3 100644
> --- a/arch/x86/kernel/kvmclock.c
> +++ b/arch/x86/kernel/kvmclock.c
> @@ -104,12 +104,8 @@ static u64 kvm_sched_clock_read(void)
>
> static inline void kvm_sched_clock_init(bool stable)
> {
> - if (!stable) {
> - pv_ops.time.sched_clock = kvm_clock_read;
> + if (!stable)
> clear_sched_clock_stable();
> - return;
> - }
> -
> kvm_sched_clock_offset = kvm_clock_read();
> pv_ops.time.sched_clock = kvm_sched_clock_read;
>
>
Queued, thanks.
Pa
next prev parent reply other threads:[~2019-01-28 9:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-26 17:49 [PATCH] x86/kvmclock: set offset for kvm unstable clock Pavel Tatashin
2019-01-28 9:15 ` Paolo Bonzini [this message]
2019-01-28 16:22 ` Jon DeVree
2019-01-30 16:06 ` Paolo Bonzini
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=90ff0ec7-7afa-d719-1b32-09e4bdaecb75@redhat.com \
--to=pbonzini@redhat.com \
--cc=asmadeus@codewreck.org \
--cc=bp@alien8.de \
--cc=carnil@debian.org \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nuxi@vault24.org \
--cc=pasha.tatashin@soleen.com \
--cc=rkrcmar@redhat.com \
--cc=t.glaser@tarent.de \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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).