]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC 340164,340168,340170: Add custom cpu_lock_delay() for x86.
authorjhb <jhb@FreeBSD.org>
Thu, 8 Nov 2018 22:39:38 +0000 (22:39 +0000)
committerjhb <jhb@FreeBSD.org>
Thu, 8 Nov 2018 22:39:38 +0000 (22:39 +0000)
commit7eb79fb417a052887eda7173298a3aa9bf6179de
tree327475ca5ba82ba8e1572360f543752c1b81b841
parent341c5eff7e4440bd794fc66a03d7675b086d39e6
MFC 340164,340168,340170: Add custom cpu_lock_delay() for x86.

340164:
Add a KPI for the delay while spinning on a spin lock.

Replace a call to DELAY(1) with a new cpu_lock_delay() KPI.  Currently
cpu_lock_delay() is defined to DELAY(1) on all platforms.  However,
platforms with a DELAY() implementation that uses spin locks should
implement a custom cpu_lock_delay() doesn't use locks.

340168:
Add a delay_tsc() static function for when DELAY() uses the TSC.

This uses slightly simpler logic than the existing code by using the
full 64-bit counter and thus not having to worry about counter
overflow.

340170:
Add a custom implementation of cpu_lock_delay() for x86.

Avoid using DELAY() since it can try to use spin locks on CPUs without
a P-state invariant TSC.  For cpu_lock_delay(), always use the TSC if
it exists (even if it is not P-state invariant) to delay for a
microsecond.  If the TSC does not exist, read from I/O port 0x84 to
delay instead.

PR: 228768
Approved by: re (gjb)
sys/amd64/include/cpu.h
sys/arm/include/cpu.h
sys/arm64/include/cpu.h
sys/i386/include/cpu.h
sys/kern/kern_mutex.c
sys/mips/include/cpu.h
sys/powerpc/include/cpu.h
sys/riscv/include/cpu.h
sys/sparc64/include/cpu.h
sys/x86/x86/delay.c