From mboxrd@z Thu Jan 1 00:00:00 1970
From: bugzilla-daemon@bugzilla.kernel.org
Subject: [Bug 195207] New: Kvmclock: Time warp when hotplug vcpu.
Date: Sat, 01 Apr 2017 01:29:48 +0000
Message-ID:
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8BIT
To: kvm@kernel.org
Return-path:
Received: from mail.wl.linuxfoundation.org ([198.145.29.98]:56452 "EHLO
mail.wl.linuxfoundation.org" rhost-flags-OK-OK-OK-OK)
by vger.kernel.org with ESMTP id S1754944AbdDAB3u (ORCPT
); Fri, 31 Mar 2017 21:29:50 -0400
Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1])
by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C84D286B4
for ; Sat, 1 Apr 2017 01:29:50 +0000 (UTC)
Received: from pdx-korg-bugzilla-1.web.codeaurora.org (unknown [172.30.200.120])
by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DD93286B4
for ; Sat, 1 Apr 2017 01:29:48 +0000 (UTC)
Sender: kvm-owner@vger.kernel.org
List-ID:
https://bugzilla.kernel.org/show_bug.cgi?id=195207
Bug ID: 195207
Summary: Kvmclock: Time warp when hotplug vcpu.
Product: Virtualization
Version: unspecified
Kernel Version: ALL
Hardware: All
OS: Linux
Tree: Mainline
Status: NEW
Severity: normal
Priority: P1
Component: kvm
Assignee: virtualization_kvm@kernel-bugs.osdl.org
Reporter: changlimin@h3c.com
Regression: No
1. Both KVM and VM will use kvmclock asap, usually the use_master_clock is
true, so all vcpus use the same base tsc and ns to calculate current ns.
2. When hotplug a vcpu to a VM, the use_master_clock will change to false, also
KVM updates base tsc and ns to all vcpus periodically.
3. KVM uses clocksource_tsc to get current ns, while VM uses kvm_clock to get
current ns. For the same delta_tsc, they will get different result.
4. After run for more than 10 hours on a 2.4Ghz host, a redhat 6.6 VM will
panic when been hotpluged a vcpu. The reason is the time warp in VM
timekeeping_get_ns
cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
// cycle_now is less than clock->cycle_last
5. Redhat 6.7 doesn't have this issue when
CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE=y
#ifdef CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE
static inline cycle_t clocksource_delta(cycle_t now, cycle_t last, cycle_t
mask)
{
cycle_t ret = (now - last) & mask;
return (s64) ret > 0 ? ret : 0;
}
#else
static inline cycle_t clocksource_delta(cycle_t now, cycle_t last, cycle_t
mask)
{
return (now - last) & mask;
}
#endif
6. It's better to fix it in KVM, when change base tsc and ns in kvmclock, also
calculate ns using kvm_clock arithmetic, be sure no time warp.
--
You are receiving this mail because:
You are watching the assignee of the bug.