From dacba8aa9cc7404449aaacc830969c57be7d1ceb Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Fri, 20 Nov 2026 12:48:02 -0600 Subject: [PATCH v1 1/3] Remove redundant spinlock code for ARM/ARM64. The ARM/ARM64 section of s_lock.h defines slock_t, tas(), and S_UNLOCK() the same way as the "no platform-specific knowledge" section added by commit 1c72d82c25. That commit left the ARM/ARM64 section alone because it has some special knowledge, but that only amounts to the TAS_SPIN() and SPIN_DELAY() definitions for ARM64. This commit removes everything else so that these platforms use the generic code instead. The generated code should be the same as before. --- src/include/storage/s_lock.h | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h index 7e049dfac18..02a3feb0d65 100644 --- a/src/include/storage/s_lock.h +++ b/src/include/storage/s_lock.h @@ -231,26 +231,10 @@ spin_delay(void) /* - * On ARM and ARM64, we use __sync_lock_test_and_set(int *, int) if available. - * - * We use the int-width variant of the builtin because it works on more chips - * than other widths. + * For ARM/ARM64, we use the "no platform-specific knowledge" flavors below, + * which use __sync_lock_test_and_set() and friends. However, we do use a + * custom TAS_SPIN() and SPIN_DELAY() for ARM64. */ -#if defined(__arm__) || defined(__aarch64__) -#ifdef HAVE_GCC__SYNC_INT32_TAS - -#define TAS(lock) tas(lock) - -typedef int slock_t; - -static inline int -tas(volatile slock_t *lock) -{ - return __sync_lock_test_and_set(lock, 1); -} - -#define S_UNLOCK(lock) __sync_lock_release(lock) - #if defined(__aarch64__) /* @@ -274,8 +258,6 @@ spin_delay(void) } #endif /* __aarch64__ */ -#endif /* HAVE_GCC__SYNC_INT32_TAS */ -#endif /* __arm__ || __aarch64__ */ /* S/390 and S/390x Linux (32- and 64-bit zSeries) */ @@ -513,7 +495,6 @@ do \ * provides __sync_lock_test_and_set(), use that. Prefer the int-width * version over the char-width version if we have both, on the rather dubious * grounds that that's known to be more likely to work in the ARM ecosystem. - * (But we dealt with ARM above.) */ #if !defined(TAS) -- 2.55.0