From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [patch 15/18] KVM: x86: implement PVCLOCK_TSC_STABLE_BIT pvclock flag\ Date: Wed, 31 Oct 2012 01:19:47 -0200 Message-ID: <20121031031947.GC9913@amt.cnet> References: <20121024131340.742340256@redhat.com> <20121024131621.986748651@redhat.com> <508F9111.3030003@parallels.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, johnstul@us.ibm.com, jeremy@goop.org, zamsden@gmail.com, gleb@redhat.com, avi@redhat.com, pbonzini@redhat.com To: Glauber Costa Return-path: Received: from mx1.redhat.com ([209.132.183.28]:26579 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756932Ab2JaD10 (ORCPT ); Tue, 30 Oct 2012 23:27:26 -0400 Content-Disposition: inline In-Reply-To: <508F9111.3030003@parallels.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Oct 30, 2012 at 12:34:25PM +0400, Glauber Costa wrote: > On 10/24/2012 05:13 PM, Marcelo Tosatti wrote: > > KVM added a global variable to guarantee monotonicity in the guest. > > One of the reasons for that is that the time between > > > > 1. ktime_get_ts(×pec); > > 2. rdtscll(tsc); > > > > Is variable. That is, given a host with stable TSC, suppose that > > two VCPUs read the same time via ktime_get_ts() above. > > > > The time required to execute 2. is not the same on those two instances > > executing in different VCPUS (cache misses, interrupts...). > > > > If the TSC value that is used by the host to interpolate when > > calculating the monotonic time is the same value used to calculate > > the tsc_timestamp value stored in the pvclock data structure, and > > a single tuple is visible to all > > vcpus simultaneously, this problem disappears. See comment on top > > of pvclock_update_vm_gtod_copy for details. > > > > Monotonicity is then guaranteed by synchronicity of the host TSCs > > and guest TSCs. > > > > Set TSC stable pvclock flag in that case, allowing the guest to read > > clock from userspace. > > > > Signed-off-by: Marcelo Tosatti > > If you are using a master copy, with a stable host-side tsc, you can get > rid of the normal REQ_CLOCK updates during vcpu load. Yes. The updates are harmless and not frequent, though, so i'd rather not touch this.