From mboxrd@z Thu Jan 1 00:00:00 1970 From: Glauber Costa Subject: Re: [PATCH 5/7] KVM-GST: KVM Steal time accounting Date: Tue, 14 Jun 2011 22:08:03 -0300 Message-ID: <4DF805F3.4030603@redhat.com> References: <1308007897-17013-1-git-send-email-glommer@redhat.com> <1308007897-17013-6-git-send-email-glommer@redhat.com> <1308046203.19856.9.camel@twins> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Rik van Riel , Jeremy Fitzhardinge , Avi Kivity , Anthony Liguori , Eric B Munson To: Peter Zijlstra Return-path: In-Reply-To: <1308046203.19856.9.camel@twins> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 06/14/2011 07:10 AM, Peter Zijlstra wrote: > On Mon, 2011-06-13 at 19:31 -0400, Glauber Costa wrote: >> +static inline int touch_steal_time(int is_idle) >> +{ >> + u64 steal, st = 0; >> + >> + if (static_branch(¶virt_steal_enabled)) { >> + >> + steal = paravirt_steal_clock(smp_processor_id()); >> + >> + steal -= this_rq()->prev_steal_time; >> + this_rq()->prev_steal_time += steal; > > If you move this addition below this test: > >> + if (is_idle || (steal< TICK_NSEC)) >> + return 0; > > that is, right here, then you don't loose tiny steal deltas and > subsequent ticks accumulate their steal time until you really > have a full steal tick to account. true > I guess you want something different for the idle case though. definitely. >> + while (steal> TICK_NSEC) { > > /* really, if we wanted a division we'd have written one */ > asm("" : "+rm" (steal)); Out of curiosity, have we seen any compiler de-optimize it to a division, or are you just being careful ? >> + steal -= TICK_NSEC; >> + st++; >> + } >> + >> + account_steal_time(st); >> + return 1; >> + } >> + return 0; >> +} > >