From mboxrd@z Thu Jan 1 00:00:00 1970 From: Glauber Costa Subject: Re: [RFC 5/7] kvm steal time implementation Date: Thu, 26 Aug 2010 19:35:03 -0300 Message-ID: <20100826223503.GI2985@mothafucka.localdomain> References: <1282772597-4183-1-git-send-email-glommer@redhat.com> <1282772597-4183-2-git-send-email-glommer@redhat.com> <1282772597-4183-3-git-send-email-glommer@redhat.com> <1282772597-4183-4-git-send-email-glommer@redhat.com> <1282772597-4183-5-git-send-email-glommer@redhat.com> <1282772597-4183-6-git-send-email-glommer@redhat.com> <4C76E6F3.5020402@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, avi@redhat.com, zamsden@redhat.com, mtosatti@redhat.com To: Rik van Riel Return-path: Received: from mx1.redhat.com ([209.132.183.28]:63569 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751193Ab0HZWfG (ORCPT ); Thu, 26 Aug 2010 18:35:06 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7QMZ6Wb012193 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 26 Aug 2010 18:35:06 -0400 Content-Disposition: inline In-Reply-To: <4C76E6F3.5020402@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Aug 26, 2010 at 06:13:07PM -0400, Rik van Riel wrote: > On 08/25/2010 05:43 PM, Glauber Costa wrote: > >This is the proposed kvm-side steal time implementation. > >It is migration safe, as it checks flags at every read. > > > >Signed-off-by: Glauber Costa > >--- > > arch/x86/kernel/kvmclock.c | 35 +++++++++++++++++++++++++++++++++++ > > 1 files changed, 35 insertions(+), 0 deletions(-) > > > >diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c > >index eb9b76c..a1f4852 100644 > >--- a/arch/x86/kernel/kvmclock.c > >+++ b/arch/x86/kernel/kvmclock.c > >@@ -18,6 +18,8 @@ > > > > #include > > #include > >+#include > >+#include > > #include > > #include > > #include > >@@ -41,6 +43,7 @@ early_param("no-kvmclock", parse_no_kvmclock); > > > > /* The hypervisor will put information about time periodically here */ > > static DEFINE_PER_CPU_SHARED_ALIGNED(struct pvclock_vcpu_time_info, hv_clock); > >+static DEFINE_PER_CPU(u64, steal_info); > > static struct pvclock_wall_clock wall_clock; > > > > /* > >@@ -82,6 +85,32 @@ static cycle_t kvm_clock_read(void) > > return ret; > > } > > > >+static DEFINE_PER_CPU(u64, steal_info); > >+ > >+cputime_t kvm_get_steal_time(void) > >+{ > >+ u64 delta = 0; > >+ u64 *last_steal_info, this_steal_info; > >+ struct pvclock_vcpu_time_info *src; > >+ > >+ src =&get_cpu_var(hv_clock); > >+ if (!(src->flags& PVCLOCK_STEAL_BIT)) > >+ goto out; > >+ > >+ this_steal_info = src->steal_time; > >+ put_cpu_var(hv_clock); > >+ > >+ last_steal_info =&get_cpu_var(steal_info); > >+ > >+ delta = this_steal_info - *last_steal_info; > >+ > >+ *last_steal_info = this_steal_info; > >+ put_cpu_var(steal_info); > >+ > >+out: > >+ return msecs_to_cputime(delta); > >+} > > Can this be changed to properly deal with overflow in > src->steal_time, the same way we deal with (eg jiffie) > overflow elsewhere in the kernel? I believe so.