OPNsense - FreeBSD source
Find a file
Colin Percival baee6cc181 x86: Speed up clock calibration
Prior to this commit, the TSC and local APIC frequencies were calibrated
at boot time by measuring the clocks before and after a one-second sleep.
This was simple and effective, but had the disadvantage of *requiring a
one-second sleep*.

Rather than making two clock measurements (before and after sleeping) we
now perform many measurements; and rather than simply subtracting the
starting count from the ending count, we calculate a best-fit regression
between the target clock and the reference clock (for which the current
best available timecounter is used). While we do this, we keep track
of an estimate of the uncertainty in the regression slope (aka. the ratio
of clock speeds), and stop measuring when we believe the uncertainty is
less than 1 PPM.

In order to avoid the risk of aliasing resulting from the data-gathering
loop synchronizing with (a multiple of) the frequency of the reference
clock, we add some additional spinning depending upon the iteration number.

For numerical stability and simplicity of implementation, we make use of
floating-point arithmetic for the statistical calculations.

On the author's Dell laptop, this reduces the time spent in calibration
from 2000 ms to 29 ms; on an EC2 c5.xlarge instance, it is reduced from
2000 ms to 2.5 ms.

Reviewed by:	bde (previous version), kib
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D33802

(cherry picked from commit c2705ceaeb)
2022-02-10 22:52:00 -08:00
.cirrus-ci Cirrus-CI: add some timing info on pkg install failure 2022-02-09 12:39:50 -05:00
.github/workflows .github: Attempt to un-break Clang 9 action 2021-05-29 04:38:07 +01:00
bin echo(1): Replace errexit() with err(3) 2022-01-07 14:12:12 +01:00
cddl dt_unring_buf: set dtbd_oldest to the start of the first record 2022-02-08 18:15:59 +02:00
contrib compiler-rt: support ReExec() on FreeBSD 2022-02-10 13:17:39 -05:00
crypto ssh: pass 0 to procctl(2) to operate on self 2022-02-10 13:09:57 -05:00
etc pkgbase: Create a FreeBSD-mtree package 2022-01-05 18:23:52 +01:00
gnu Bump shared library versions after ncurses bump in 13. 2021-02-04 17:51:45 -08:00
include Remove 'All Rights Reserved' from xlocale FreeBSD Foundation copyrights 2022-02-09 12:39:50 -05:00
kerberos5 pkgbase: Create a FreeBSD-kerberos package 2022-01-05 18:23:50 +01:00
lib execve: disallow argc == 0 2022-02-10 14:21:59 -06:00
libexec pf: fallback if $pf_rules fails to load 2022-01-24 21:11:02 +01:00
release pkgbase: Remove runtime dependency on bootloader 2022-01-28 08:10:12 +01:00
rescue Fix building rescue/rescue when sanitizers are enabled 2021-08-05 09:59:51 +01:00
sbin ipfilter: Restore ipfsync 2022-02-07 05:51:18 -08:00
secure ssh: enable FIDO/U2F keys 2022-02-09 19:03:21 -05:00
share syncache: accept packet with no SA when TCP_MD5SIG is set 2022-02-10 10:31:33 -09:00
stand loader: tslog: Add more log for module loading 2022-01-27 11:06:43 +01:00
sys x86: Speed up clock calibration 2022-02-10 22:52:00 -08:00
targets Fix bootstrapping to actually build lldb-tblgen for later use 2021-09-07 13:08:18 +01:00
tests tests: add a basic test for argc == 0 2022-02-10 14:21:59 -06:00
tools ssh: update to OpenSSH v8.8p1 2022-02-10 13:09:57 -05:00
usr.bin elfctl: update man page example for 'no' prefix 2022-02-09 12:28:41 -05:00
usr.sbin bhyve/virtio: use correct device id for virtio-scsi 2022-02-10 10:45:56 -09:00
.arcconfig arcconfig: add callsign again 2020-11-23 04:39:29 +00:00
.arclint arc lint: ignore /tests/ in chmod 2017-12-19 03:38:06 +00:00
.cirrus.yml Cirrus-CI: build with LLVM 13 package 2022-01-07 19:14:12 -05:00
.clang-format clang-format: Add bitset loop macros 2021-11-01 09:20:11 -04:00
.gitattributes Add a basic clang-format configuration file 2019-06-07 15:23:52 +00:00
.gitignore add exuberant ctags tags file to gitignore 2022-01-11 15:25:37 +02:00
COPYRIGHT copyrights: Happy New Year 2021 2020-12-31 10:29:44 -05:00
LOCKS LOCKS: update current locks 2018-06-09 03:08:04 +00:00
MAINTAINERS Add a pointer to csprng@ for the CSPRNG driver. This is enforced anyway by 2020-09-01 08:02:12 +00:00
Makefile Fix 'make bmake' top-level bootstrapping. 2021-12-21 14:44:51 +01:00
Makefile.inc1 Makefile.inc1: remove lorder from build/cross tools 2022-02-09 16:23:53 -05:00
Makefile.libcompat Prefer MK_SSP=no to SSP_CFLAGS= 2021-08-11 13:56:28 -03:00
Makefile.sys.inc AUTO_OBJ: For all top-level targets enforce using an OBJDIR. 2017-12-05 21:29:47 +00:00
ObsoleteFiles.inc Make date headers in ObsoleteFiles.inc a little more consistent 2022-01-27 19:58:14 +01:00
README README.md: update gnu directory description 2021-12-19 21:01:53 -05:00
README.md README.md: update gnu directory description 2021-12-19 21:01:53 -05:00
RELNOTES RELNOTES: Add comment about WiFi 6 support 2021-11-22 10:42:11 -08:00
UPDATING Add UPDATING entry for PIE default 2022-01-23 11:12:28 +01:00

FreeBSD Source:

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

FreeBSD is an operating system used to power modern servers, desktops, and embedded platforms. A large community has continually developed it for more than thirty years. Its advanced networking, security, and storage features have made FreeBSD the platform of choice for many of the busiest web sites and most pervasive embedded networking and storage devices.

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. See build(7), config(8), https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html, and https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html for more information, including setting make(1) variables.

Source Roadmap:

bin		System/user commands.

cddl		Various commands and libraries under the Common Development
		and Distribution License.

contrib		Packages contributed by 3rd parties.

crypto		Cryptography stuff (see crypto/README).

etc		Template files for /etc.

gnu		Commands and libraries under the GNU General Public License
		(GPL) or Lesser General Public License (LGPL).  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.

stand		Boot loader sources.

sys		Kernel sources.

sys/<arch>/conf Kernel configuration files. GENERIC is the configuration
		used in release builds. NOTES contains documentation of
		all possible entries.

tests		Regression tests which can be run by Kyua.  See tests/README
		for additional information.

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:

https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/current-stable.html