opnsense-src/sys
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
..
amd64 amd64: micro-optimize vptopte()/vtopde() further 2022-02-09 02:42:44 +02:00
arm sched: separate out schedinit_ap() 2022-02-10 14:55:29 -06:00
arm64 sched: separate out schedinit_ap() 2022-02-10 14:55:29 -06:00
bsm
cam CTL: Fix mode page trucation on HA synchronization. 2022-02-10 19:47:23 -05:00
cddl sys/cddl: remove extraneous semicolons 2022-02-08 15:04:31 -05:00
compat Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2022-02-08 15:00:55 -05:00
conf x86: Speed up clock calibration 2022-02-10 22:52:00 -08:00
contrib zfs: Remove zfs-images submodule 2022-02-09 12:39:50 -05:00
crypto Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2022-02-08 15:00:55 -05:00
ddb ddb: reliably fail with ambiguous commands 2021-07-02 14:13:24 -07:00
dev rtwn(4): Add new USB ID. 2022-02-10 16:11:07 +01:00
dts add overlay for enabling i2c1 on allwinner h3 2022-02-09 11:35:59 +02:00
fs nfsclient: Delete unused function nfscl_getcookie() 2022-02-09 19:39:00 -08:00
gdb gdb(4): Do not use run length encoding for 3-symbol repetitions 2022-02-04 20:58:34 -05:00
geom GEOM: Set G_CF_DIRECT_SEND/RECEIVE for taste consumers. 2022-02-10 19:50:46 -05:00
gnu
i386 Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2022-02-08 15:00:55 -05:00
isa Remove more remnants of sio(4) 2021-04-14 09:19:49 -04:00
kern x86: Speed up clock calibration 2022-02-10 22:52:00 -08:00
kgssapi
libkern Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2022-02-08 15:00:55 -05:00
mips sched: separate out schedinit_ap() 2022-02-10 14:55:29 -06:00
modules add overlay for enabling i2c1 on allwinner h3 2022-02-09 11:35:59 +02:00
net pflog: align header to 4 bytes, not 8 2022-02-09 10:40:58 +01:00
net80211 Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2022-02-08 15:00:55 -05:00
netgraph Add ETHER_ALIGN support to ng_device(4). 2022-01-14 14:28:43 +01:00
netinet Fix a memory leak when ip_output_send() returns EAGAIN due to send tag issues 2022-02-10 15:39:22 -05:00
netinet6 Fix a memory leak when ip_output_send() returns EAGAIN due to send tag issues 2022-02-10 15:39:22 -05:00
netipsec syncache: accept packet with no SA when TCP_MD5SIG is set 2022-02-10 10:31:33 -09:00
netpfil pf: Initialize pf_kpool mutexes earlier 2022-02-07 09:10:16 -05:00
netsmb netsmb: Avoid a read-after-free in smb_t2_request_int() 2021-06-02 09:34:47 -04:00
nfs nfs: don't truncate directory cookies to 32-bits in the NFS server 2022-01-02 20:09:15 -07:00
nfsclient
nfsserver
nlm
ofed socket: Rename sb(un)lock() and interlock with listen(2) 2021-10-07 09:56:47 -04:00
opencrypto Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2022-02-08 15:00:55 -05:00
powerpc sched: separate out schedinit_ap() 2022-02-10 14:55:29 -06:00
riscv sched: separate out schedinit_ap() 2022-02-10 14:55:29 -06:00
rpc rpc: Delete AUTH_NEEDS_TLS(_MUTUAL_HOST) auth_stat values 2021-12-29 17:23:30 -08:00
security Thread creation privilege for realtime group 2021-12-19 04:42:52 +02:00
sys x86: Speed up clock calibration 2022-02-10 22:52:00 -08:00
teken
tests routing: add IPv6 fib validation procedure. 2021-09-07 21:02:58 +00:00
tools Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2022-02-08 15:00:55 -05:00
ufs ufs, msdosfs: do not record witness order when creating vnode 2022-02-07 11:38:50 +02:00
vm Revert "vm_pageout_scans: correct detection of active object" 2022-02-10 16:56:15 +02:00
x86 x86: Speed up clock calibration 2022-02-10 22:52:00 -08:00
xdr
xen xen(4): Fix a common typo in a source code comments 2022-02-09 07:20:31 +01:00
Makefile