FreeBSD src
Go to file
Andriy Gapon b064b6d1cd 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
2009-07-15 17:07:39 +00:00
bin Add manual page links to advertise procstat(1) a little better. 2009-07-09 16:40:00 +00:00
cddl The mutex_owned() macro should operate on kmutex_t and not on mutex_t. 2009-07-09 20:22:05 +00:00
contrib correct IEEE80211_RADIOTAP_XCHANNEL to match system 2009-07-15 13:50:06 +00:00
crypto Use the closefrom(2) system call. 2009-06-16 15:30:10 +00:00
etc 1) Use our vendor domain at the pool. 2009-07-13 05:51:33 +00:00
games Misc fixed to fortunes 2009-06-05 07:57:10 +00:00
gnu Second attempt at eliminating .text relocations in shared libraries 2009-07-14 21:19:13 +00:00
include Separate the parallel scsi knowledge out of the core of the XPT, and 2009-07-10 08:18:08 +00:00
kerberos5 Disconnect closefrom.c as we have it as a system call. 2009-06-16 00:09:06 +00:00
lib Second attempt at eliminating .text relocations in shared libraries 2009-07-14 21:19:13 +00:00
libexec Second attempt at eliminating .text relocations in shared libraries 2009-07-14 21:19:13 +00:00
release Add libjail to the boot_crunch binaries (for ifconfig). 2009-06-29 13:59:30 +00:00
rescue Add the "vnet" and "-vnet" options, to allow moving interfaces between 2009-06-24 18:21:37 +00:00
sbin Implementation of the upcoming Wireless Mesh standard, 802.11s, on the 2009-07-11 15:02:45 +00:00
secure Remove build timestamps from the following files: 2009-07-11 22:30:37 +00:00
share Second attempt at eliminating .text relocations in shared libraries 2009-07-14 21:19:13 +00:00
sys dtrace_gethrtime: improve scaling of TSC ticks to nanoseconds 2009-07-15 17:07:39 +00:00
tools Test suite for the poll(2)/select(2) on fifos, pipes and sockets, 2009-07-12 12:50:43 +00:00
usr.bin Make mklocale work again, now that fwrite()'s return codes are different. 2009-07-14 09:19:33 +00:00
usr.sbin fix Jouni's email address 2009-07-12 19:58:52 +00:00
COPYRIGHT Bump the odometer of the years. A little early this year for 7.1R. 2008-12-30 04:46:25 +00:00
LOCKS
MAINTAINERS - pkg_install is maintained by portmgr. 2009-07-06 11:46:18 +00:00
Makefile Add a new world named 'mips' to our universe. 2009-04-01 17:11:50 +00:00
Makefile.inc1 Second attempt at eliminating .text relocations in shared libraries 2009-07-14 21:19:13 +00:00
ObsoleteFiles.inc Build on Jeff Roberson's linker-set based dynamic per-CPU allocator 2009-07-14 22:48:30 +00:00
README
UPDATING Build on Jeff Roberson's linker-set based dynamic per-CPU allocator 2009-07-14 22:48:30 +00:00

This is the top level of the FreeBSD source directory.  This file
was last revised on:
$FreeBSD$

For copyright information, please see the file COPYRIGHT in this
directory (additional copyright information also exists for some
sources in this tree - please see the specific source directories for
more information).

The Makefile in this directory supports a number of targets for
building components (or all) of the FreeBSD source tree, the most
commonly used one being ``world'', which rebuilds and installs
everything in the FreeBSD system from the source tree except the
kernel, the kernel-modules and the contents of /etc.  The ``world''
target should only be used in cases where the source tree has not
changed from the currently running version.  See:
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html
for more information, including setting make(1) variables.

The ``buildkernel'' and ``installkernel'' targets build and install
the kernel and the modules (see below).  Please see the top of
the Makefile in this directory for more information on the
standard build targets and compile-time flags.

Building a kernel is a somewhat more involved process, documentation
for which can be found at:
   http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html
And in the config(8) man page.
Note: If you want to build and install the kernel with the
``buildkernel'' and ``installkernel'' targets, you might need to build
world before.  More information is available in the handbook.

The sample kernel configuration files reside in the sys/<arch>/conf
sub-directory (assuming that you've installed the kernel sources), the
file named GENERIC being the one used to build your initial installation
kernel.  The file NOTES contains entries and documentation for all possible
devices, not just those commonly used.  It is the successor of the ancient
LINT file, but in contrast to LINT, it is not buildable as a kernel but a
pure reference and documentation file.


Source Roadmap:
---------------
bin		System/user commands.

contrib		Packages contributed by 3rd parties.

crypto		Cryptography stuff (see crypto/README).

etc		Template files for /etc.

games		Amusements.

gnu		Various commands and libraries under the GNU Public License.
		Please see gnu/COPYING* for more information.

include		System include files.

kerberos5	Kerberos5 (Heimdal) package.

lib		System libraries.

libexec		System daemons.

release		Release building Makefile & associated tools.

rescue		Build system for statically linked /rescue utilities.

sbin		System commands.

secure		Cryptographic libraries and commands.

share		Shared resources.

sys		Kernel sources.

tools		Utilities for regression testing and miscellaneous tasks.

usr.bin		User commands.

usr.sbin	System administration commands.


For information on synchronizing your source tree with one or more of
the FreeBSD Project's development branches, please see:

  http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/synching.html