agora inbox for pgsql-hackers@postgresql.orghelp / color / mirror / Atom feed
[PATCH v8 2/6] Handle pg_get_viewdef default args in system_functions.sql 440+ messages / 2 participants [nested] [flat]
* [PATCH v8 2/6] Handle pg_get_viewdef default args in system_functions.sql @ 2025-12-09 17:33 Mark Wong <markwkm@gmail.com> 0 siblings, 0 replies; 440+ messages in thread From: Mark Wong @ 2025-12-09 17:33 UTC (permalink / raw) Modernize pg_get_viewdef to use proargdefaults to handle the optional pretty argument for both versions that use OID or view name. --- src/backend/utils/adt/ruleutils.c | 44 ------------------------------- src/include/catalog/pg_proc.dat | 17 +++++------- 2 files changed, 6 insertions(+), 55 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 76705db3dac..fd00d6c3515 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -669,25 +669,6 @@ pg_get_ruledef_worker(Oid ruleoid, int prettyFlags) */ Datum pg_get_viewdef(PG_FUNCTION_ARGS) -{ - /* By OID */ - Oid viewoid = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_viewdef_worker(viewoid, prettyFlags, WRAP_COLUMN_DEFAULT); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - - -Datum -pg_get_viewdef_ext(PG_FUNCTION_ARGS) { /* By OID */ Oid viewoid = PG_GETARG_OID(0); @@ -727,31 +708,6 @@ pg_get_viewdef_wrap(PG_FUNCTION_ARGS) Datum pg_get_viewdef_name(PG_FUNCTION_ARGS) -{ - /* By qualified name */ - text *viewname = PG_GETARG_TEXT_PP(0); - int prettyFlags; - RangeVar *viewrel; - Oid viewoid; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - /* Look up view name. Can't lock it - we might not have privileges. */ - viewrel = makeRangeVarFromNameList(textToQualifiedNameList(viewname)); - viewoid = RangeVarGetRelid(viewrel, NoLock, false); - - res = pg_get_viewdef_worker(viewoid, prettyFlags, WRAP_COLUMN_DEFAULT); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - - -Datum -pg_get_viewdef_name_ext(PG_FUNCTION_ARGS) { /* By qualified name */ text *viewname = PG_GETARG_TEXT_PP(0); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 45e4483692d..5b22fdc8e08 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3981,13 +3981,6 @@ { oid => '6469', descr => 'source text of a property graph', proname => 'pg_get_propgraphdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_propgraphdef' }, -{ oid => '1640', descr => 'select statement of a view', - proname => 'pg_get_viewdef', provolatile => 's', proparallel => 'r', - prorettype => 'text', proargtypes => 'text', - prosrc => 'pg_get_viewdef_name' }, -{ oid => '1641', descr => 'select statement of a view', - proname => 'pg_get_viewdef', provolatile => 's', proparallel => 'r', - prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_viewdef' }, { oid => '1642', descr => 'role name by OID (with fallback)', proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name', proargtypes => 'oid', prosrc => 'pg_get_userbyid' }, @@ -8567,15 +8560,17 @@ proargtypes => 'oid bool', proargnames => '{rule,pretty}', proargdefaults => '{false}',prosrc => 'pg_get_ruledef' }, { oid => '2505', - descr => 'select statement of a view with pretty-print option', + descr => 'select statement of a view', proname => 'pg_get_viewdef', provolatile => 's', proparallel => 'r', prorettype => 'text', proargtypes => 'text bool', - prosrc => 'pg_get_viewdef_name_ext' }, + proargnames => '{view,pretty}', proargdefaults => '{false}', + prosrc => 'pg_get_viewdef_name' }, { oid => '2506', - descr => 'select statement of a view with pretty-print option', + descr => 'select statement of a view', proname => 'pg_get_viewdef', provolatile => 's', proparallel => 'r', prorettype => 'text', proargtypes => 'oid bool', - prosrc => 'pg_get_viewdef_ext' }, + proargnames => '{view,pretty}', proargdefaults => '{false}', + prosrc => 'pg_get_viewdef' }, { oid => '3159', descr => 'select statement of a view with pretty-printing and specified line wrapping', proname => 'pg_get_viewdef', provolatile => 's', proparallel => 'r', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0003-Handle-pg_get_indexdef-default-args-in-system_fun.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-convert-Sharedsort-currentWorker-workersFinished-.patch ^ permalink raw reply [nested|flat] 440+ messages in thread
* [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic @ 2026-07-09 19:26 Nathan Bossart <nathan@postgresql.org> 0 siblings, 0 replies; 440+ messages in thread From: Nathan Bossart @ 2026-07-09 19:26 UTC (permalink / raw) --- src/backend/storage/lmgr/proc.c | 12 +++--------- src/include/storage/proc.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 9d6e69175a5..5f314efb289 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -239,7 +239,7 @@ ProcGlobalShmemInit(void *arg) dlist_init(&ProcGlobal->autovacFreeProcs); dlist_init(&ProcGlobal->bgworkerFreeProcs); dlist_init(&ProcGlobal->walsenderFreeProcs); - ProcGlobal->startupBufferPinWaitBufId = -1; + pg_atomic_init_u32(&ProcGlobal->startupBufferPinWaitBufId, -1); pg_atomic_init_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->walwriterProc, INVALID_PROC_NUMBER); pg_atomic_init_u32(&ProcGlobal->checkpointerProc, INVALID_PROC_NUMBER); @@ -768,10 +768,7 @@ InitAuxiliaryProcess(void) void SetStartupBufferPinWaitBufId(int bufid) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - procglobal->startupBufferPinWaitBufId = bufid; + pg_atomic_write_u32(&ProcGlobal->startupBufferPinWaitBufId, bufid); } /* @@ -780,10 +777,7 @@ SetStartupBufferPinWaitBufId(int bufid) int GetStartupBufferPinWaitBufId(void) { - /* use volatile pointer to prevent code rearrangement */ - volatile PROC_HDR *procglobal = ProcGlobal; - - return procglobal->startupBufferPinWaitBufId; + return pg_atomic_read_u32(&ProcGlobal->startupBufferPinWaitBufId); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 03a1a466fa8..e2034255124 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -499,7 +499,7 @@ typedef struct PROC_HDR /* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ - int startupBufferPinWaitBufId; + pg_atomic_uint32 startupBufferPinWaitBufId; } PROC_HDR; extern PGDLLIMPORT PROC_HDR *ProcGlobal; -- 2.50.1 (Apple Git-155) --Ot5x3ffkWEuxilWO Content-Type: text/plain; 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 -- 2025-12-09 17:33 [PATCH v8 2/6] Handle pg_get_viewdef default args in system_functions.sql Mark Wong <markwkm@gmail.com> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.org> 2026-07-09 19:26 [PATCH v1 4/8] convert PROC_HDR->startupBufferPinWaitBufId to an atomic Nathan Bossart <nathan@postgresql.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