agora inbox for pgsql-hackers@postgresql.orghelp / color / mirror / Atom feed
[PATCH v9a 07/22] ci: windows: Install bison flex via msys 440+ messages / 2 participants [nested] [flat]
* [PATCH v9a 07/22] ci: windows: Install bison flex via msys @ 2026-06-03 06:21 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 440+ messages in thread From: Andres Freund @ 2026-06-03 06:21 UTC (permalink / raw) That's a fair bit faster and fails less often. --- .github/workflows/pg-ci.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pg-ci.yml b/.github/workflows/pg-ci.yml index b05c3539ab6..e35170956e8 100644 --- a/.github/workflows/pg-ci.yml +++ b/.github/workflows/pg-ci.yml @@ -760,10 +760,25 @@ jobs: Add-Content $env:GITHUB_ENV "PATH=$filtered" Write-Host "Removed Mercurial entries from PATH" + # Install some dependencies via msys64, that seems to be the fastest and + # most reliable + - name: Install dependencies, Mingw + shell: 'C:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' + run: | + # Install some dependencies via msys64, that seems to be the fastest + # and most reliable + pacman -S --noconfirm --needed --asdeps \ + bison flex + + # Make bison and flex visible + echo C:/msys64/usr/bin >> "$GITHUB_PATH" + + # Don't prefer mingw's perl + echo C:/Strawberry/perl/bin >> "$GITHUB_PATH" + - name: Install dependencies shell: pwsh run: | - choco install -y --no-progress --limitoutput diffutils winflexbison3 # meson + ninja aren't preinstalled on windows-2022. Install via pip python -m pip install --upgrade meson ninja -- 2.54.0.380.gc69baaf57b --lyfxwjjve3vodszg Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v9a-0008-ci-mingw-Don-t-install-make-use-asdeps.patch" ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic @ 2026-07-22 15:32 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-22 15:32 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index f973494abb1..5be06073ea1 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBuf = InvalidBuffer; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBuf, InvalidBuffer); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBuf(Buffer buffer) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBuf = buffer; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBuf, buffer); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBuf(Buffer buffer) Buffer GetStartupBufferPinWaitBuf(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBuf; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBuf); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 4c3f431b4eb..abe40001d9a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -500,7 +500,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer that Startup process waits for pin on, or InvalidBuffer */ - Buffer startupBufferPinWaitBuf; + pg_atomic_uint32 startupBufferPinWaitBuf; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Xf36GNcW+0xZNily Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0006-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
end of thread, other threads:[~2026-07-22 15:32 UTC | newest] Thread overview: 440+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-06-03 06:21 [PATCH v9a 07/22] ci: windows: Install bison flex via msys Andres Freund <andres@anarazel.de> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-22 15:32 [PATCH v2 5/9] convert PROC_HDR->startupBufferPinWaitBuf to an atomic Nathan Bossart <nathan@postgresql.org>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox