qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Michael Tokarev <mjt@tls.msk.ru>, "@amt.cnet"@amt.cnet
Cc: qemu-devel <qemu-devel@nongnu.org>, Avi Kivity <avi@redhat.com>,
	KVM list <kvm@vger.kernel.org>, Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] TSC in qem[-kvm] 1.1+ and in-kernel irqchip
Date: Thu, 9 Aug 2012 16:06:33 -0300	[thread overview]
Message-ID: <20120809190633.GF20889@amt.cnet> (raw)
In-Reply-To: <5024011F.2020200@msgid.tls.msk.ru>

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.

  reply	other threads:[~2012-08-09 19:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-09 18:27 [Qemu-devel] TSC in qem[-kvm] 1.1+ and in-kernel irqchip Michael Tokarev
2012-08-09 19:06 ` Marcelo Tosatti [this message]
     [not found]   ` <20120809204748.GA32346@amt.cnet>
2012-08-09 21:36     ` Michael Tokarev
2012-08-10  7:33 ` Gleb Natapov
2012-08-10  9:24   ` Michael Tokarev
2012-08-12  8:10     ` Gleb Natapov
2012-08-12  9:24       ` Michael Tokarev
2012-08-13 13:07         ` Jan Kiszka
2012-08-13 13:16           ` Michael Tokarev
2012-08-13 13:41             ` Jan Kiszka
2012-08-13 18:18             ` [Qemu-devel] [PATCH uq/master] kvm: i8254: Finish time conversion fix Jan Kiszka
2012-08-13 18:40               ` Michael Tokarev
2012-08-14  7:41                 ` Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120809190633.GF20889@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc="@amt.cnet"@amt.cnet \
    --cc=avi@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).