mirror of
https://github.com/postgres/postgres.git
synced 2025-06-27 23:21:58 +03:00
Rename some shared memory initialization routines
To make them follow the usual naming convention where FoobarShmemSize() calculates the amount of shared memory needed by Foobar subsystem, and FoobarShmemInit() performs the initialization. I didn't rename CreateLWLocks() and InitShmmeIndex(), because they are a little special. They need to be called before any of the other ShmemInit() functions, because they set up the shared memory bookkeeping itself. I also didn't rename InitProcGlobal(), because unlike other Shmeminit functions, it's not called by individual backends. Reviewed-by: Andreas Karlsson Discussion: https://www.postgresql.org/message-id/c09694ff-2453-47e5-b26c-32a16cd75ce6@iki.fi
This commit is contained in:
@ -65,7 +65,7 @@ CkptSortItem *CkptBufferIds;
|
|||||||
* postmaster, or in a standalone backend).
|
* postmaster, or in a standalone backend).
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
InitBufferPool(void)
|
BufferManagerShmemInit(void)
|
||||||
{
|
{
|
||||||
bool foundBufs,
|
bool foundBufs,
|
||||||
foundDescs,
|
foundDescs,
|
||||||
@ -151,13 +151,13 @@ InitBufferPool(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* BufferShmemSize
|
* BufferManagerShmemSize
|
||||||
*
|
*
|
||||||
* compute the size of shared memory for the buffer pool including
|
* compute the size of shared memory for the buffer pool including
|
||||||
* data pages, buffer descriptors, hash tables, etc.
|
* data pages, buffer descriptors, hash tables, etc.
|
||||||
*/
|
*/
|
||||||
Size
|
Size
|
||||||
BufferShmemSize(void)
|
BufferManagerShmemSize(void)
|
||||||
{
|
{
|
||||||
Size size = 0;
|
Size size = 0;
|
||||||
|
|
||||||
|
@ -3582,7 +3582,7 @@ AtEOXact_Buffers(bool isCommit)
|
|||||||
* buffer pool.
|
* buffer pool.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
InitBufferPoolAccess(void)
|
InitBufferManagerAccess(void)
|
||||||
{
|
{
|
||||||
HASHCTL hash_ctl;
|
HASHCTL hash_ctl;
|
||||||
|
|
||||||
|
@ -506,7 +506,7 @@ StrategyInitialize(bool init)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Grab the whole linked list of free buffers for our strategy. We
|
* Grab the whole linked list of free buffers for our strategy. We
|
||||||
* assume it was previously set up by InitBufferPool().
|
* assume it was previously set up by BufferManagerShmemInit().
|
||||||
*/
|
*/
|
||||||
StrategyControl->firstFreeBuffer = 0;
|
StrategyControl->firstFreeBuffer = 0;
|
||||||
StrategyControl->lastFreeBuffer = NBuffers - 1;
|
StrategyControl->lastFreeBuffer = NBuffers - 1;
|
||||||
|
@ -115,7 +115,7 @@ CalculateShmemSize(int *num_semaphores)
|
|||||||
sizeof(ShmemIndexEnt)));
|
sizeof(ShmemIndexEnt)));
|
||||||
size = add_size(size, dsm_estimate_size());
|
size = add_size(size, dsm_estimate_size());
|
||||||
size = add_size(size, DSMRegistryShmemSize());
|
size = add_size(size, DSMRegistryShmemSize());
|
||||||
size = add_size(size, BufferShmemSize());
|
size = add_size(size, BufferManagerShmemSize());
|
||||||
size = add_size(size, LockManagerShmemSize());
|
size = add_size(size, LockManagerShmemSize());
|
||||||
size = add_size(size, PredicateLockShmemSize());
|
size = add_size(size, PredicateLockShmemSize());
|
||||||
size = add_size(size, ProcGlobalShmemSize());
|
size = add_size(size, ProcGlobalShmemSize());
|
||||||
@ -132,7 +132,7 @@ CalculateShmemSize(int *num_semaphores)
|
|||||||
size = add_size(size, LWLockShmemSize());
|
size = add_size(size, LWLockShmemSize());
|
||||||
size = add_size(size, ProcArrayShmemSize());
|
size = add_size(size, ProcArrayShmemSize());
|
||||||
size = add_size(size, BackendStatusShmemSize());
|
size = add_size(size, BackendStatusShmemSize());
|
||||||
size = add_size(size, SInvalShmemSize());
|
size = add_size(size, SharedInvalShmemSize());
|
||||||
size = add_size(size, PMSignalShmemSize());
|
size = add_size(size, PMSignalShmemSize());
|
||||||
size = add_size(size, ProcSignalShmemSize());
|
size = add_size(size, ProcSignalShmemSize());
|
||||||
size = add_size(size, CheckpointerShmemSize());
|
size = add_size(size, CheckpointerShmemSize());
|
||||||
@ -286,7 +286,7 @@ CreateOrAttachShmemStructs(void)
|
|||||||
CommitTsShmemInit();
|
CommitTsShmemInit();
|
||||||
SUBTRANSShmemInit();
|
SUBTRANSShmemInit();
|
||||||
MultiXactShmemInit();
|
MultiXactShmemInit();
|
||||||
InitBufferPool();
|
BufferManagerShmemInit();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set up lock manager
|
* Set up lock manager
|
||||||
@ -296,22 +296,22 @@ CreateOrAttachShmemStructs(void)
|
|||||||
/*
|
/*
|
||||||
* Set up predicate lock manager
|
* Set up predicate lock manager
|
||||||
*/
|
*/
|
||||||
InitPredicateLocks();
|
PredicateLockShmemInit();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set up process table
|
* Set up process table
|
||||||
*/
|
*/
|
||||||
if (!IsUnderPostmaster)
|
if (!IsUnderPostmaster)
|
||||||
InitProcGlobal();
|
InitProcGlobal();
|
||||||
CreateSharedProcArray();
|
ProcArrayShmemInit();
|
||||||
CreateSharedBackendStatus();
|
BackendStatusShmemInit();
|
||||||
TwoPhaseShmemInit();
|
TwoPhaseShmemInit();
|
||||||
BackgroundWorkerShmemInit();
|
BackgroundWorkerShmemInit();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set up shared-inval messaging
|
* Set up shared-inval messaging
|
||||||
*/
|
*/
|
||||||
CreateSharedInvalidationState();
|
SharedInvalShmemInit();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set up interprocess signaling mechanisms
|
* Set up interprocess signaling mechanisms
|
||||||
|
@ -370,7 +370,7 @@ static inline FullTransactionId FullXidRelativeTo(FullTransactionId rel,
|
|||||||
static void GlobalVisUpdateApply(ComputeXidHorizonsResult *horizons);
|
static void GlobalVisUpdateApply(ComputeXidHorizonsResult *horizons);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Report shared-memory space needed by CreateSharedProcArray.
|
* Report shared-memory space needed by ProcArrayShmemInit
|
||||||
*/
|
*/
|
||||||
Size
|
Size
|
||||||
ProcArrayShmemSize(void)
|
ProcArrayShmemSize(void)
|
||||||
@ -415,7 +415,7 @@ ProcArrayShmemSize(void)
|
|||||||
* Initialize the shared PGPROC array during postmaster startup.
|
* Initialize the shared PGPROC array during postmaster startup.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
CreateSharedProcArray(void)
|
ProcArrayShmemInit(void)
|
||||||
{
|
{
|
||||||
bool found;
|
bool found;
|
||||||
|
|
||||||
|
@ -212,10 +212,10 @@ static void CleanupInvalidationState(int status, Datum arg);
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SInvalShmemSize --- return shared-memory space needed
|
* SharedInvalShmemSize --- return shared-memory space needed
|
||||||
*/
|
*/
|
||||||
Size
|
Size
|
||||||
SInvalShmemSize(void)
|
SharedInvalShmemSize(void)
|
||||||
{
|
{
|
||||||
Size size;
|
Size size;
|
||||||
|
|
||||||
@ -227,18 +227,18 @@ SInvalShmemSize(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CreateSharedInvalidationState
|
* SharedInvalShmemInit
|
||||||
* Create and initialize the SI message buffer
|
* Create and initialize the SI message buffer
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
CreateSharedInvalidationState(void)
|
SharedInvalShmemInit(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
bool found;
|
bool found;
|
||||||
|
|
||||||
/* Allocate space in shared memory */
|
/* Allocate space in shared memory */
|
||||||
shmInvalBuffer = (SISeg *)
|
shmInvalBuffer = (SISeg *)
|
||||||
ShmemInitStruct("shmInvalBuffer", SInvalShmemSize(), &found);
|
ShmemInitStruct("shmInvalBuffer", SharedInvalShmemSize(), &found);
|
||||||
if (found)
|
if (found)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@
|
|||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
*
|
*
|
||||||
* housekeeping for setting up shared memory predicate lock structures
|
* housekeeping for setting up shared memory predicate lock structures
|
||||||
* InitPredicateLocks(void)
|
* PredicateLockShmemInit(void)
|
||||||
* PredicateLockShmemSize(void)
|
* PredicateLockShmemSize(void)
|
||||||
*
|
*
|
||||||
* predicate lock reporting
|
* predicate lock reporting
|
||||||
@ -1127,7 +1127,7 @@ CheckPointPredicate(void)
|
|||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* InitPredicateLocks -- Initialize the predicate locking data structures.
|
* PredicateLockShmemInit -- Initialize the predicate locking data structures.
|
||||||
*
|
*
|
||||||
* This is called from CreateSharedMemoryAndSemaphores(), which see for
|
* This is called from CreateSharedMemoryAndSemaphores(), which see for
|
||||||
* more comments. In the normal postmaster case, the shared hash tables
|
* more comments. In the normal postmaster case, the shared hash tables
|
||||||
@ -1137,7 +1137,7 @@ CheckPointPredicate(void)
|
|||||||
* shared hash tables.
|
* shared hash tables.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
InitPredicateLocks(void)
|
PredicateLockShmemInit(void)
|
||||||
{
|
{
|
||||||
HASHCTL info;
|
HASHCTL info;
|
||||||
long max_table_size;
|
long max_table_size;
|
||||||
|
@ -77,7 +77,7 @@ static void pgstat_setup_backend_status_context(void);
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Report shared-memory space needed by CreateSharedBackendStatus.
|
* Report shared-memory space needed by BackendStatusShmemInit.
|
||||||
*/
|
*/
|
||||||
Size
|
Size
|
||||||
BackendStatusShmemSize(void)
|
BackendStatusShmemSize(void)
|
||||||
@ -113,7 +113,7 @@ BackendStatusShmemSize(void)
|
|||||||
* during postmaster startup.
|
* during postmaster startup.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
CreateSharedBackendStatus(void)
|
BackendStatusShmemInit(void)
|
||||||
{
|
{
|
||||||
Size size;
|
Size size;
|
||||||
bool found;
|
bool found;
|
||||||
|
@ -592,7 +592,7 @@ BaseInit(void)
|
|||||||
/* Do local initialization of storage and buffer managers */
|
/* Do local initialization of storage and buffer managers */
|
||||||
InitSync();
|
InitSync();
|
||||||
smgrinit();
|
smgrinit();
|
||||||
InitBufferPoolAccess();
|
InitBufferManagerAccess();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize temporary file access after pgstat, so that the temporary
|
* Initialize temporary file access after pgstat, so that the temporary
|
||||||
|
@ -249,7 +249,7 @@ extern Buffer ExtendBufferedRelTo(BufferManagerRelation bmr,
|
|||||||
BlockNumber extend_to,
|
BlockNumber extend_to,
|
||||||
ReadBufferMode mode);
|
ReadBufferMode mode);
|
||||||
|
|
||||||
extern void InitBufferPoolAccess(void);
|
extern void InitBufferManagerAccess(void);
|
||||||
extern void AtEOXact_Buffers(bool isCommit);
|
extern void AtEOXact_Buffers(bool isCommit);
|
||||||
extern char *DebugPrintBufferRefcount(Buffer buffer);
|
extern char *DebugPrintBufferRefcount(Buffer buffer);
|
||||||
extern void CheckPointBuffers(int flags);
|
extern void CheckPointBuffers(int flags);
|
||||||
@ -300,8 +300,8 @@ extern void LimitAdditionalLocalPins(uint32 *additional_pins);
|
|||||||
extern bool EvictUnpinnedBuffer(Buffer buf);
|
extern bool EvictUnpinnedBuffer(Buffer buf);
|
||||||
|
|
||||||
/* in buf_init.c */
|
/* in buf_init.c */
|
||||||
extern void InitBufferPool(void);
|
extern void BufferManagerShmemInit(void);
|
||||||
extern Size BufferShmemSize(void);
|
extern Size BufferManagerShmemSize(void);
|
||||||
|
|
||||||
/* in localbuf.c */
|
/* in localbuf.c */
|
||||||
extern void AtProcExit_LocalBuffers(void);
|
extern void AtProcExit_LocalBuffers(void);
|
||||||
|
@ -37,7 +37,7 @@ typedef void *SerializableXactHandle;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* housekeeping for shared memory predicate lock structures */
|
/* housekeeping for shared memory predicate lock structures */
|
||||||
extern void InitPredicateLocks(void);
|
extern void PredicateLockShmemInit(void);
|
||||||
extern Size PredicateLockShmemSize(void);
|
extern Size PredicateLockShmemSize(void);
|
||||||
|
|
||||||
extern void CheckPointPredicate(void);
|
extern void CheckPointPredicate(void);
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
|
|
||||||
extern Size ProcArrayShmemSize(void);
|
extern Size ProcArrayShmemSize(void);
|
||||||
extern void CreateSharedProcArray(void);
|
extern void ProcArrayShmemInit(void);
|
||||||
extern void ProcArrayAdd(PGPROC *proc);
|
extern void ProcArrayAdd(PGPROC *proc);
|
||||||
extern void ProcArrayRemove(PGPROC *proc, TransactionId latestXid);
|
extern void ProcArrayRemove(PGPROC *proc, TransactionId latestXid);
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
/*
|
/*
|
||||||
* prototypes for functions in sinvaladt.c
|
* prototypes for functions in sinvaladt.c
|
||||||
*/
|
*/
|
||||||
extern Size SInvalShmemSize(void);
|
extern Size SharedInvalShmemSize(void);
|
||||||
extern void CreateSharedInvalidationState(void);
|
extern void SharedInvalShmemInit(void);
|
||||||
extern void SharedInvalBackendInit(bool sendOnly);
|
extern void SharedInvalBackendInit(bool sendOnly);
|
||||||
|
|
||||||
extern void SIInsertDataEntries(const SharedInvalidationMessage *data, int n);
|
extern void SIInsertDataEntries(const SharedInvalidationMessage *data, int n);
|
||||||
|
@ -299,7 +299,7 @@ extern PGDLLIMPORT PgBackendStatus *MyBEEntry;
|
|||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
extern Size BackendStatusShmemSize(void);
|
extern Size BackendStatusShmemSize(void);
|
||||||
extern void CreateSharedBackendStatus(void);
|
extern void BackendStatusShmemInit(void);
|
||||||
|
|
||||||
|
|
||||||
/* ----------
|
/* ----------
|
||||||
|
Reference in New Issue
Block a user