Date: Fri, 8 May 2009 11:45:16 +1000 (EST) From: Bruce Evans <brde@optusnet.com.au> To: Dmitry Chagin <dchagin@FreeBSD.org> Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r191883 - head/sys/compat/linux Message-ID: <20090508111302.C1275@besplex.bde.org> In-Reply-To: <200905071424.n47EOos1058369@svn.freebsd.org> References: <200905071424.n47EOos1058369@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <time.h> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090508111302.C1275>