From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: VDSO pvclock may increase host cpu consumption, is this a problem? Date: Tue, 1 Apr 2014 21:12:13 -0300 Message-ID: <20140402001213.GB29864@amt.cnet> References: <5339AB59.4050906@mit.edu> <20140331213032.GA5866@amt.cnet> <20140401180134.GA17963@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Thomas Gleixner , "linux-kernel@vger.kernel.org" , zhang yanying , Zhouxiangjiu , "kvm@vger.kernel.org" , "johnstul@us.ibm.com" , Zhanghailiang To: Andy Lutomirski Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Tue, Apr 01, 2014 at 12:17:16PM -0700, Andy Lutomirski wrote: > On Tue, Apr 1, 2014 at 11:01 AM, Marcelo Tosatti wrote: > > On Mon, Mar 31, 2014 at 10:33:41PM -0700, Andy Lutomirski wrote: > >> On Mar 31, 2014 8:45 PM, "Marcelo Tosatti" wrote: > >> > > >> > On Mon, Mar 31, 2014 at 10:52:25AM -0700, Andy Lutomirski wrote: > >> > > On 03/29/2014 01:47 AM, Zhanghailiang wrote: > >> > > > Hi, > >> > > > I found when Guest is idle, VDSO pvclock may increase host consumption. > >> > > > We can calcutate as follow, Correct me if I am wrong. > >> > > > (Host)250 * update_pvclock_gtod = 1500 * gettimeofday(Guest) > >> > > > In Host, VDSO pvclock introduce a notifier chain, pvclock_gtod_chain in timekeeping.c. It consume nearly 900 cycles per call. So in consideration of 250 Hz, it may consume 225,000 cycles per second, even no VM is created. > >> > > > In Guest, gettimeofday consumes 220 cycles per call with VDSO pvclock. If the no-kvmclock-vsyscall is configured, gettimeofday consumes 370 cycles per call. The feature decrease 150 cycles consumption per call. > >> > > > When call gettimeofday 1500 times,it decrease 225,000 cycles,equal to the host consumption. > >> > > > Both Host and Guest is linux-3.13.6. > >> > > > So, whether the host cpu consumption is a problem? > >> > > > >> > > Does pvclock serve any real purpose on systems with fully-functional > >> > > TSCs? The x86 guest implementation is awful, so it's about 2x slower > >> > > than TSC. It could be improved a lot, but I'm not sure I understand why > >> > > it exists in the first place. > >> > > >> > VM migration. > >> > >> Why does that need percpu stuff? Wouldn't it be sufficient to > >> interrupt all CPUs (or at least all cpus running in userspace) on > >> migration and update the normal timing data structures? > > > > Are you suggesting to allow interruption of the timekeeping code > > at any time to update frequency information ? > > I'm not sure what you mean by "interruption of the timekeeping code". > I'm suggesting sending an interrupt to the guest (via a virtio device, > presumably) to tell it that it has been paused and resumed. code: 1) disable interrupts 2) A = RDTSC 3) B = SCALE(A, TSC.FREQ) If migration happens between 2 and 3, you've got an incorrect value.