From owner-freebsd-current@FreeBSD.ORG Thu Sep 10 17:50:18 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 D0BB8106566B for ; Thu, 10 Sep 2009 17:50:18 +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 606728FC19 for ; Thu, 10 Sep 2009 17:50:18 +0000 (UTC) Received: by smtp.kn-bremen.de (Postfix, from userid 10) id 4CFAA1E0038A; Thu, 10 Sep 2009 19:50:17 +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 n8AHkfHE030922; Thu, 10 Sep 2009 19:46:41 +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 n8AHketJ030921; Thu, 10 Sep 2009 19:46:40 +0200 (CEST) (envelope-from nox) From: Juergen Lock Date: Thu, 10 Sep 2009 19:46:40 +0200 To: Luigi Rizzo Message-ID: <20090910174640.GA30706@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> <20090909204616.GB93761@onelab2.iet.unipi.it> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090909204616.GB93761@onelab2.iet.unipi.it> 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: Thu, 10 Sep 2009 17:50:19 -0000 On Wed, Sep 09, 2009 at 10:46:16PM +0200, Luigi Rizzo wrote: > On Mon, Sep 07, 2009 at 10:59:55PM +0200, Juergen Lock wrote: > > [I'm copying freebsd-current@FreeBSD.org because ppl there might know > > more about this...] > > > > qemu on FreeBSD hosts used to be able to run a (FreeBSD at least) guest > > with the same HZ as the host (like, 1000) with (mostly) proper timing > > once, but no longer. :( It seems there are two problems involved: > > > > a) use of apic seems to cause the clock irq rate to be doubled to 2 * HZ > > (can anyone explain why?), i.e. a FreeBSD 7 guest on a FreeBSD 7 host > > only gets proper timing after setting hint.apic.0.disabled=1 via the > > loader. (as can be verified by `vmstat -i' and `time sleep 2' in an > > installed guest or via the fixit->cdrom/dvd shell on a FreeBSD livefs > > or dvd1 iso.) > > > > b) qemu running on FreeBSD 8 hosts (and most likely head) has the > > additional problem of running its timers only at HZ/2 when using > > setitimer(2) (called `-clock unix' in qemu), as seen below. (as also > > this problem in 8.x is caused by the bug i described here yesterday: > > http://lists.freebsd.org/pipermail/freebsd-current/2009-September/011393.html > > In qeumu, the setitimer call (in file vl.c) has a timeout of 1 tick > which maps to callout_reset(..., 1, ...) and because (due to the bug) > 8.x processes callouts 1 tick late, this effectively halves the clock rate. > Thanx for the pointer! The proposed patch in that post didn't make a different here tho, guest still sees only half host HZ clock irq rate. (i.e. ~500 Hz.) Here is the patch I used, to make sure I patched what you meant... Index: sys/kern/kern_timeout.c @@ -323,7 +323,7 @@ softclock(void *arg) steps = 0; cc = (struct callout_cpu *)arg; CC_LOCK(cc); - while (cc->cc_softticks != ticks) { + while (cc->cc_softticks-1 != ticks) { /* * cc_softticks may be modified by hard clock, so cache * it while we work on a given bucket. > > seen below, timer_settime(2) aka `-clock dynticks' in qemu behaves > > even worse, but that is similarly true on FreeBSD 7 which is why > > I removed the patch that enabled that from our qemu port(s) a few > > days ago.) And the only reason FreeBSD 8 guests are usually less > > affected by these problems is they now reduce their HZ to 100 when > > they detect being run in a VM. (which makes sense for other reasons > > as well, don't get me wrong... but of course doesn't help when the > > host is running with HZ=100 too.) > > cheers > luigi Cheers, Juergen