pgsql: Refactor shared memory allocation for semaphores

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Refactor shared memory allocation for semaphores
Date: 2025-11-06 12:46:10
Message-ID: E1vGzNS-005IKr-0c@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(dot)bapat(dot)oss(at)gmail(dot)com>
Discussion: https://www.postgresql.org/message-id/CAExHW5seSZpPx-znjidVZNzdagGHOk06F+Ds88MpPUbxd1kTaA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/aa9c5fd3e3d7f1e6154474e39ab71377136d463a

Modified Files
--------------
src/backend/port/posix_sema.c | 6 +-----
src/backend/port/sysv_sema.c | 6 +-----
src/backend/storage/ipc/ipci.c | 31 +++++--------------------------
src/backend/storage/ipc/shmem.c | 3 ++-
src/backend/storage/lmgr/proc.c | 4 ++++
src/include/storage/ipc.h | 2 +-
src/include/storage/shmem.h | 1 -
7 files changed, 14 insertions(+), 39 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Álvaro Herrera 2025-11-06 12:57:48 Re: pgsql: pg_createsubscriber: Fix error complaining about the wrong thing
Previous Message Peter Eisentraut 2025-11-06 09:58:18 pgsql: Fix redundancy in error message