summaryrefslogtreecommitdiffstats
path: root/sys/conf
diff options
context:
space:
mode:
authoravg <avg@FreeBSD.org>2009-07-15 17:07:39 +0000
committeravg <avg@FreeBSD.org>2009-07-15 17:07:39 +0000
commitb898b874c6ac6d3ebccdf4844571b90e08f39f0e (patch)
treee8923eb934a3053e438f8f4b36433f78316a58fe /sys/conf
parent9990f66d4450ab695ddf3686db11797c224dea45 (diff)
downloadFreeBSD-src-b898b874c6ac6d3ebccdf4844571b90e08f39f0e.zip
FreeBSD-src-b898b874c6ac6d3ebccdf4844571b90e08f39f0e.tar.gz
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
Diffstat (limited to 'sys/conf')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud