From owner-freebsd-stable@FreeBSD.ORG Thu Mar 10 20:42:18 2005 Return-Path: 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 7CC6016A4CE for ; Thu, 10 Mar 2005 20:42:18 +0000 (GMT) Received: from smtp811.mail.sc5.yahoo.com (smtp811.mail.sc5.yahoo.com [66.163.170.81]) by mx1.FreeBSD.org (Postfix) with SMTP id 06C5343D1D for ; Thu, 10 Mar 2005 20:42:18 +0000 (GMT) (envelope-from noackjr@alumni.rice.edu) Received: from unknown (HELO optimator.noacks.org) (noacks@swbell.net@70.240.225.210 with login) by smtp811.mail.sc5.yahoo.com with SMTP; 10 Mar 2005 20:42:17 -0000 Received: from localhost (localhost [127.0.0.1]) by optimator.noacks.org (Postfix) with ESMTP id 3BDDE62CF; Thu, 10 Mar 2005 14:42:16 -0600 (CST) Received: from optimator.noacks.org ([127.0.0.1]) by localhost (optimator.noacks.org [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 47734-18-2; Thu, 10 Mar 2005 14:42:13 -0600 (CST) Received: from [127.0.0.1] (optimator [192.168.1.11]) by optimator.noacks.org (Postfix) with ESMTP id C830162A1; Thu, 10 Mar 2005 14:42:13 -0600 (CST) Message-ID: <4230B125.9070005@alumni.rice.edu> Date: Thu, 10 Mar 2005 14:42:13 -0600 From: Jon Noack User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Pete French References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: amavisd-new at noacks.org cc: stable@FreeBSD.ORG Subject: Re: Just a sanity check before I sumbit a buig report X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: noackjr@alumni.rice.edu List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Mar 2005 20:42:18 -0000 Pete French wrote: >>'sysctl kern.clockrate' will return this information if you don't want to >>write a program to do it for you :) > > I was just using the code from time(1). Inteesring though - heres the > output: > > kern.clockrate: { hz = 100, tick = 10000, tickadj = 5, profhz = 100, stathz = 100 } > > So that thinks stathz is 100, but sysconf(_SC_CLK_TCK) is returning 128! > >>What are the two machines? stathz is 128 on i386, 100 on sparc64, and 130 >>on amd64. Or thats the defaults at least. > > These are all i386 machines - I have a number of them, all running 4.11. > I can take the same a.out and run it on all of them - on some both > numbers are 128, on other the numbers are 100 and 128. > > If I go to one where both the calls return 128 though, the output > of 'sysctl kern.clockrate' is this: > > kern.clockrate: { hz = 100, tick = 10000, tickadj = 5, profhz = 1024, stathz = 128 } > > So, it looks like theres a bug in sysconf(_SC_CLK_TCK) possibly ? because > it seems to be always returning 128, regardless of the value of stathz > as returned by 'sysctl kern.clockrate' > > I can reproduce this on a number of machines BTW - the only things they have in > common is that I wrote their kernel config files at various points in time... I infer from your kern.clockrate output that you are running 4.x. Why does sysconf(_SC_CLK_TCK) always returns 128? Check out sysconf() in src/lib/libc/gen/sysconf.c (lines 83-84 of rev. 1.10): ********************************************************************** case _SC_CLK_TCK: return (CLK_TCK); ********************************************************************** CLK_TCK is defined in src/include/time.h (line 52 of rev. 1.15): ********************************************************************** #define CLK_TCK _BSD_CLK_TCK_ ********************************************************************** _BSD_CLK_TCK_ is defined in src/sys/i386/include/ansi.h (line 101 of rev. 1.18.2.4): ********************************************************************** #define _BSD_CLK_TCK_ 128 ********************************************************************** So on i386 (and FreeBSD 4.x), sysconf(_SC_CLK_TCK) will always return 128. If you look in src/sys/alpha/include/ansi.h, you'll see that on alpha it will always return 100. To determine how stathz can vary, we'll have to dig deeper. Check out initclocks() in src/sys/kern/kern_clock.c (lines 196-213 of rev. 1.105.2.11): ********************************************************************** /* * Set divisors to 1 (normal case) and let the machine-specific * code do its bit. */ psdiv = pscnt = 1; cpu_initclocks(); #ifdef DEVICE_POLLING init_device_poll(); #endif /* * Compute profhz/stathz, and fix profhz if needed. */ i = stathz ? stathz : hz; if (profhz == 0) profhz = i; psratio = profhz / i; ********************************************************************** stathz and profhz are originally set by cpu_initclocks() (which is MD). If they are not set at this point, hz is used. This must be the case for some of your machines as both stathz and profhz equal hz. So why aren't stathz and profhz being set earlier? Check out cpu_initclocks() in src/sys/i386/isa/clock.c (lines 995-1008 of rev. 1.149.2.6): ********************************************************************** if (statclock_disable) { /* * The stat interrupt mask is different without the * statistics clock. Also, don't set the interrupt * flag which would normally cause the RTC to generate * interrupts. */ stat_imask = HWI_MASK | SWI_MASK; rtc_statusb = RTCSB_24HR; } else { /* Setting stathz to nonzero early helps avoid races. */ stathz = RTC_NOPROFRATE; profhz = RTC_PROFRATE; } ********************************************************************** If you look in src/sys/isa/rtc.h, you'll see that RTC_NOPROFRATE=128 and RTC_PROFRATE=1024. The only way stathz and profhz will not be set here is if statclock_disable is true. Where is statclock_disable set? Check out apm_attach() in src/sys/i386/apm/apm.c (lines 1032-1033 of rev. 1.114.2.6): ********************************************************************** if (flags & 0x20) statclock_disable = 1; ********************************************************************** Thus, you must have "device apm0 flags 0x20" or something similar in your kernel config file for you to get stathz and profhz as 100. apm is disabled in GENERIC, so by default this is not a problem; apm_attach won't be called if apm is disabled, so the fact that GENERIC includes "flags 0x20" is irrelevant. Jon