Skip to content

Commit e256266

Browse files
committed
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
1 parent 1330843 commit e256266

File tree

20 files changed

+13
-486
lines changed

20 files changed

+13
-486
lines changed

configure

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,6 @@ enable_integer_datetimes
836836
enable_nls
837837
with_pgport
838838
enable_rpath
839-
enable_spinlocks
840839
enable_atomics
841840
enable_debug
842841
enable_profiling
@@ -1529,7 +1528,6 @@ Optional Features:
15291528
enable Native Language Support
15301529
--disable-rpath do not embed shared library search path in
15311530
executables
1532-
--disable-spinlocks do not use spinlocks
15331531
--disable-atomics do not use atomic operations
15341532
--enable-debug build with debugging symbols (-g)
15351533
--enable-profiling build with profiling enabled
@@ -3266,33 +3264,6 @@ fi
32663264

32673265

32683266

3269-
#
3270-
# Spinlocks
3271-
#
3272-
3273-
3274-
# Check whether --enable-spinlocks was given.
3275-
if test "${enable_spinlocks+set}" = set; then :
3276-
enableval=$enable_spinlocks;
3277-
case $enableval in
3278-
yes)
3279-
:
3280-
;;
3281-
no)
3282-
:
3283-
;;
3284-
*)
3285-
as_fn_error $? "no argument expected for --enable-spinlocks option" "$LINENO" 5
3286-
;;
3287-
esac
3288-
3289-
else
3290-
enable_spinlocks=yes
3291-
3292-
fi
3293-
3294-
3295-
32963267
#
32973268
# Atomic operations
32983269
#
@@ -12185,17 +12156,6 @@ fi
1218512156

1218612157
fi
1218712158

12188-
if test "$enable_spinlocks" = yes; then
12189-
12190-
$as_echo "#define HAVE_SPINLOCKS 1" >>confdefs.h
12191-
12192-
else
12193-
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
12194-
*** Not using spinlocks will cause poor performance." >&5
12195-
$as_echo "$as_me: WARNING:
12196-
*** Not using spinlocks will cause poor performance." >&2;}
12197-
fi
12198-
1219912159
if test "$enable_atomics" = yes; then
1220012160

1220112161
$as_echo "#define HAVE_ATOMICS 1" >>confdefs.h

configure.ac

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,6 @@ PGAC_ARG_BOOL(enable, rpath, yes,
186186
[do not embed shared library search path in executables])
187187
AC_SUBST(enable_rpath)
188188

189-
#
190-
# Spinlocks
191-
#
192-
PGAC_ARG_BOOL(enable, spinlocks, yes,
193-
[do not use spinlocks])
194-
195189
#
196190
# Atomic operations
197191
#
@@ -1296,13 +1290,6 @@ failure. It is possible the compiler isn't looking in the proper directory.
12961290
Use --without-zlib to disable zlib support.])])
12971291
fi
12981292

1299-
if test "$enable_spinlocks" = yes; then
1300-
AC_DEFINE(HAVE_SPINLOCKS, 1, [Define to 1 if you have spinlocks.])
1301-
else
1302-
AC_MSG_WARN([
1303-
*** Not using spinlocks will cause poor performance.])
1304-
fi
1305-
13061293
if test "$enable_atomics" = yes; then
13071294
AC_DEFINE(HAVE_ATOMICS, 1, [Define to 1 if you want to use atomics if available.])
13081295
else

doc/src/sgml/installation.sgml

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,22 +1258,6 @@ build-postgresql:
12581258
</listitem>
12591259
</varlistentry>
12601260

1261-
<varlistentry id="configure-option-disable-spinlocks">
1262-
<term><option>--disable-spinlocks</option></term>
1263-
<listitem>
1264-
<para>
1265-
Allow the build to succeed even if <productname>PostgreSQL</productname>
1266-
has no CPU spinlock support for the platform. The lack of
1267-
spinlock support will result in very poor performance; therefore,
1268-
this option should only be used if the build aborts and
1269-
informs you that the platform lacks spinlock support. If this
1270-
option is required to build <productname>PostgreSQL</productname> on
1271-
your platform, please report the problem to the
1272-
<productname>PostgreSQL</productname> developers.
1273-
</para>
1274-
</listitem>
1275-
</varlistentry>
1276-
12771261
<varlistentry id="configure-option-disable-atomics">
12781262
<term><option>--disable-atomics</option></term>
12791263
<listitem>
@@ -2690,23 +2674,6 @@ ninja install
26902674
</listitem>
26912675
</varlistentry>
26922676

