From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzY6s-000856-HX for qemu-devel@nongnu.org; Thu, 09 Aug 2012 15:09:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SzY6r-0000co-CU for qemu-devel@nongnu.org; Thu, 09 Aug 2012 15:09:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10889) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzY6q-0000cR-US for qemu-devel@nongnu.org; Thu, 09 Aug 2012 15:09:29 -0400 Date: Thu, 9 Aug 2012 16:06:33 -0300 From: Marcelo Tosatti Message-ID: <20120809190633.GF20889@amt.cnet> References: <5024011F.2020200@msgid.tls.msk.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5024011F.2020200@msgid.tls.msk.ru> Subject: Re: [Qemu-devel] TSC in qem[-kvm] 1.1+ and in-kernel irqchip List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Tokarev , "@amt.cnet"@amt.cnet Cc: qemu-devel , Avi Kivity , KVM list , Gerd Hoffmann On Thu, Aug 09, 2012 at 10:27:43PM +0400, Michael Tokarev wrote: > As a follow-up to the patch "tsc: use kvmclock for > calibration". > > There's another problem reported by several users. > The sympthom is that grub does not show boot menu, > it boots default entry right away without any pause. > > After quite some debugging it turned out to be > TSC issue. Grub uses tsc for its timeout handling. > When setting timeout to some very large value > (10000), I can see the counter is ticking backwards > at a very high speed, ticking from 10000 to 0 in > about 5 seconds. > > Running kvm -cpu host,-tsc forces grub to use > rtc clocksource, and the problem goes away. > > The most interesting thing is that this is a > problem new for qemu-kvm 1.1 (and is still > present in current git), 1.0 version had no > such issue. And it only happens when in-kernel > irqchip is enabled -- running with -no-kvm-irqchip > also fixes the grub problem, so that tsc starts > counting "correctly" for grub again. > > Gerd mentioned mis-calibration of bios timer > when host is heavily loaded. I tested grub on > my workstation today which was completely idle, > no other processes running. > > It smells like a bug in kvm somewhere. And it > happens when I explicitly pin kvm to a single > core, so tsc should tick correctly even if its > syncronization is broken between cores. > > Current qemu also has this issue (since 1.1), > since it also has in-kernel irqchip support now. > > FWIW, here's the TSC calibration routine from > grub: > > /* Calibrate the TSC based on the RTC. */ > static void > calibrate_tsc (void) > { > /* First calibrate the TSC rate (relative, not absolute time). */ > grub_uint64_t start_tsc; > grub_uint64_t end_tsc; > > start_tsc = grub_get_tsc (); > grub_pit_wait (0xffff); > end_tsc = grub_get_tsc (); > > tsc_ticks_per_ms = grub_divmod64 (end_tsc - start_tsc, 55, 0); > } Emulation of grub_pit_wait sequence by in-kernel PIT is probably broken. QEMU PIT emulation is also affected by miscalibration. Please provide steps to reproduce.