From owner-svn-src-head@FreeBSD.ORG Fri May 8 01:45:21 2009 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0432F106564A; Fri, 8 May 2009 01:45:21 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail06.syd.optusnet.com.au (mail06.syd.optusnet.com.au [211.29.132.187]) by mx1.freebsd.org (Postfix) with ESMTP id 946F48FC0A; Fri, 8 May 2009 01:45:20 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c122-106-172-38.carlnfd1.nsw.optusnet.com.au [122.106.172.38]) by mail06.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id n481jH50015891 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 8 May 2009 11:45:18 +1000 Date: Fri, 8 May 2009 11:45:16 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Dmitry Chagin In-Reply-To: <200905071424.n47EOos1058369@svn.freebsd.org> Message-ID: <20090508111302.C1275@besplex.bde.org> References: <200905071424.n47EOos1058369@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r191883 - head/sys/compat/linux X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 May 2009 01:45:21 -0000 On Thu, 7 May 2009, Dmitry Chagin wrote: > Log: > Linux exports HZ value to user space via AT_CLKTCK auxiliary vector entry, > which is available for Glibc as sysconf(_SC_CLK_TCK). If AT_CLKTCK entry is > not exported, Glibc uses 100. This cannot work for older applications/glibc's that have CLK_TCK hard-coded. > linux_times() shall use the value that is exported to user space. FreeBSD handles the problem by "exporting" the old constant value of CLK_TCK (128) although this value has always been bogus and the "export" is actually hard-coded into libc:sysconf() (and into except in post-2001 pure-POSIX case -- in particular, the bogus macro CLK_TCK is still hard- coded to the bogus value 128 in the BSD_VISIBLE case to avoid breaking bogus BSD applications that use it). > Modified: head/sys/compat/linux/linux_misc.c > ============================================================================== > --- head/sys/compat/linux/linux_misc.c Thu May 7 13:49:48 2009 (r191882) > +++ head/sys/compat/linux/linux_misc.c Thu May 7 14:24:50 2009 (r191883) > @@ -659,9 +659,7 @@ struct l_times_argv { > l_clock_t tms_cstime; > }; > > -#define CLK_TCK 100 /* Linux uses 100 */ > - > -#define CONVTCK(r) (r.tv_sec * CLK_TCK + r.tv_usec / (1000000 / CLK_TCK)) > +#define CONVTCK(r) (r.tv_sec * hz + r.tv_usec / (1000000 / hz)) hz has very little to do with statistics clock ticks. The frequency of the statistics clock in FreeBSD is given by stathz. stathz will normally only equal hz if the statistics clock is the same as the scheduling clock. stathz is a bogus value too since the clock most relevant for them is the cputicker and the statistics clock is only used to divide them up. Anyway, this patch is backwards. The bug was that the value exported to user space didn't match the value here. The value cannot be changed in either FreeBSD or Linux without breaking compatibility. It is even harder to change in emulators than in a full O/S distribution since the full distribution can more reasonably drop support for all old applications. A correct emulator would have to have an array of values for each "constant" sysconf() value with the arrays index by the O/S version and maybe the libc version being emulated :-(. Bruce