From 46e03d047168eadbab0081973698a2a1b89ecf6a Mon Sep 17 00:00:00 2001 From: humzak711 Date: Fri, 30 Jan 2026 03:16:42 +0000 Subject: [PATCH] arch/x86_64: use pause to reduce power consumption in spin wait loops Signed-off-by: humzak711 This commit defines the UP_WFE() macro as the 'pause' instruction for x86_64. This optimization reduces power consumption and prevents pipeline flushes caused by memory ordering violations during contended spinlock acqusitions --- arch/x86_64/include/arch.h | 2 ++ arch/x86_64/include/barriers.h | 1 + 2 files changed, 3 insertions(+) diff --git a/arch/x86_64/include/arch.h b/arch/x86_64/include/arch.h index 09a8ac7da14..45ad2229601 100644 --- a/arch/x86_64/include/arch.h +++ b/arch/x86_64/include/arch.h @@ -41,6 +41,8 @@ /* Include architecture-specific definitions */ +#include + #ifdef CONFIG_ARCH_INTEL64 # include #endif diff --git a/arch/x86_64/include/barriers.h b/arch/x86_64/include/barriers.h index bf1248b9aa6..ec634564fc3 100644 --- a/arch/x86_64/include/barriers.h +++ b/arch/x86_64/include/barriers.h @@ -29,5 +29,6 @@ #define UP_DMB() __asm__ __volatile__ ("mfence" ::: "memory") #define UP_RMB() __asm__ __volatile__ ("lfence" ::: "memory") #define UP_WMB() __asm__ __volatile__ ("sfence" ::: "memory") +#define UP_WFE() __asm__ __volatile__ ("pause") #endif /* __ARCH_X86_64_INCLUDE_BARRIERS_H */