summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorThomas Munro2024-07-30 09:45:01 +0000
committerThomas Munro2024-07-30 10:58:37 +0000
commite25626677f8076eb3ce94586136c5464ee154381 (patch)
treef03f87af97b998e2dd5aadcfe8a93a83a1ae716b /src/include
parent1330843bb78e9d2422af2f2b9909b80732bd6fc0 (diff)
Remove --disable-spinlocks.
A later change will require atomic support, so it wouldn't make sense for a hypothetical new system not to be able to implement spinlocks. Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> (concept, not the patch) Reviewed-by: Andres Freund <andres@anarazel.de> (concept, not the patch) Discussion: https://postgr.es/m/3351991.1697728588%40sss.pgh.pa.us
Diffstat (limited to 'src/include')
-rw-r--r--src/include/pg_config.h.in3
-rw-r--r--src/include/pg_config_manual.h15
-rw-r--r--src/include/port/atomics.h4
-rw-r--r--src/include/port/atomics/fallback.h4
-rw-r--r--src/include/storage/s_lock.h39
-rw-r--r--src/include/storage/spin.h18
6 files changed, 9 insertions, 74 deletions
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 3dea3856aaf..e6c06f61027 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -382,9 +382,6 @@
/* Define to 1 if the system has the type `socklen_t'. */
#undef HAVE_SOCKLEN_T
-/* Define to 1 if you have spinlocks. */
-#undef HAVE_SPINLOCKS
-
/* Define to 1 if you have the `SSL_CTX_set_cert_cb' function. */
#undef HAVE_SSL_CTX_SET_CERT_CB
diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h
index f941ee2faf8..11f74f4b56d 100644
--- a/src/include/pg_config_manual.h
+++ b/src/include/pg_config_manual.h
@@ -86,21 +86,6 @@
#define USE_FLOAT8_BYVAL 1
#endif
-/*
- * When we don't have native spinlocks, we use semaphores to simulate them.
- * Decreasing this value reduces consumption of OS resources; increasing it
- * may improve performance, but supplying a real spinlock implementation is
- * probably far better.
- */
-#define NUM_SPINLOCK_SEMAPHORES 128
-
-/*
- * When we have neither spinlocks nor atomic operations support we're
- * implementing atomic operations on top of spinlock on top of semaphores. To
- * be safe against atomic operations while holding a spinlock separate
- * semaphores have to be used.
- */
-#define NUM_ATOMICS_SEMAPHORES 64
/*
* MAXPGPATH: standard size of a pathname buffer in PostgreSQL (hence,
diff --git a/src/include/port/atomics.h b/src/include/port/atomics.h
index f6fa432d2df..03134e3b7bb 100644
--- a/src/include/port/atomics.h
+++ b/src/include/port/atomics.h
@@ -16,8 +16,8 @@
*
* There exist generic, hardware independent, implementations for several
* compilers which might be sufficient, although possibly not optimal, for a
- * new platform. If no such generic implementation is available spinlocks (or
- * even OS provided semaphores) will be used to implement the API.
+ * new platform. If no such generic implementation is available spinlocks will
+ * be used to implement the API.
*
* Implement _u64 atomics if and only if your platform can use them
* efficiently (and obviously correctly).
diff --git a/src/include/port/atomics/fallback.h b/src/include/port/atomics/fallback.h
index 34cfee110fb..2e3eef4acaf 100644
--- a/src/include/port/atomics/fallback.h
+++ b/src/include/port/atomics/fallback.h
@@ -20,9 +20,7 @@
#ifndef pg_memory_barrier_impl
/*
* If we have no memory barrier implementation for this architecture, we
- * fall back to acquiring and releasing a spinlock. This might, in turn,
- * fall back to the semaphore-based spinlock implementation, which will be
- * amazingly slow.
+ * fall back to acquiring and releasing a spinlock.
*
* It's not self-evident that every possible legal implementation of a
* spinlock acquire-and-release would be equivalent to a full memory barrier.
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 02c68513a53..e94ed5f48bd 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -1,10 +1,10 @@
/*-------------------------------------------------------------------------
*
* s_lock.h
- * Hardware-dependent implementation of spinlocks.
+ * Implementation of spinlocks.
*
* NOTE: none of the macros in this file are intended to be called directly.
- * Call them through the hardware-independent macros in spin.h.
+ * Call them through the macros in spin.h.
*
* The following hardware-dependent macros must be provided for each
* supported platform:
@@ -78,13 +78,6 @@
* in assembly language to execute a hardware atomic-test-and-set
* instruction. Equivalent OS-supplied mutex routines could be used too.
*
- * If no system-specific TAS() is available (ie, HAVE_SPINLOCKS is not
- * defined), then we fall back on an emulation that uses SysV semaphores
- * (see spin.c). This emulation will be MUCH MUCH slower than a proper TAS()
- * implementation, because of the cost of a kernel call per lock or unlock.
- * An old report is that Postgres spends around 40% of its time in semop(2)
- * when using the SysV semaphore code.
- *
*
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
@@ -100,8 +93,6 @@
#error "s_lock.h may not be included from frontend code"
#endif
-#ifdef HAVE_SPINLOCKS /* skip spinlocks if requested */
-
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
/*************************************************************************
* All the gcc inlines
@@ -655,34 +646,10 @@ spin_delay(void)
/* Blow up if we didn't have any way to do spinlocks */
#ifndef HAS_TEST_AND_SET
-#error PostgreSQL does not have native spinlock support on this platform. To continue the compilation, rerun configure using --disable-spinlocks. However, performance will be poor. Please report this to pgsql-bugs@lists.postgresql.org.
+#error PostgreSQL does not have spinlock support on this platform. Please report this to pgsql-bugs@lists.postgresql.org.
#endif
-#else /* !HAVE_SPINLOCKS */
-
-
-/*
- * Fake spinlock implementation using semaphores --- slow and prone
- * to fall foul of kernel limits on number of semaphores, so don't use this
- * unless you must! The subroutines appear in spin.c.
- */
-typedef int slock_t;
-
-extern bool s_lock_free_sema(volatile slock_t *lock);
-extern void s_unlock_sema(volatile slock_t *lock);
-extern void s_init_lock_sema(volatile slock_t *lock, bool nested);
-extern int tas_sema(volatile slock_t *lock);
-
-#define S_LOCK_FREE(lock) s_lock_free_sema(lock)
-#define S_UNLOCK(lock) s_unlock_sema(lock)
-#define S_INIT_LOCK(lock) s_init_lock_sema(lock, false)
-#define TAS(lock) tas_sema(lock)
-
-
-#endif /* HAVE_SPINLOCKS */
-
-
/*
* Default Definitions - override these above as needed.
*/
diff --git a/src/include/storage/spin.h b/src/include/storage/spin.h
index c0679c59992..3ae2a56d073 100644
--- a/src/include/storage/spin.h
+++ b/src/include/storage/spin.h
@@ -1,11 +1,11 @@
/*-------------------------------------------------------------------------
*
* spin.h
- * Hardware-independent implementation of spinlocks.
+ * API for spinlocks.
*
*
- * The hardware-independent interface to spinlocks is defined by the
- * typedef "slock_t" and these macros:
+ * The interface to spinlocks is defined by the typedef "slock_t" and
+ * these macros:
*
* void SpinLockInit(volatile slock_t *lock)
* Initialize a spinlock (to the unlocked state).
@@ -52,9 +52,6 @@
#define SPIN_H
#include "storage/s_lock.h"
-#ifndef HAVE_SPINLOCKS
-#include "storage/pg_sema.h"
-#endif
#define SpinLockInit(lock) S_INIT_LOCK(lock)
@@ -65,13 +62,4 @@
#define SpinLockFree(lock) S_LOCK_FREE(lock)
-
-extern int SpinlockSemas(void);
-extern Size SpinlockSemaSize(void);
-
-#ifndef HAVE_SPINLOCKS
-extern void SpinlockSemaInit(void);
-extern PGDLLIMPORT PGSemaphore *SpinlockSemaArray;
-#endif
-
#endif /* SPIN_H */