diff options
author | 2020-09-06 20:50:00 +0000 | |
---|---|---|
committer | 2020-09-06 20:50:00 +0000 | |
commit | eca6036631da63309801d81b42bec0fe4ad0cecc (patch) | |
tree | 6f2d9c9964654cf2efb699b79c803aa04ccdda9d /lib/libssl/t1_lib.c | |
parent | Drop redundant else for readability. (diff) | |
download | wireguard-openbsd-eca6036631da63309801d81b42bec0fe4ad0cecc.tar.xz wireguard-openbsd-eca6036631da63309801d81b42bec0fe4ad0cecc.zip |
amd64: add tsc_delay(), a delay(9) implementation based on the TSC
In preparation for running the lapic timer in oneshot mode on amd64 we
need a replacement for lapic_delay().
Using the lapic timer itself to implement delay(9) when the timer is
not running in periodic mode is complicated if not outright impossible.
Meanwhile, the i8254 provides our only other amd64 delay(9) implementation
and it is an extremely slow clock. On my 2GHz machine, gettick() takes
~20 microseconds to complete *without* mutex contention. On a VM it is
even slower, as you must exit the VM for each inb() and outb().
So, add tsc_delay() and use it when we have a constant/invariant TSC.
The TSC is a 64-bit "up-counter" so the implementation is simple.
Given how slow the i8254 is on modern machines, we may want to add an
HPET delay(9) implementation as a fallback for machines where the TSC
drifts. The HPET itself is pretty slow, but not as slow as the i8254.
Discussed with kettenis@, Mike Larkin, and naddy@.
Tweaked by kettenis@.
ok kettenis@
Diffstat (limited to 'lib/libssl/t1_lib.c')
0 files changed, 0 insertions, 0 deletions