Date: Sun, 10 May 2009 00:45:59 +0400 From: Chagin Dmitry <dchagin@freebsd.org> To: Bruce Evans <brde@optusnet.com.au> 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: <20090509204559.GA4626@dchagin.static.corbina.ru> In-Reply-To: <20090508111302.C1275@besplex.bde.org> References: <200905071424.n47EOos1058369@svn.freebsd.org> <20090508111302.C1275@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 08, 2009 at 11:45:16AM +1000, Bruce Evans wrote: > On Thu, 7 May 2009, Dmitry Chagin wrote: >=20 > > Log: > > Linux exports HZ value to user space via AT_CLKTCK auxiliary vector en= try, > > which is available for Glibc as sysconf(_SC_CLK_TCK). If AT_CLKTCK ent= ry is > > not exported, Glibc uses 100. >=20 > This cannot work for older applications/glibc's that have CLK_TCK hard-co= ded. >=20 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. >=20 > 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 actua= lly > 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). >=20 > > Modified: head/sys/compat/linux/linux_misc.c > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- head/sys/compat/linux/linux_misc.c Thu May 7 13:49:48 2009 (r19188= 2) > > +++ head/sys/compat/linux/linux_misc.c Thu May 7 14:24:50 2009 (r19188= 3) > > @@ -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_TC= K)) > > +#define CONVTCK(r) (r.tv_sec * hz + r.tv_usec / (1000000 / hz)) >=20 > hz has very little to do with statistics clock ticks. The frequency of t= he > 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. >=20 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 :-(. >=20 I will try to make the hard-coded CLK_TCK support. It will depend on value of compat.linux.osrelease (2.2 I guess). --=20 Have fun! chd --HcAYCG3uE/tztfnV Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.10 (FreeBSD) iEYEARECAAYFAkoF64cACgkQ0t2Tb3OO/O2wcgCdH1PhcLiJT9gDouR/lB38J4qT J20An3FOzMSWCi8G3+kRGv9E3tGTDB3T =sW/f -----END PGP SIGNATURE----- --HcAYCG3uE/tztfnV--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090509204559.GA4626>