Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Jul 2009 17:07:39 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        cvs-src-old@freebsd.org
Subject:   cvs commit: src/sys/cddl/dev/dtrace/amd64 dtrace_subr.c src/sys/cddl/dev/dtrace/i386 dtrace_subr.c
Message-ID:  <200907151708.n6FH80dW019498@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
avg         2009-07-15 17:07:39 UTC

  FreeBSD src repository

  Modified files:
    sys/cddl/dev/dtrace/amd64 dtrace_subr.c 
    sys/cddl/dev/dtrace/i386 dtrace_subr.c 
  Log:
  SVN rev 195710 on 2009-07-15 17:07:39Z by avg
  
  dtrace_gethrtime: improve scaling of TSC ticks to nanoseconds
  
  Currently dtrace_gethrtime uses formula similar to the following for
  converting TSC ticks to nanoseconds:
  rdtsc() * 10^9 / tsc_freq
  The dividend overflows 64-bit type and wraps-around every 2^64/10^9 =
  18446744073 ticks which is just a few seconds on modern machines.
  
  Now we instead use precalculated scaling factor of
  10^9*2^N/tsc_freq < 2^32 and perform TSC value multiplication separately
  for each 32-bit half.  This allows to avoid overflow of the dividend
  described above.
  The idea is taken from OpenSolaris.
  This has an added feature of always scaling TSC with invariant value
  regardless of TSC frequency changes. Thus the timestamps will not be
  accurate if TSC actually changes, but they are always proportional to
  TSC ticks and thus monotonic. This should be much better than current
  formula which produces wildly different non-monotonic results on when
  tsc_freq changes.
  
  Also drop write-only 'cp' variable from amd64 dtrace_gethrtime_init()
  to make it identical to the i386 twin.
  
  PR:             kern/127441
  Tested by:      Thomas Backman <serenity@exscape.org>
  Reviewed by:    jhb
  Discussed with: current@, bde, gnn
  Silence from:   jb
  Approved by:    re (gnn)
  MFC after:      1 week
  
  Revision  Changes    Path
  1.3       +48 -3     src/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
  1.3       +47 -1     src/sys/cddl/dev/dtrace/i386/dtrace_subr.c



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907151708.n6FH80dW019498>