svn commit: r237434 - in head/lib/libc: amd64/sys gen i386/sys include sys

Konstantin Belousov kostikbel at gmail.com
Fri Jun 22 07:48:37 UTC 2012


On Fri, Jun 22, 2012 at 09:34:56AM +0200, Marius Strobl wrote:
> On Fri, Jun 22, 2012 at 07:13:31AM +0000, Konstantin Belousov wrote:
> > Author: kib
> > Date: Fri Jun 22 07:13:30 2012
> > New Revision: 237434
> > URL: http://svn.freebsd.org/changeset/base/237434
> > 
> > Log:
> >   Use struct vdso_timehands data to implement fast gettimeofday(2) and
> >   clock_gettime(2) functions if supported. The speedup seen in
> >   microbenchmarks is in range 4x-7x depending on the hardware.
> >   
> >   Only amd64 and i386 architectures are supported. Libc uses rdtsc and
> >   kernel data to calculate current time, if enabled by kernel.
> 
> I don't know much about x86 CPUs but is my understanding correct
> that TSCs are not synchronized in any way across CPUs, i.e.
> reading it on different CPUs may result in time going backwards
> etc., which is okay for this application though?

Generally speaking, tsc state among different CPU after boot is not
synchronized, you are right.

Kernel has somewhat doubtful test which verifies whether the after-boot
state of tsc looks good. If the test fails, TSC is not enabled by
default as timecounter, and then usermode follows kernel policy and
falls back to slow syscall. So we err on the safe side.
I tested this on Core i7 2xxx, where the test (usually) passes.

The test we currently have fails for me at least on single-package
Nehalems, where the counter should be located on uncore part. This
indicates some brokeness in the code, but I did not investigated the
cause.

The code can be developed which adjusts tsc msrs to be in sync. Or, rtdscp
instruction can be used, which allow to handle counter skew in usermode
in race-free manner.

While you are there. do you have comments about sparc64 TICK counter ?
On SMP, the counter of BSP is used by IPI. Is it unavoidable ?
-------------- 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/20120622/ed97d77d/attachment.pgp


More information about the svn-src-all mailing list