Little cleanup: Move ProcStructLock to the ProcGlobal struct

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Little cleanup: Move ProcStructLock to the ProcGlobal struct
Date: 2026-02-10 17:39:17
Message-ID: b78719db-0c54-409f-b185-b0d59261143f@iki.fi
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

For some reason, the ProcStructLock spinlock is allocated in a shared
memory area of its own:

/* Create ProcStructLock spinlock, too */
ProcStructLock = (slock_t *) ShmemInitStruct("ProcStructLock spinlock",
sizeof(slock_t),
&found);
SpinLockInit(ProcStructLock);

I believe that's just for historical reasons. A long long time ago,
spinlocks had to be allocated separately rather than embedded in other
structs.

The spinlock protects the freeProcs list and some other fields in
ProcGlobal, so let's put it together with those fields. It's good for
cache locality to have it next to the thing it protects, and just makes
more sense anyway.

Any objections?

- Heikki

Attachment Content-Type Size
0001-Move-ProcStructLock-to-the-ProcGlobal-struct.patch text/x-patch 8.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pierre Ducroquet 2026-02-10 17:39:40 llvmjit - improve code generated in O0
Previous Message Heikki Linnakangas 2026-02-10 17:14:44 PGPROC alignment (was Re: pgsql: Separate RecoveryConflictReasons from procsignals)