From owner-freebsd-stable@FreeBSD.ORG Wed Dec 7 07:17:26 2005 Return-Path: X-Original-To: freebsd-stable@freebsd.org Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0399116A41F for ; Wed, 7 Dec 2005 07:17:26 +0000 (GMT) (envelope-from PeterJeremy@optushome.com.au) Received: from mail09.syd.optusnet.com.au (mail09.syd.optusnet.com.au [211.29.132.190]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7B17043D53 for ; Wed, 7 Dec 2005 07:17:24 +0000 (GMT) (envelope-from PeterJeremy@optushome.com.au) Received: from cirb503493.alcatel.com.au (c220-239-19-236.belrs4.nsw.optusnet.com.au [220.239.19.236]) by mail09.syd.optusnet.com.au (8.12.11/8.12.11) with ESMTP id jB77HDUB014892 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Wed, 7 Dec 2005 18:17:14 +1100 Received: from cirb503493.alcatel.com.au (localhost.alcatel.com.au [127.0.0.1]) by cirb503493.alcatel.com.au (8.12.10/8.12.10) with ESMTP id jB77HCHh063963; Wed, 7 Dec 2005 18:17:13 +1100 (EST) (envelope-from pjeremy@cirb503493.alcatel.com.au) Received: (from pjeremy@localhost) by cirb503493.alcatel.com.au (8.12.10/8.12.9/Submit) id jB77HAUG063962; Wed, 7 Dec 2005 18:17:10 +1100 (EST) (envelope-from pjeremy) Date: Wed, 7 Dec 2005 18:17:10 +1100 From: Peter Jeremy To: Kevin Oberman Message-ID: <20051207071710.GQ32006@cirb503493.alcatel.com.au> References: <20051205124910.GC90806@over-yonder.net> <20051205181552.2D7AB5D04@ptavv.es.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20051205181552.2D7AB5D04@ptavv.es.net> User-Agent: Mutt/1.4.2.1i X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc Cc: kama , freebsd-stable@freebsd.org, "Matthew D. Fuller" Subject: Re: cpu-timer rate X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Dec 2005 07:17:26 -0000 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