2693-
<varlistentry id="configure-spinlocks-meson">
2694-
<term><option>-Dspinlocks={ true | false }</option></term>
2695-
<listitem>
2696-
<para>
2697-
This option is set to true by default; setting it to false will
2698-
allow the build to succeed even if <productname>PostgreSQL</productname>
2699-
has no CPU spinlock support for the platform. The lack of
2700-
spinlock support will result in very poor performance; therefore,
2701-
this option should only be changed if the build aborts and
2702-
informs you that the platform lacks spinlock support. If setting this
2703-
option to false is required to build <productname>PostgreSQL</productname> on
2704-
your platform, please report the problem to the
2705-
<productname>PostgreSQL</productname> developers.
2706-
</para>
2707-
</listitem>
2708-
</varlistentry>
2709-
27102677
<varlistentry id="configure-atomics-meson">
27112678
<term><option>-Datomics={ true | false }</option></term>
27122679
<listitem>
@@ -2719,6 +2686,7 @@ ninja install
27192686
</para>
27202687
</listitem>
27212688
</varlistentry>
2689+
27222690
</variablelist>
27232691
</sect3>
27242692

@@ -3393,9 +3361,6 @@ export MANPATH
33933361
these CPU architectures: x86, PowerPC, S/390, SPARC, ARM, MIPS,
33943362
and RISC-V, including
33953363
big-endian, little-endian, 32-bit, and 64-bit variants where applicable.
3396-
It is often
3397-
possible to build on an unsupported CPU type by configuring with
3398-
<option>--disable-spinlocks</option>, but performance will be poor.
33993364
</para>
34003365

34013366
<para>

meson.build

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,12 +2089,6 @@ endif
20892089
# Atomics
20902090
###############################################################
20912091

2092-
if not get_option('spinlocks')
2093-
warning('Not using spinlocks will cause poor performance')
2094-
else
2095-
cdata.set('HAVE_SPINLOCKS', 1)
2096-
endif
2097-
20982092
if not get_option('atomics')
20992093
warning('Not using atomics will cause poor performance')
21002094
else

src/backend/port/atomics.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,7 @@ pg_atomic_init_flag_impl(volatile pg_atomic_flag *ptr)
5757
StaticAssertDecl(sizeof(ptr->sema) >= sizeof(slock_t),
5858
"size mismatch of atomic_flag vs slock_t");
5959

60-
#ifndef HAVE_SPINLOCKS
61-
62-
/*
63-
* NB: If we're using semaphore based TAS emulation, be careful to use a
64-
* separate set of semaphores. Otherwise we'd get in trouble if an atomic
65-
* var would be manipulated while spinlock is held.
66-
*/
67-
s_init_lock_sema((slock_t *) &ptr->sema, true);
68-
#else
6960
SpinLockInit((slock_t *) &ptr->sema);
70-
#endif
7161

7262
ptr->value = false;
7363
}
@@ -108,15 +98,7 @@ pg_atomic_init_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 val_)
10898
StaticAssertDecl(sizeof(ptr->sema) >= sizeof(slock_t),
10999
"size mismatch of atomic_uint32 vs slock_t");
110100

111-
/*
112-
* If we're using semaphore based atomic flags, be careful about nested
113-
* usage of atomics while a spinlock is held.
114-
*/
115-
#ifndef HAVE_SPINLOCKS
116-
s_init_lock_sema((slock_t *) &ptr->sema, true);
117-
#else
118101
SpinLockInit((slock_t *) &ptr->sema);
119-
#endif
120102
ptr->value = val_;
121103
}
122104

@@ -184,15 +166,7 @@ pg_atomic_init_u64_impl(volatile pg_atomic_uint64 *ptr, uint64 val_)
184166
StaticAssertDecl(sizeof(ptr->sema) >= sizeof(slock_t),
185167
"size mismatch of atomic_uint64 vs slock_t");
186168

187-
/*
188-
* If we're using semaphore based atomic flags, be careful about nested
189-
* usage of atomics while a spinlock is held.
190-
*/
191-
#ifndef HAVE_SPINLOCKS
192-
s_init_lock_sema((slock_t *) &ptr->sema, true);
193-
#else
194169
SpinLockInit((slock_t *) &ptr->sema);
195-
#endif
196170
ptr->value = val_;
197171
}
198172

src/backend/port/posix_sema.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,7 @@ PGReserveSemaphores(int maxSemas)
217217

