From: Luigi Rizzo <rizzo@iet.unipi.it>
To: Juergen Lock <nox@jelal.kn-bremen.de>
Cc: Mohammed Gamal <m.gamal005@gmail.com>,
freebsd-current@freebsd.org, Jan Kiszka <jan.kiszka@web.de>,
qemu-devel@nongnu.org, Avi Kivity <avi@qumranet.com>
Subject: Re: FreeBSD timing issues and qemu (was: Re: [Qemu-devel] Re: Breakage with local APIC routing)
Date: Thu, 10 Sep 2009 21:08:00 +0200 [thread overview]
Message-ID: <20090910190800.GA14191@onelab2.iet.unipi.it> (raw)
In-Reply-To: <20090910174640.GA30706@triton8.kn-bremen.de>
On Thu, Sep 10, 2009 at 07:46:40PM +0200, Juergen Lock wrote:
> 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.
>
as mentioned in the followup message in that thread,
you also need this change in callout_tick()
mtx_lock_spin_flags(&cc->cc_lock, MTX_QUIET);
- for (; (cc->cc_softticks - ticks) < 0; cc->cc_softticks++) {
+ for (; (cc->cc_softticks - ticks) <= 0; cc->cc_softticks++) {
bucket = cc->cc_softticks & callwheelmask;
cheers
luigi
next prev parent reply other threads:[~2009-09-10 19:02 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-11 14:28 [Qemu-devel] Breakage with local APIC routing Johannes Schindelin
2008-08-13 8:14 ` [Qemu-devel] " Jan Kiszka
2008-08-13 9:08 ` Jan Kiszka
2008-08-17 15:00 ` Johannes Schindelin
2008-08-17 15:28 ` Johannes Schindelin
2008-08-17 16:52 ` Jan Kiszka
2009-08-13 16:21 ` Johannes Schindelin
2009-08-25 6:56 ` Jan Kiszka
2009-08-25 8:24 ` Mohammed Gamal
2009-08-25 8:59 ` Jan Kiszka
2009-08-25 9:09 ` Mohammed Gamal
2009-08-25 9:33 ` Jan Kiszka
2009-08-25 10:16 ` Mohammed Gamal
2009-08-25 10:21 ` Mohammed Gamal
2009-08-25 10:38 ` Jan Kiszka
2009-08-26 22:10 ` Juergen Lock
2009-08-27 17:56 ` Jan Kiszka
2009-08-29 21:18 ` Juergen Lock
2009-08-31 7:47 ` Jan Kiszka
2009-08-31 21:27 ` Juergen Lock
2009-09-01 20:12 ` Juergen Lock
2009-09-07 20:59 ` FreeBSD timing issues and qemu (was: Re: [Qemu-devel] Re: Breakage with local APIC routing) Juergen Lock
2009-09-08 2:17 ` Ryan Stone
2009-09-09 20:15 ` Juergen Lock
2009-09-09 20:39 ` Ryan Stone
2009-09-09 20:46 ` Luigi Rizzo
2009-09-10 17:46 ` Juergen Lock
2009-09-10 19:08 ` Luigi Rizzo [this message]
2009-09-10 20:44 ` Juergen Lock
2009-09-11 15:22 ` John Baldwin
2009-09-11 17:03 ` Luigi Rizzo
2009-09-11 17:01 ` John Baldwin
2009-09-12 15:48 ` Luigi Rizzo
2009-08-25 11:48 ` [Qemu-devel] Re: Breakage with local APIC routing Johannes Schindelin
2009-08-25 12:31 ` Jan Kiszka
2009-08-25 13:36 ` Johannes Schindelin
2009-08-26 7:31 ` Jan Kiszka
2009-08-26 9:27 ` Avi Kivity
2009-08-27 18:07 ` Jan Kiszka
2008-08-17 17:32 ` [Qemu-devel] " Stefan Weil
2008-08-17 18:58 ` [Qemu-devel] " Jan Kiszka
2008-08-17 20:40 ` Stefan Weil
2008-08-17 20:23 ` [Qemu-devel] " Aurelien Jarno
2008-08-17 21:10 ` Stefan Weil
2008-08-18 14:27 ` Anthony Liguori
2008-08-17 21:14 ` [Qemu-devel] " 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=20090910190800.GA14191@onelab2.iet.unipi.it \
--to=rizzo@iet.unipi.it \
--cc=avi@qumranet.com \
--cc=freebsd-current@freebsd.org \
--cc=jan.kiszka@web.de \
--cc=m.gamal005@gmail.com \
--cc=nox@jelal.kn-bremen.de \
--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).