From owner-freebsd-current@FreeBSD.ORG Wed Sep 9 20:18:55 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B631810657AE for ; Wed, 9 Sep 2009 20:18:55 +0000 (UTC) (envelope-from nox@jelal.kn-bremen.de) Received: from smtp.kn-bremen.de (gelbbaer.kn-bremen.de [78.46.108.116]) by mx1.freebsd.org (Postfix) with ESMTP id 6C3B88FC19 for ; Wed, 9 Sep 2009 20:18:55 +0000 (UTC) Received: by smtp.kn-bremen.de (Postfix, from userid 10) id 0BC001E0037F; Wed, 9 Sep 2009 22:18:54 +0200 (CEST) Received: from triton8.kn-bremen.de (noident@localhost [127.0.0.1]) by triton8.kn-bremen.de (8.14.3/8.14.3) with ESMTP id n89KFvHv095785; Wed, 9 Sep 2009 22:15:57 +0200 (CEST) (envelope-from nox@triton8.kn-bremen.de) Received: (from nox@localhost) by triton8.kn-bremen.de (8.14.3/8.14.3/Submit) id n89KFvIP095784; Wed, 9 Sep 2009 22:15:57 +0200 (CEST) (envelope-from nox) From: Juergen Lock Date: Wed, 9 Sep 2009 22:15:56 +0200 To: Ryan Stone Message-ID: <20090909201556.GA95426@triton8.kn-bremen.de> References: <52d4a3890908250321u746e5757u136030bcbc19208d@mail.gmail.com> <4A93BF0C.8040601@web.de> <20090826221001.GA1070@triton8.kn-bremen.de> <4A96C8D9.6070804@web.de> <20090829211848.GA59305@triton8.kn-bremen.de> <4A9B800F.1040209@web.de> <20090831212723.GA32448@triton8.kn-bremen.de> <20090901201248.GA60123@triton8.kn-bremen.de> <20090907205955.GA91866@triton8.kn-bremen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Cc: Juergen Lock , Avi Kivity , qemu-devel@nongnu.org, freebsd-current@freebsd.org, Jan Kiszka , Mohammed Gamal Subject: Re: FreeBSD timing issues and qemu (was: Re: [Qemu-devel] Re: Breakage with local APIC routing) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2009 20:18:55 -0000 On Mon, Sep 07, 2009 at 10:17:23PM -0400, Ryan Stone wrote: > I'm not entirely clear on why it's done this way, but the timer is run at > twice hz for statistics-gathering purposes*. CPU usage statistics gathering > is driven off of the timer interrupt. Running the timer at twice hz may be > an attempt to eliminate clock-aliasing problems; if so, it's a poor way of > doing so. In any case, seeing interrupts come in at twice hz is expected > behaviour. This means that the guest will be requesting a timer interrupt > rate of twice the granularity that the host's scheduler can support; this > may be the cause of your other timing problems(although I have a hard time > imagining how). > Yes, this is the first issue I reported, and it causes e.g. a FreeBSD 7 guest on a 7 host to sleep ~4s on a `time sleep 2'. (unless when I disable apic as I said.) > This timer is twice hz behaviour has existed at least since FreeBSD 6.1, so > I can't explain why you see the new behaviour between 7 and 8. You do have > hz set to 1000 on both the guest and host when running 7? > Yes, and the behaviour on 8 is in addition to the guest expecting clock irqs at 2000 Hz, i.e. on 8 the guest gets only around 500 Hz with -clock unix instead of ~1000 Hz on a 7 host, and `time sleep 2' then consequently sleeps ~8s. > * Actually, from looking at the code the behaviour is dynamic. If hz >= > 1500, the timer interrupt rate is set to hz. If 750 <= hz < 1500, the timer > interrupt rate is set to 2 * hz. If hz < 750, the timer interrupt rate is > set to 4 * hz. Aha, so another way to get around the first issue would be to run at least the host with HZ=2000... Worth a try, tho I suspect it won't help the additional rate halving on 8, unless maybe to use even HZ=4000. Oh well... Juergen