public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: bugzilla-daemon@bugzilla.kernel.org
To: kvm@kernel.org
Subject: [Bug 195207] New: Kvmclock: Time warp when hotplug vcpu.
Date: Sat, 01 Apr 2017 01:29:48 +0000	[thread overview]
Message-ID: <bug-195207-28872@https.bugzilla.kernel.org/> (raw)

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.

                 reply	other threads:[~2017-04-01  1:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=bug-195207-28872@https.bugzilla.kernel.org/ \
    --to=bugzilla-daemon@bugzilla.kernel.org \
    --cc=kvm@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