Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Dec 2005 18:17:10 +1100
From:      Peter Jeremy <PeterJeremy@optushome.com.au>
To:        Kevin Oberman <oberman@es.net>
Cc:        kama <kama@pvp.se>, freebsd-stable@freebsd.org, "Matthew D. Fuller" <fullermd@over-yonder.net>
Subject:   Re: cpu-timer rate
Message-ID:  <20051207071710.GQ32006@cirb503493.alcatel.com.au>
In-Reply-To: <20051205181552.2D7AB5D04@ptavv.es.net>
References:  <20051205124910.GC90806@over-yonder.net> <20051205181552.2D7AB5D04@ptavv.es.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 2005-Dec-05 10:15:52 -0800, Kevin Oberman wrote:
>> On Mon, Dec 05, 2005 at 09:42:08AM +0100 I heard the voice of
>> kama, and lo! it spake thus:
>> > 
>> > I appreciate that you took time to answer about the different
>> > clocks. But that does not answer why vmstat -i shows a rate of 2000
>> > when I have set the hz to 1000.
>> 
>> Because the rate is always twice hz.
>
>While I will concede that I have no explanation, but on all of my systems
>rate = HZ +/-1. I have never seen a case where rate/2 = HZ.

Basically, it depends on what clock(s) your kernel is using.

Traditionally, FreeBSD/i386 uses the one of the i8254 counters to
generate hz (on irq0) and the RTC to generate profhz/stathz (on irq8).
In this case, the rate on those interrupts should match the values
reported by kern.clockrate.  On SMP machines, this approach is fairly
expensive because the interrupts need to be forwarded to all CPUs
using IPIs.

In early February, jhb implemented an alternative approach using the
local APIC clock (sys/i386/i386/local_apic.c v1.13 and other files).
Since every CPU has a LAPIC, every CPU gets its own clock interrupts
without needing IPIs.  The downside is that there's only a single
LAPIC so a single hardware clock interrupt needs to generate separate
(and independent) hz/tick and stathz/profhz clocks.

Since the clocks need to be independent (to make process statistics
meaningful), this implies that the hardware (LAPIC) clock (cpu0) needs
to be faster than hz.  The original commit ran LAPIC at hz*3 but this
was later changed to hz*2 to reduce overheads.

-- 
Peter Jeremy



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051207071710.GQ32006>