218218
/*
219219
* We must use ShmemAllocUnlocked(), since the spinlock protecting
220-
* ShmemAlloc() won't be ready yet. (This ordering is necessary when we
221-
* are emulating spinlocks with semaphores.)
220+
* ShmemAlloc() won't be ready yet.
222221
*/
223222
sharedSemas = (PGSemaphore)
224223
ShmemAllocUnlocked(PGSemaphoreShmemSize(maxSemas));

src/backend/port/sysv_sema.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,7 @@ PGReserveSemaphores(int maxSemas)
325325

326326
/*
327327
* We must use ShmemAllocUnlocked(), since the spinlock protecting
328-
* ShmemAlloc() won't be ready yet. (This ordering is necessary when we
329-
* are emulating spinlocks with semaphores.)
328+
* ShmemAlloc() won't be ready yet.
330329
*/
331330
sharedSemas = (PGSemaphore)
332331
ShmemAllocUnlocked(PGSemaphoreShmemSize(maxSemas));

src/backend/postmaster/launch_backend.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ typedef struct
108108
#ifdef USE_INJECTION_POINTS
109109
struct InjectionPointsCtl *ActiveInjectionPoints;
110110
#endif
111-
#ifndef HAVE_SPINLOCKS
112111
PGSemaphore *SpinlockSemaArray;
113-
#endif
114112
int NamedLWLockTrancheRequests;
115113
NamedLWLockTranche *NamedLWLockTrancheArray;
116114
LWLockPadded *MainLWLockArray;
@@ -724,9 +722,6 @@ save_backend_variables(BackendParameters *param, ClientSocket *client_sock,
724722
param->ActiveInjectionPoints = ActiveInjectionPoints;
725723
#endif
726724

727-
#ifndef HAVE_SPINLOCKS
728-
param->SpinlockSemaArray = SpinlockSemaArray;
729-
#endif
730725
param->NamedLWLockTrancheRequests = NamedLWLockTrancheRequests;
731726
param->NamedLWLockTrancheArray = NamedLWLockTrancheArray;
732727
param->MainLWLockArray = MainLWLockArray;
@@ -986,9 +981,6 @@ restore_backend_variables(BackendParameters *param)
986981
ActiveInjectionPoints = param->ActiveInjectionPoints;
987982
#endif
988983

989-
#ifndef HAVE_SPINLOCKS
990-
SpinlockSemaArray = param->SpinlockSemaArray;
991-
#endif
992984
NamedLWLockTrancheRequests = param->NamedLWLockTrancheRequests;
993985
NamedLWLockTrancheArray = param->NamedLWLockTrancheArray;
994986
MainLWLockArray = param->MainLWLockArray;

src/backend/storage/ipc/ipci.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ CalculateShmemSize(int *num_semaphores)
9494

9595
/* Compute number of semaphores we'll need */
9696
numSemas = ProcGlobalSemas();
97-
numSemas += SpinlockSemas();
9897

9998
/* Return the number of semaphores if requested by the caller */
10099
if (num_semaphores)
@@ -111,7 +110,6 @@ CalculateShmemSize(int *num_semaphores)
111110
*/
112111
size = 100000;
113112
size = add_size(size, PGSemaphoreShmemSize(numSemas));
114-
size = add_size(size, SpinlockSemaSize());
115113
size = add_size(size, hash_estimate_size(SHMEM_INDEX_SIZE,
116114
sizeof(ShmemIndexEnt)));
117115
size = add_size(size, dsm_estimate_size());
@@ -225,14 +223,6 @@ CreateSharedMemoryAndSemaphores(void)
225223
*/
226224
PGReserveSemaphores(numSemas);
227225

228-
/*
229-
* If spinlocks are disabled, initialize emulation layer (which depends on
230-
* semaphores, so the order is important here).
231-
*/
232-
#ifndef HAVE_SPINLOCKS
233-
SpinlockSemaInit();
234-
#endif
235-
236226
/*
237227
* Set up shared memory allocation mechanism
238228
*/

src/backend/storage/lmgr/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ OBJS = \
2121
predicate.o \
2222
proc.o \
2323
s_lock.o \
24-
spin.o
2524

2625
include $(top_srcdir)/src/backend/common.mk
2726

src/backend/storage/lmgr/meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ backend_sources += files(
99
'predicate.c',
1010
'proc.c',
1111
's_lock.c',
12-
'spin.c',
1312
)

src/backend/storage/lmgr/s_lock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*-------------------------------------------------------------------------
22
*
33
* s_lock.c
4-
* Hardware-dependent implementation of spinlocks.
4+
* Implementation of spinlocks.
55
*
66
* When waiting for a contended spinlock we loop tightly for awhile, then
77
* delay using pg_usleep() and try again. Preferably, "awhile" should be a

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