From: Paolo Bonzini Subject: Re: TSC deadline timer in guests vs. migration? Date: Tue, 5 Jul 2016 12:48:45 +0200 Message-ID: References: <759376f0-e0bf-e53a-99e4-598bf14547e3@redhat.com> <20160704190710.GB4131@thinpad.lan.raisama.net> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Cc: Marcelo Tosatti , David Matlack , Peter Hornyack , KVM list To: Eduardo Habkost Return-path: Received: from mail-wm0-f44.google.com ([74.125.82.44]:34865 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751268AbcGEKsu (ORCPT ); Tue, 5 Jul 2016 06:48:50 -0400 Received: by mail-wm0-f44.google.com with SMTP id z126so70359903wme.0 for ; Tue, 05 Jul 2016 03:48:49 -0700 (PDT) In-Reply-To: <20160704190710.GB4131@thinpad.lan.raisama.net> Sender: kvm-owner@vger.kernel.org List-ID: On 04/07/2016 21:07, Eduardo Habkost 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. > > I believe it can. Also: what about everything else the guest may > try to use the TSC for? (even without TSC deadline timer) Luckily there isn't much that uses it directly. Userspace should not trust the TSC. In practice there's quite some code that uses it for performance measurement, but probably not for timekeeping. > From a quick look at Linux code, it looks like the TSC > clocksource code is more strict (but the exact rules are hard to > follow), but it will still use the TSC in native_sched_clock(). This is not a big problem because KVM pvops override sched_clock to kvm_clock_read(). > What about kvmclock? Do we have a mechanism to trigger a re-read > of TSC frequency from the hypervisor? Yes, that's the point of kvmclock. Every time the TSC frequency changes (which includes the first time you start the VCPU on a new host), the kvmclock pages are updated with new data. Paolo