Re: Little cleanup: Move ProcStructLock to the ProcGlobal struct - Mailing list pgsql-hackers

From Chao Li
Subject Re: Little cleanup: Move ProcStructLock to the ProcGlobal struct
Date
Msg-id D70D9385-7433-4BF6-AB1C-928E37C7F07E@gmail.com
Whole thread Raw
In response to Little cleanup: Move ProcStructLock to the ProcGlobal struct  (Heikki Linnakangas <hlinnaka@iki.fi>)
Responses Re: Little cleanup: Move ProcStructLock to the ProcGlobal struct
List pgsql-hackers

> On Feb 11, 2026, at 01:39, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
>
> 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
thanembedded 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<0001-Move-ProcStructLock-to-the-ProcGlobal-struct.patch>

Hi Heikki,

I took a quick review. You moved ProcStructLock into PROC_HDR as freeProcsLock, and deleted:
```
ProcStructLock = ShmemInitStruct(...);
SpinLockInit(ProcStructLock);
```

But I don’t see a replacement like SpinLockInit(&ProcGlobal->freeProcsLock);

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/







pgsql-hackers by date:

Previous
From: Chao Li
Date:
Subject: Is it OK to perform logging while holding a LWLock?
Next
From: Tom Lane
Date:
Subject: Re: Is it OK to perform logging while holding a LWLock?