From: Marcelo Tosatti <mtosatti@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
David Matlack <dmatlack@google.com>,
Peter Hornyack <peterhornyack@google.com>,
KVM list <kvm@vger.kernel.org>
Subject: Re: TSC deadline timer in guests vs. migration?
Date: Tue, 5 Jul 2016 09:51:41 -0300 [thread overview]
Message-ID: <20160705125140.GA17664@amt.cnet> (raw)
In-Reply-To: <20160704194506.GE4131@thinpad.lan.raisama.net>
On Mon, Jul 04, 2016 at 04:45:06PM -0300, Eduardo Habkost wrote:
> On Mon, Jul 04, 2016 at 04:30:08PM -0300, Marcelo Tosatti wrote:
> > On Mon, Jul 04, 2016 at 01:01:42PM +0200, Paolo Bonzini wrote:
> > > Can bad things happen if a guest using the TSC deadline timer is
> > > migrated? The guest doesn't re-calibrate the TSC after migration, and
> > > the TSC frequency can and will change unless your data center is
> > > perfectly homogeneous.
> >
> > It can fire earlier if the destination runs at a higher frequency.
> > It will fire past the configured time if the destination runs at a slower frequency.
> >
> > Suppose the first case is worse.
> >
> > Should convert the expiration time to nanoseconds i suppose, and then
> > convert back on the destination.
>
> This won't make any difference if the guest sets up a new timer
> after migration (but using the old TSC frequency), will it?
It does, because the timer setup traps to the host, where you can
convert it to the proper value:
guest_tsc = kvm_x86_ops->read_l1_tsc(vcpu,
native_read_tsc());
if (likely(tscdeadline > guest_tsc)) {
ns = (tscdeadline - guest_tsc) * 1000000ULL;
do_div(ns, this_tsc_khz);
expire = ktime_add_ns(now, ns);
expire = ktime_sub_ns(expire,
lapic_timer_advance_ns);
hrtimer_start(&apic->lapic_timer.timer,
expire, HRTIMER_MODE_ABS);
} else
I've opened a BZ: feel free to take it, or make a reference to it
if you submit a patch to fix it (including the CC'ed Google guys).
https://bugzilla.redhat.com/show_bug.cgi?id=1352909
next prev parent reply other threads:[~2016-07-05 12:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-04 11:01 TSC deadline timer in guests vs. migration? Paolo Bonzini
2016-07-04 19:07 ` Eduardo Habkost
2016-07-05 10:48 ` Paolo Bonzini
2016-07-04 19:30 ` Marcelo Tosatti
2016-07-04 19:45 ` Eduardo Habkost
2016-07-04 20:17 ` Paolo Bonzini
2016-07-05 12:51 ` Marcelo Tosatti [this message]
2016-07-05 13:04 ` Eduardo Habkost
2016-07-05 13:34 ` Paolo Bonzini
2016-07-05 18:11 ` Eduardo Habkost
2016-07-05 21:40 ` Paolo Bonzini
2016-07-05 22:12 ` Eduardo Habkost
2016-07-06 6:01 ` Paolo Bonzini
2016-07-05 20:39 ` Marcelo Tosatti
2016-07-05 21:41 ` 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=20160705125140.GA17664@amt.cnet \
--to=mtosatti@redhat.com \
--cc=dmatlack@google.com \
--cc=ehabkost@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=peterhornyack@google.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