PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/transam.h"
#include "fmgr.h"
#include "funcapi.h"
#include "miscadmin.h"
#include "storage/lwlock.h"
#include "storage/pg_shmem.h"
#include "storage/shmem.h"
#include "storage/spin.h"
#include "utils/builtins.h"
Go to the source code of this file.
Macros | |
#define | PG_GET_SHMEM_SIZES_COLS 4 |
Functions | |
static void * | ShmemAllocRaw (Size size, Size *allocated_size) |
void | InitShmemAccess (void *seghdr) |
void | InitShmemAllocation (void) |
void * | ShmemAlloc (Size size) |
void * | ShmemAllocNoError (Size size) |
void * | ShmemAllocUnlocked (Size size) |
bool | ShmemAddrIsValid (const void *addr) |
void | InitShmemIndex (void) |
HTAB * | ShmemInitHash (const char *name, long init_size, long max_size, HASHCTL *infoP, int hash_flags) |
void * | ShmemInitStruct (const char *name, Size size, bool *foundPtr) |
Size | add_size (Size s1, Size s2) |
Size | mul_size (Size s1, Size s2) |
Datum | pg_get_shmem_allocations (PG_FUNCTION_ARGS) |
Variables | |
static PGShmemHeader * | ShmemSegHdr |
static void * | ShmemBase |
static void * | ShmemEnd |
slock_t * | ShmemLock |
static HTAB * | ShmemIndex = NULL |
#define PG_GET_SHMEM_SIZES_COLS 4 |
Referenced by pg_get_shmem_allocations().
Definition at line 502 of file shmem.c.
References ereport, errcode(), errmsg(), ERROR, and s2.
Referenced by _bt_parallel_estimate_shared(), ApplyLauncherShmemSize(), AsyncShmemInit(), AsyncShmemSize(), AutoVacuumShmemSize(), BackendStatusShmemSize(), BackgroundWorkerShmemSize(), begin_parallel_vacuum(), BTreeShmemSize(), BufferShmemSize(), CheckpointerShmemSize(), CreateSharedMemoryAndSemaphores(), CreateSharedProcArray(), estimate_variable_size(), EstimateComboCIDStateSpace(), EstimateGUCStateSpace(), EstimateLibraryStateSpace(), EstimateParamExecSpace(), EstimateParamListSpace(), EstimateSnapshotSpace(), EstimateTransactionStateSpace(), ExecAggEstimate(), ExecAppendEstimate(), ExecBitmapHeapEstimate(), ExecHashEstimate(), ExecIncrementalSortEstimate(), ExecSortEstimate(), expand_planner_arrays(), hash_estimate_size(), index_parallelscan_estimate(), index_parallelscan_initialize(), LockShmemSize(), LWLockShmemSize(), MultiXactShmemSize(), pgss_memsize(), PMSignalShmemSize(), PredicateLockShmemSize(), ProcArrayShmemSize(), ProcGlobalShmemSize(), ProcSignalShmemSize(), ReplicationOriginShmemSize(), ReplicationSlotsShmemSize(), RequestAddinShmemSpace(), SerializeTransactionState(), shm_toc_estimate(), SInvalShmemSize(), SnapMgrShmemSize(), StrategyShmemSize(), table_parallelscan_estimate(), tuplesort_estimate_shared(), TwoPhaseShmemSize(), WalRcvShmemSize(), WalSndShmemSize(), and XLOGShmemSize().
void InitShmemAccess | ( | void * | seghdr | ) |
Definition at line 101 of file shmem.c.
References ShmemBase, ShmemEnd, and PGShmemHeader::totalsize.
Referenced by BackendRun(), and CreateSharedMemoryAndSemaphores().
void InitShmemAllocation | ( | void | ) |
Definition at line 116 of file shmem.c.
References Assert, CACHELINEALIGN, ShmemAlloc(), ShmemAllocUnlocked(), ShmemLock, ShmemSegHdr, ShmemVariableCache, and SpinLockInit.
Referenced by CreateSharedMemoryAndSemaphores().
void InitShmemIndex | ( | void | ) |
Definition at line 292 of file shmem.c.
References HASHCTL::entrysize, HASH_ELEM, HASH_STRINGS, HASHCTL::keysize, SHMEM_INDEX_KEYSIZE, SHMEM_INDEX_SIZE, and ShmemInitHash().
Referenced by CreateSharedMemoryAndSemaphores().
Definition at line 519 of file shmem.c.
References ereport, errcode(), errmsg(), ERROR, and s2.
Referenced by _bt_begin_parallel(), ApplyLauncherShmemSize(), AsyncShmemInit(), AsyncShmemSize(), AutoVacuumShmemSize(), BackendStatusShmemSize(), BackgroundWorkerShmemSize(), begin_parallel_vacuum(), BTreeShmemSize(), BufferShmemSize(), CheckpointerShmemSize(), CreateSharedBackendStatus(), CreateSharedProcArray(), EstimateComboCIDStateSpace(), EstimatePendingSyncsSpace(), EstimateReindexStateSpace(), EstimateSnapshotSpace(), EstimateTransactionStateSpace(), ExecAggEstimate(), ExecHashEstimate(), ExecIncrementalSortEstimate(), ExecInitParallelPlan(), ExecParallelRetrieveInstrumentation(), ExecParallelRetrieveJitInstrumentation(), ExecParallelSetupTupleQueues(), ExecSortEstimate(), hash_estimate_size(), InitializeParallelDSM(), InitPredicateLocks(), LWLockShmemSize(), PGSemaphoreShmemSize(), PMSignalShmemSize(), PostmasterMarkPIDForWorkerNotify(), PredicateLockShmemSize(), ProcArrayShmemSize(), ProcGlobalShmemSize(), ProcSignalShmemSize(), ReplicationOriginShmemSize(), ReplicationSlotsShmemSize(), shm_toc_estimate(), SInvalShmemSize(), SnapMgrShmemSize(), tuplesort_estimate_shared(), TwoPhaseShmemSize(), WalSndShmemSize(), and XLOGShmemSize().
Datum pg_get_shmem_allocations | ( | PG_FUNCTION_ARGS | ) |
Definition at line 536 of file shmem.c.
References ReturnSetInfo::allowedModes, CStringGetTextDatum, ReturnSetInfo::econtext, ExprContext::ecxt_per_query_memory, elog, ereport, errcode(), errmsg(), ERROR, PGShmemHeader::freeoffset, get_call_result_type(), hash_seq_init(), hash_seq_search(), Int64GetDatum(), IsA, LW_SHARED, LWLockAcquire(), LWLockRelease(), MemoryContextSwitchTo(), PG_GET_SHMEM_SIZES_COLS, ReturnSetInfo::returnMode, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, SFRM_Materialize, PGShmemHeader::totalsize, tuplestore_begin_heap(), tuplestore_donestoring, tuplestore_putvalues(), TYPEFUNC_COMPOSITE, values, and work_mem.
bool ShmemAddrIsValid | ( | const void * | addr | ) |
Definition at line 283 of file shmem.c.
References ShmemBase, and ShmemEnd.
Referenced by NextPredXact(), ReleasePredXact(), ShmemInitStruct(), SHMQueueDelete(), SHMQueueElemInit(), SHMQueueEmpty(), SHMQueueInit(), SHMQueueInsertAfter(), SHMQueueInsertBefore(), SHMQueueIsDetached(), SHMQueueNext(), and SHMQueuePrev().
void* ShmemAlloc | ( | Size | size | ) |
Definition at line 161 of file shmem.c.
References ereport, errcode(), errmsg(), ERROR, and ShmemAllocRaw().
Referenced by CreateLWLocks(), InitPredicateLocks(), InitProcGlobal(), InitShmemAllocation(), PostmasterMarkPIDForWorkerNotify(), and ShmemInitStruct().
void* ShmemAllocNoError | ( | Size | size | ) |
Definition at line 195 of file shmem.c.
References Assert, CACHELINEALIGN, PGShmemHeader::freeoffset, ShmemBase, ShmemLock, SpinLockAcquire, and SpinLockRelease.
Referenced by ShmemAlloc(), ShmemAllocNoError(), and ShmemInitStruct().
void* ShmemAllocUnlocked | ( | Size | size | ) |
Definition at line 247 of file shmem.c.
References Assert, ereport, errcode(), errmsg(), ERROR, PGShmemHeader::freeoffset, MAXALIGN, ShmemBase, and PGShmemHeader::totalsize.
Referenced by InitShmemAllocation(), PGReserveSemaphores(), and SpinlockSemaInit().
HTAB* ShmemInitHash | ( | const char * | name, |
long | init_size, | ||
long | max_size, | ||
HASHCTL * | infoP, | ||
int | hash_flags | ||
) |
Definition at line 341 of file shmem.c.
References HASHCTL::alloc, HASHCTL::dsize, HASH_ALLOC, HASH_ATTACH, hash_create(), HASH_DIRSIZE, hash_get_shared_size(), hash_select_dirsize(), HASH_SHARED_MEM, HASHCTL::hctl, HASHCTL::max_dsize, ShmemAllocNoError(), and ShmemInitStruct().
Referenced by InitBufTable(), InitLocks(), InitPredicateLocks(), InitShmemIndex(), and pgss_shmem_startup().
Definition at line 396 of file shmem.c.
References ShmemIndexEnt::allocated_size, Assert, CACHELINEALIGN, ereport, errcode(), errmsg(), ERROR, HASH_ENTER_NULL, HASH_REMOVE, hash_search(), PGShmemHeader::index, IsUnderPostmaster, ShmemIndexEnt::location, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), ShmemAddrIsValid(), ShmemAlloc(), ShmemAllocRaw(), ShmemSegHdr, and ShmemIndexEnt::size.
Referenced by ApplyLauncherShmemInit(), apw_init_shmem(), AsyncShmemInit(), AutoVacuumShmemInit(), AuxiliaryPidGetProc(), BackgroundWorkerShmemInit(), BTreeShmemInit(), CheckpointerShmemInit(), CommitTsShmemInit(), CreateSharedBackendStatus(), CreateSharedInvalidationState(), CreateSharedProcArray(), dsm_shmem_init(), InitBufferPool(), InitLocks(), InitPredicateLocks(), InitProcGlobal(), MultiXactShmemInit(), pgss_shmem_startup(), PMSignalShmemInit(), ProcSignalShmemInit(), ReplicationOriginShmemInit(), ReplicationSlotsShmemInit(), SerialInit(), ShmemInitHash(), SimpleLruInit(), SnapMgrInit(), StrategyInitialize(), SyncScanShmemInit(), TwoPhaseShmemInit(), WalRcvShmemInit(), WalSndShmemInit(), and XLOGShmemInit().
|
static |
Definition at line 84 of file shmem.c.
Referenced by InitShmemAccess(), ShmemAddrIsValid(), ShmemAllocRaw(), and ShmemAllocUnlocked().
|
static |
Definition at line 86 of file shmem.c.
Referenced by InitShmemAccess(), and ShmemAddrIsValid().
slock_t* ShmemLock |
Definition at line 88 of file shmem.c.
Referenced by InitShmemAllocation(), LWLockNewTrancheId(), PostmasterMarkPIDForWorkerNotify(), and ShmemAllocRaw().
|
static |
Definition at line 82 of file shmem.c.
Referenced by InitShmemAllocation(), and ShmemInitStruct().