Skip to content

Commit a82a5ee

Browse files
committed
Use ISB as a spin-delay instruction on ARM64.
This seems beneficial on high-core-count machines, and not harmful on lesser hardware. However, older ARM32 gear doesn't have this instruction, so restrict the patch to ARM64. Geoffrey Blake Discussion: https://postgr.es/m/78338F29-9D7F-4DC8-BD71-E9674CE71425@amazon.com
1 parent 8ea7963 commit a82a5ee

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/include/storage/s_lock.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,23 @@ tas(volatile slock_t *lock)
337337

338338
#define S_UNLOCK(lock) __sync_lock_release(lock)
339339

340+
/*
341+
* Using an ISB instruction to delay in spinlock loops appears beneficial on
342+
* high-core-count ARM64 processors. It seems mostly a wash for smaller gear,
343+
* and ISB doesn't exist at all on pre-v7 ARM chips.
344+
*/
345+
#if defined(__aarch64__) || defined(__aarch64)
346+
347+
#define SPIN_DELAY() spin_delay()
348+
349+
static __inline__ void
350+
spin_delay(void)
351+
{
352+
__asm__ __volatile__(
353+
" isb; \n");
354+
}
355+
356+
#endif /* __aarch64__ || __aarch64 */
340357
#endif /* HAVE_GCC__SYNC_INT32_TAS */
341358
#endif /* __arm__ || __arm || __aarch64__ || __aarch64 */
342359

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy