From ba401828c194c17031a6a2dedd97bc0defd80d4b Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Thu, 19 Feb 2026 16:19:41 -0600 Subject: [PATCH] Remove SpinLockFree() and S_LOCK_FREE(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit S_LOCK_FREE() is used by the test program in s_lock.c, but nobody has voiced concerns about losing some coverage there. SpinLockFree() appears to have been unused since it was introduced by commit 499abb0c0f. There was agreement to remove these in 2020, but it never happened. Since we still have agreement for removal in 2026, let's do that now. Reviewed-by: Fabrízio de Royes Mello Reviewed-by: Andres Freund Discussion: https://postgr.es/m/aZX2oUcKf7IzHnnK%40nathan Discussion: https://postgr.es/m/20200608225338.m5zho424w6lpwb2d%40alap3.anarazel.de --- src/backend/storage/lmgr/s_lock.c | 24 ------------------------ src/include/storage/s_lock.h | 8 -------- src/include/storage/spin.h | 6 ------ 3 files changed, 38 deletions(-) diff --git a/src/backend/storage/lmgr/s_lock.c b/src/backend/storage/lmgr/s_lock.c index 5b79556bc9c..6df568eccb3 100644 --- a/src/backend/storage/lmgr/s_lock.c +++ b/src/backend/storage/lmgr/s_lock.c @@ -262,12 +262,6 @@ main() return 1; } - if (!S_LOCK_FREE(&test_lock.lock)) - { - printf("S_LOCK_TEST: failed, lock not initialized\n"); - return 1; - } - S_LOCK(&test_lock.lock); if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44) @@ -276,12 +270,6 @@ main() return 1; } - if (S_LOCK_FREE(&test_lock.lock)) - { - printf("S_LOCK_TEST: failed, lock not locked\n"); - return 1; - } - S_UNLOCK(&test_lock.lock); if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44) @@ -290,12 +278,6 @@ main() return 1; } - if (!S_LOCK_FREE(&test_lock.lock)) - { - printf("S_LOCK_TEST: failed, lock not unlocked\n"); - return 1; - } - S_LOCK(&test_lock.lock); if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44) @@ -304,12 +286,6 @@ main() return 1; } - if (S_LOCK_FREE(&test_lock.lock)) - { - printf("S_LOCK_TEST: failed, lock not re-locked\n"); - return 1; - } - printf("S_LOCK_TEST: this will print %d stars and then\n", NUM_DELAYS); printf(" exit with a 'stuck spinlock' message\n"); printf(" if S_LOCK() and TAS() are working.\n"); diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h index 62364586d60..c9e52511990 100644 --- a/src/include/storage/s_lock.h +++ b/src/include/storage/s_lock.h @@ -21,10 +21,6 @@ * void S_UNLOCK(slock_t *lock) * Unlock a previously acquired lock. * - * bool S_LOCK_FREE(slock_t *lock) - * Tests if the lock is free. Returns true if free, false if locked. - * This does *not* change the state of the lock. - * * void SPIN_DELAY(void) * Delay operation to occur inside spinlock wait loop. * @@ -671,10 +667,6 @@ spin_delay(void) (TAS(lock) ? s_lock((lock), __FILE__, __LINE__, __func__) : 0) #endif /* S_LOCK */ -#if !defined(S_LOCK_FREE) -#define S_LOCK_FREE(lock) (*(lock) == 0) -#endif /* S_LOCK_FREE */ - #if !defined(S_UNLOCK) /* * Our default implementation of S_UNLOCK is essentially *(lock) = 0. This diff --git a/src/include/storage/spin.h b/src/include/storage/spin.h index 0f160d0e395..78c95ae538b 100644 --- a/src/include/storage/spin.h +++ b/src/include/storage/spin.h @@ -18,10 +18,6 @@ * void SpinLockRelease(volatile slock_t *lock) * Unlock a previously acquired lock. * - * bool SpinLockFree(slock_t *lock) - * Tests if the lock is free. Returns true if free, false if locked. - * This does *not* change the state of the lock. - * * Callers must beware that the macro argument may be evaluated multiple * times! * @@ -60,6 +56,4 @@ #define SpinLockRelease(lock) S_UNLOCK(lock) -#define SpinLockFree(lock) S_LOCK_FREE(lock) - #endif /* SPIN_H */