public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: Gregory Haskins <GHaskins-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: PIT weirdness
Date: Tue, 22 May 2007 14:39:43 +0300	[thread overview]
Message-ID: <4652D67F.6090609@qumranet.com> (raw)
In-Reply-To: <46529AC80200005A000249C3-Igcdv/6uVdMHoYOw/+koYqIwWpluYiW7@public.gmane.org>

Gregory Haskins wrote:
> Hi all, 
>   I found some strangeness with the PIT emulation while working on this APIC code that I can't quite explain.  So I thought I would ping the list to see if anyone knowledgable can tell me what is happening. 
>  
> I am seeing two interrupts coming from the PIT for every SIGALARM.  The second interrupt normally gets aliased behind the single vector in the PIC/APIC unless you turn on the TDF feature of QEMU.  I also wrote a "fix" for the in-kernel APIC so it could queue deeper that 1-2 vectors.  In either case, linux now sees time as double time.  Ok, so something is off. 
>  
> Normally I see the PIT ticking at 125Hz.  With the fixes on, I see double that (250Hz).  What I can't explain is: if I look at the PIT registers, "count" is programmed to 4773.  If I do the math correctly, this translates into a 4ms period, or 250Hz. 
>  
> Ok, so it looks like the PIT is *supposed* to be ticking at 250Hz?  If so, why does the system work correctly if every other interrupt is dropped?  This somewhat makes sense because I think Linux uses 250Hz as the default, IIUC (this is a 2.6.16.21 guest) 
>  
> What I figure is that someone hacked in some other compensating logic somewhere else in QEMU so that time passes normally even though jiffies are half speed.  But I would just like someone to sanity check what I described above before attacking from that angle.  Anyone?

Most likely the guest PIT is supposed to tick at 250Hz.  See you .config
to make sure.

There was a fix that was committed to (kvm's) qemu some time ago which
is probably related:

commit 654501f79be082925c623806c00a27021565035f
Author: He, Qing <qing.he-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Date:   Sat Apr 28 09:44:53 2007 +0300

    kvm: qemu: fix PIC interrupt delivery in Qemu when LAPIC is enabled

    Current interrupt logic in Qemu unconditionally checks pending irqs on
    PIC after checking local APIC, however, this is problematic.
        On common platform, PIC is usually connected to the LINT0 of
    local APIC. In this way when local APIC is disabled, this pin behaves
    like INTR. But when local APIC is enabled, its behavior can be
    determined by LVT_LINT0: PIC should only deliver normal irq only when
    `external interrupt' delivery mode is set.
        x86_64 Linux kernel uses PIT->PIC->LINT0 as NMI source when
    performance counters are not available, but the logic described above
    treats the NMI as normal interrupt which yields a 2x faster global timer
    because an additional timer interrupt is injected on every tick. This
    patch fixes this issue.

    Signed-off-by: Qing He <qing.he-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>



-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

      parent reply	other threads:[~2007-05-22 11:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <46529AC50200005A000249C0@mcclure.wal.novell.com>
2007-05-22 11:24 ` PIT weirdness Gregory Haskins
     [not found]   ` <46529AC80200005A000249C3-Igcdv/6uVdMHoYOw/+koYqIwWpluYiW7@public.gmane.org>
2007-05-22 11:39     ` Avi Kivity [this message]

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=4652D67F.6090609@qumranet.com \
    --to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
    --cc=GHaskins-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.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