Skip to content

Improve the spinloop pause / yield hint

Tony Finch requested to merge fanf-arm-spinloop into main

Unfortunately, C still lacks a standard function for pause (x86, sparc) or yeild (arm) instructions, for use in spin lock or CAS loops. BIND has its own based on vendor intrinsics or inline asm.

Previously, it was buried in the isc_rwlock implementation. This commit renames isc_rwlock_pause() to isc_atomic_pause() and moves it into <isc/atomic.h>.

This commit also fixes the configure script so that it detects ARM yield support on systems that identify as aarch* instead of arm*.

On ARM systems that support the ISB (instruction synchronization barrier) instruction, we now use that in preference to yield. The ISB instruction pauses the CPU for longer, several nanoseconds, which is more like the x86 pause instruction. There are more details in a Rust pull request, which also refers to MySQL making the same change: https://github.com/rust-lang/rust/pull/84725

Merge request reports