summaryrefslogtreecommitdiff
path: root/src/backend/storage/lmgr/proc.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2025-11-06 14:45:00 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2025-11-06 14:45:00 +0200
commitaa9c5fd3e3d7f1e6154474e39ab71377136d463a (patch)
treef061ab14e14dacd5f360ce892cca2a1b7038c096 /src/backend/storage/lmgr/proc.c
parentdaf3d99d2b8bebb3361163a11ef3d232002127c9 (diff)
Refactor shared memory allocation for semaphores
Before commit e25626677f, spinlocks were implemented using semaphores on some platforms (--disable-spinlocks). That made it necessary to initialize semaphores early, before any spinlocks could be used. Now that we don't support --disable-spinlocks anymore, we can allocate the shared memory needed for semaphores the same way as other shared memory structures. Since the semaphores are used only in the PGPROC array, move the semaphore shmem size estimation and initialization calls to ProcGlobalShmemSize() and InitProcGlobal(). Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> Discussion: https://www.postgresql.org/message-id/CAExHW5seSZpPx-znjidVZNzdagGHOk06F+Ds88MpPUbxd1kTaA@mail.gmail.com
Diffstat (limited to 'src/backend/storage/lmgr/proc.c')
-rw-r--r--src/backend/storage/lmgr/proc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index 26b201eadb8..1504fafe6d8 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -145,6 +145,7 @@ ProcGlobalShmemSize(void)
size = add_size(size, sizeof(PROC_HDR));
size = add_size(size, sizeof(slock_t));
+ size = add_size(size, PGSemaphoreShmemSize(ProcGlobalSemas()));
size = add_size(size, PGProcShmemSize());
size = add_size(size, FastPathLockShmemSize());
@@ -287,6 +288,9 @@ InitProcGlobal(void)
/* For asserts checking we did not overflow. */
fpEndPtr = fpPtr + requestSize;
+ /* Reserve space for semaphores. */
+ PGReserveSemaphores(ProcGlobalSemas());
+
for (i = 0; i < TotalProcs; i++)
{
PGPROC *proc = &procs[i];