svn commit: r191883 - head/sys/compat/linux

Chagin Dmitry dchagin at freebsd.org
Sat May 9 20:46:09 UTC 2009


On Fri, May 08, 2009 at 11:45:16AM +1000, Bruce Evans wrote:
> 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.
> 

yes, I know. Glibc versions prior to 2.2.1 uses hardcoded CLK_TCK value.


> >  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.
> 

Thank you!

> 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

hmm, r189362. hz exported to user space via AT_CLKTCK.

> 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 :-(.
> 

I will try to make the hard-coded CLK_TCK support. It will depend
on value of compat.linux.osrelease (2.2 I guess).


-- 
Have fun!
chd
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/svn-src-all/attachments/20090509/42cfbe05/attachment.pgp


More information about the svn-src-all mailing list