From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:33413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QHcPL-0000rc-OA for qemu-devel@nongnu.org; Wed, 04 May 2011 09:46:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QHcPK-0001OZ-G0 for qemu-devel@nongnu.org; Wed, 04 May 2011 09:46:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29664) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QHcPK-0001OM-2t for qemu-devel@nongnu.org; Wed, 04 May 2011 09:46:26 -0400 Date: Wed, 4 May 2011 16:46:21 +0300 From: Gleb Natapov Message-ID: <20110504134621.GZ2265@redhat.com> References: <20110503190357.GA10617@amt.cnet> <541075535.332616.1304496419890.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com> <20110504090932.GA24953@amt.cnet> <1304516172.4737.18.camel@mothafucka.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1304516172.4737.18.camel@mothafucka.localdomain> Subject: Re: [Qemu-devel] [PATCH v3 5/5] hpet 'driftfix': add code in hpet_timer() to compensate delayed callbacks and coalesced interrupts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Glauber Costa Cc: aliguori@us.ibm.com, kvm@vger.kernel.org, qemu-devel@nongnu.org, jan kiszka , Marcelo Tosatti , Ulrich Obergfell , gcosta@redhat.com, avi@redhat.com On Wed, May 04, 2011 at 10:36:12AM -0300, Glauber Costa wrote: > On Wed, 2011-05-04 at 06:09 -0300, Marcelo Tosatti wrote: > > On Wed, May 04, 2011 at 04:06:59AM -0400, Ulrich Obergfell wrote: > > > > > > Hi Marcelo, > > > > > > > Whats prev_period for, since in practice the period will not change > > > > between interrupts (OS programs comparator once, or perhaps twice > > > > during bootup) ? > > > > > > 'prev_period' is needed if a guest o/s changes the comparator period > > > 'on the fly' (without stopping and restarting the timer). > > > > > > > > > guest o/s changes period > > > | > > > ti(n-1) | ti(n) ti(n+1) > > > | v | | > > > +---------------------+------------------------------+ > > > > > > <--- prev_period ---> <---------- period ----------> > > > > > > > > > The idea is that each timer interrupt represents a certain quantum > > > of time (the comparator period). If a guest o/s changes the period > > > between timer interrupt 'n-1' and timer interrupt 'n', I think the > > > new value should not take effect before timer interrupt 'n'. Timer > > > interrupt 'n' still represents the old/previous quantum, and timer > > > interrupt 'n+1' represents the new quantum. > > > > > > Hence, the patch decrements 'ticks_not_accounted' by 'prev_period' > > > and sets 'prev_period' to 'period' when an interrupt was delivered > > > to the guest o/s. > > > > > > + irq_delivered = update_irq(t, 1); > > > + if (irq_delivered) { > > > + t->ticks_not_accounted -= t->prev_period; > > > + t->prev_period = t->period; > > > + } else { > > > > > > Most of the time 'prev_period' is equal to 'period'. It should only > > > be different in the scenario shown above. > > > > OK, makes sense. You should probably reset ticks_not_accounted to zero > > on HPET initialization (for example, to avoid miscalibration when > > kexec'ing a new kernel). > > Everybody resetting the machine in anyway is expected to force devices > to be reinitialized, right ? > I may be wrong, but I was under the impression that kexec would do this > as well. In this case, the reset function should be enough. > kexec does not reset a machine. That's the whole point of kexec in fact. -- Gleb.