This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit b608568643af244aed90526efe91803a3f1933f6 Author: ouyangxiangzhen <[email protected]> AuthorDate: Tue Nov 10 09:41:06 2026 +0800 arch/arm64: define UP_RELAX() as YIELD Busy-wait spin loops on arm64 fall back to the empty UP_RELAX() hint, so a contended lock hammers the interconnect and the pipeline: the polling loop keeps issuing loads against the lock line although nothing can progress until the owner releases. Define UP_RELAX() as the YIELD instruction. YIELD hints that the current thread is performing a spin-wait loop and lets the PE yield its execution resources to other threads or PEs sharing the pipeline; it does not sleep, so unlocking needs no wake event. Evidence: Arm ARM DDI 0487, YIELD. Linux uses the same hint in cpu_relax() (arch/arm64/include/asm/processor.h). Assisted-By: mimo-v2.6-pro Signed-off-by: ouyangxiangzhen <[email protected]> --- arch/arm64/include/arch.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/include/arch.h b/arch/arm64/include/arch.h index 22e6486d92a..971c25a58c0 100644 --- a/arch/arm64/include/arch.h +++ b/arch/arm64/include/arch.h @@ -56,6 +56,12 @@ #define UP_WFE() __asm__ __volatile__ ("wfe" : : : "memory") +/* Relax hint for spin waiting: YIELD reduces pipeline contention while + * polling the lock. It does not sleep and needs no wake event. + */ + +#define UP_RELAX() __asm__ __volatile__ ("yield") + /* SEV is not a memory access and is not subject to memory ordering, * so a waiter may observe the event before the lock release store * becomes visible, re-read the stale lock and sleep again with the
