https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=557e7cf22612e3a9e2d8abe032c0c57a39029ad3
commit 557e7cf22612e3a9e2d8abe032c0c57a39029ad3 Author: Radek Bartoň <radek.bar...@microsoft.com> Date: Thu Jun 5 12:41:37 2025 +0200 Cygwin: implement spinlock pause for AArch64 Signed-off-by: Radek Bartoň <radek.bar...@microsoft.com> Diff: --- winsup/cygwin/local_includes/cygtls.h | 5 ++++- winsup/cygwin/thread.cc | 5 +++++ winsup/testsuite/winsup.api/pthread/cpu_relax.h | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/local_includes/cygtls.h b/winsup/cygwin/local_includes/cygtls.h index 29a539d83..44bd44e72 100644 --- a/winsup/cygwin/local_includes/cygtls.h +++ b/winsup/cygwin/local_includes/cygtls.h @@ -243,8 +243,11 @@ public: /* Do NOT remove this public: line, it's a marker for gentls_offsets. */ { while (InterlockedExchange (&stacklock, 1)) { -#ifdef __x86_64__ +#if defined(__x86_64__) __asm__ ("pause"); +#elif defined(__aarch64__) + __asm__ ("dmb ishst\n" + "yield"); #else #error unimplemented for this target #endif diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index fea6079b8..510e2be93 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -1968,7 +1968,12 @@ pthread_spinlock::lock () else if (spins < FAST_SPINS_LIMIT) { ++spins; +#if defined(__x86_64__) __asm__ volatile ("pause":::); +#elif defined(__aarch64__) + __asm__ volatile ("dmb ishst\n" + "yield":::); +#endif } else { diff --git a/winsup/testsuite/winsup.api/pthread/cpu_relax.h b/winsup/testsuite/winsup.api/pthread/cpu_relax.h index 1936dc5f4..71cec0b2b 100644 --- a/winsup/testsuite/winsup.api/pthread/cpu_relax.h +++ b/winsup/testsuite/winsup.api/pthread/cpu_relax.h @@ -4,7 +4,8 @@ #if defined(__x86_64__) || defined(__i386__) // Check for x86 architectures #define CPU_RELAX() __asm__ volatile ("pause" :::) #elif defined(__aarch64__) || defined(__arm__) // Check for ARM architectures - #define CPU_RELAX() __asm__ volatile ("yield" :::) + #define CPU_RELAX() __asm__ volatile ("dmb ishst \ + yield" :::) #else #error unimplemented for this target #endif