All of lore.kernel.org
 help / color / mirror / Atom feed
* [Bug 195207] New: Kvmclock: Time warp when hotplug vcpu.
@ 2017-04-01  1:29 bugzilla-daemon
  0 siblings, 0 replies; only message in thread
From: bugzilla-daemon @ 2017-04-01  1:29 UTC (permalink / raw)
  To: kvm

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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-04-01  1:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-01  1:29 [Bug 195207] New: Kvmclock: Time warp when hotplug vcpu bugzilla-daemon

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.