|
PostgreSQL Source Code git master
|
#include "postgres.h"#include <unistd.h>#include "access/slru.h"#include "common/int.h"#include "fmgr.h"#include "funcapi.h"#include "miscadmin.h"#include "port/pg_bitutils.h"#include "port/pg_numa.h"#include "storage/lwlock.h"#include "storage/pg_shmem.h"#include "storage/shmem.h"#include "storage/shmem_internal.h"#include "storage/spin.h"#include "utils/builtins.h"#include "utils/tuplestore.h"
Go to the source code of this file.
Data Structures | |
| struct | ShmemRequest |
| struct | ShmemAllocatorData |
| struct | ShmemIndexEnt |
Macros | |
| #define | ShmemIndexLock (&ShmemAllocator->index_lock) |
| #define | SHMEM_INDEX_KEYSIZE (48) |
| #define | SHMEM_INDEX_ADDITIONAL_SIZE (128) |
| #define | PG_GET_SHMEM_SIZES_COLS 4 |
| #define | PG_GET_SHMEM_NUMA_SIZES_COLS 3 |
Typedefs | |
| typedef struct ShmemAllocatorData | ShmemAllocatorData |
Enumerations | |
| enum | shmem_request_state { SRS_INITIAL , SRS_REQUESTING , SRS_INITIALIZING , SRS_ATTACHING , SRS_AFTER_STARTUP_ATTACH_OR_INIT , SRS_DONE } |
| #define PG_GET_SHMEM_NUMA_SIZES_COLS 3 |
| #define PG_GET_SHMEM_SIZES_COLS 4 |
| #define ShmemIndexLock (&ShmemAllocator->index_lock) |
| Enumerator | |
|---|---|
| SRS_INITIAL | |
| SRS_REQUESTING | |
| SRS_INITIALIZING | |
| SRS_ATTACHING | |
| SRS_AFTER_STARTUP_ATTACH_OR_INIT | |
| SRS_DONE | |
Definition at line 185 of file shmem.c.
Definition at line 1043 of file shmem.c.
References ereport, errcode(), errmsg, ERROR, fb(), pg_add_size_overflow(), result, s1, and s2.
Referenced by _brin_parallel_estimate_shared(), _bt_parallel_estimate_shared(), _gin_parallel_estimate_shared(), ApplyLauncherShmemRequest(), AsyncShmemRequest(), AutoVacuumShmemRequest(), BackgroundWorkerShmemRequest(), btestimateparallelscan(), BTreeShmemRequest(), CalculateFastPathLockShmemSize(), CalculateShmemSize(), CheckpointerShmemRequest(), CreateAnonymousSegment(), estimate_variable_size(), EstimateClientConnectionInfoSpace(), EstimateComboCIDStateSpace(), EstimateGUCStateSpace(), EstimateLibraryStateSpace(), EstimateParamExecSpace(), EstimateParamListSpace(), EstimateSnapshotSpace(), EstimateTransactionStateSpace(), ExecAggEstimate(), ExecAppendEstimate(), ExecBitmapHeapEstimate(), ExecBitmapHeapInitializeDSM(), ExecHashEstimate(), ExecIncrementalSortEstimate(), ExecMemoizeEstimate(), ExecSortEstimate(), expand_planner_arrays(), hash_estimate_size(), index_parallelscan_estimate(), index_parallelscan_initialize(), InitializeShmemGUCs(), MultiXactShmemRequest(), PMSignalShmemRequest(), PredicateLockShmemRequest(), ProcArrayShmemRequest(), ProcGlobalShmemRequest(), ProcSignalShmemRequest(), ReplicationOriginShmemRequest(), ReplicationSlotsShmemRequest(), RequestAddinShmemSpace(), SerializeTransactionState(), SharedInvalShmemRequest(), shm_toc_estimate(), ShmemGetRequestedSize(), StatsShmemSize(), table_parallelscan_estimate(), tuplesort_estimate_shared(), TwoPhaseShmemRequest(), WaitLSNShmemRequest(), WalSndShmemRequest(), and XLOGShmemRequest().
|
static |
Definition at line 578 of file shmem.c.
References ereport, errmsg, ERROR, fb(), HASH_FIND, hash_search(), name, SHMEM_ATTACH_UNKNOWN_SIZE, shmem_hash_attach(), SHMEM_KIND_HASH, SHMEM_KIND_SLRU, SHMEM_KIND_STRUCT, shmem_slru_attach(), and ShmemIndex.
Referenced by CallShmemCallbacksAfterStartup(), and ShmemInitStruct().
|
static |
Definition at line 896 of file shmem.c.
References Assert, ShmemCallbacks::attach_fn, AttachShmemIndexEntry(), elog, ERROR, fb(), foreach_ptr, HASH_FIND, hash_search(), ShmemCallbacks::init_fn, InitShmemIndexEntry(), list_free_deep(), LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), NIL, ShmemCallbacks::opaque_arg, pending_shmem_requests, ShmemCallbacks::request_fn, ShmemIndex, ShmemIndexLock, SRS_AFTER_STARTUP_ATTACH_OR_INIT, SRS_DONE, and SRS_REQUESTING.
Referenced by RegisterShmemCallbacks().
| void InitShmemAllocator | ( | PGShmemHeader * | seghdr | ) |
Definition at line 635 of file shmem.c.
References Assert, CACHELINEALIGN, HASHCTL::entrysize, ereport, errcode(), errmsg, ERROR, fb(), ShmemAllocatorData::free_offset, HASH_ELEM, HASH_ENTER, hash_estimate_size(), HASH_FIXED_SIZE, hash_search(), HASH_STRINGS, ShmemAllocatorData::index, ShmemAllocatorData::index_lock, ShmemAllocatorData::index_size, IsUnderPostmaster, HASHCTL::keysize, list_length(), LWLockInitialize(), MAXALIGN, pending_shmem_requests, result, shmem_hash_create(), SHMEM_INDEX_ADDITIONAL_SIZE, SHMEM_INDEX_KEYSIZE, ShmemAllocatorData::shmem_lock, ShmemAlloc(), ShmemAllocator, ShmemBase, ShmemEnd, ShmemIndex, ShmemSegHdr, SpinLockInit(), SRS_INITIAL, SRS_INITIALIZING, SRS_REQUESTING, and PGShmemHeader::totalsize.
Referenced by CreateSharedMemoryAndSemaphores().
|
static |
Definition at line 509 of file shmem.c.
References elog, ereport, errcode(), errmsg, ERROR, fb(), HASH_ENTER_NULL, HASH_REMOVE, hash_search(), name, shmem_hash_init(), SHMEM_KIND_HASH, SHMEM_KIND_SLRU, SHMEM_KIND_STRUCT, shmem_slru_init(), ShmemAllocRaw(), and ShmemIndex.
Referenced by CallShmemCallbacksAfterStartup(), ShmemInitRequested(), and ShmemInitStruct().
Definition at line 1058 of file shmem.c.
References ereport, errcode(), errmsg, ERROR, fb(), pg_mul_size_overflow(), result, s1, and s2.
Referenced by _brin_begin_parallel(), _bt_begin_parallel(), _gin_begin_parallel(), AioBackendShmemSize(), AioHandleDataShmemSize(), AioHandleIOVShmemSize(), AioHandleShmemSize(), ApplyLauncherShmemRequest(), AsyncShmemRequest(), AutoVacuumShmemRequest(), BackendStatusShmemAttach(), BackendStatusShmemRequest(), BackgroundWorkerShmemRequest(), BTreeShmemRequest(), CalculateFastPathLockShmemSize(), CheckpointerShmemRequest(), EstimateComboCIDStateSpace(), EstimatePendingSyncsSpace(), EstimateReindexStateSpace(), EstimateSnapshotSpace(), EstimateTransactionStateSpace(), ExecAggEstimate(), ExecBitmapHeapEstimate(), ExecBitmapHeapInitializeDSM(), ExecHashEstimate(), ExecIncrementalSortEstimate(), ExecInitParallelPlan(), ExecMemoizeEstimate(), ExecParallelRetrieveInstrumentation(), ExecParallelRetrieveJitInstrumentation(), ExecParallelSetupTupleQueues(), ExecSortEstimate(), hash_estimate_size(), InitializeParallelDSM(), MultiXactShmemRequest(), parallel_vacuum_init(), PGSemaphoreShmemRequest(), PMSignalShmemRequest(), PredicateLockShmemRequest(), ProcArrayShmemRequest(), ProcGlobalShmemRequest(), ProcSignalShmemRequest(), ReplicationOriginShmemRequest(), ReplicationSlotsShmemRequest(), SharedInvalShmemRequest(), shm_toc_estimate(), tuplesort_estimate_shared(), TwoPhaseShmemRequest(), WaitLSNShmemRequest(), WalSndShmemRequest(), and XLOGShmemRequest().
| Datum pg_get_shmem_allocations | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1071 of file shmem.c.
References CStringGetTextDatum, fb(), ShmemAllocatorData::free_offset, hash_seq_init(), hash_seq_search(), InitMaterializedSRF(), Int64GetDatum(), LW_SHARED, LWLockAcquire(), LWLockRelease(), PG_GET_SHMEM_SIZES_COLS, ShmemAllocator, ShmemIndex, ShmemIndexLock, ShmemSegHdr, PGShmemHeader::totalsize, tuplestore_putvalues(), and values.
| Datum pg_get_shmem_allocations_numa | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1128 of file shmem.c.
References CHECK_FOR_INTERRUPTS, CStringGetTextDatum, DEBUG1, elog, ERROR, fb(), firstNumaTouch, hash_seq_init(), hash_seq_search(), i, InitMaterializedSRF(), Int32GetDatum(), Int64GetDatum(), LW_SHARED, LWLockAcquire(), LWLockRelease(), palloc0_array, palloc_array, PG_GET_SHMEM_NUMA_SIZES_COLS, pg_get_shmem_pagesize(), pg_numa_get_max_node(), pg_numa_init(), pg_numa_query_pages(), pg_numa_touch_mem_if_required, ShmemIndex, ShmemIndexLock, ShmemSegHdr, PGShmemHeader::totalsize, tuplestore_putvalues(), TYPEALIGN, TYPEALIGN_DOWN, UINT64_FORMAT, and values.
Definition at line 1299 of file shmem.c.
References Assert, fb(), GetHugePageSize(), HUGE_PAGES_ON, huge_pages_status, HUGE_PAGES_UNKNOWN, and IsUnderPostmaster.
Referenced by pg_buffercache_os_pages_internal(), and pg_get_shmem_allocations_numa().
| Datum pg_numa_available | ( | PG_FUNCTION_ARGS | ) |
| void RegisterShmemCallbacks | ( | const ShmemCallbacks * | callbacks | ) |
Definition at line 871 of file shmem.c.
References CallShmemCallbacksAfterStartup(), elog, ERROR, ShmemCallbacks::flags, IsUnderPostmaster, lappend(), registered_shmem_callbacks, SHMEM_CALLBACKS_ALLOW_AFTER_STARTUP, and SRS_DONE.
Referenced by _PG_init().
Definition at line 740 of file shmem.c.
References Assert, IsUnderPostmaster, NIL, pending_shmem_requests, and SRS_INITIAL.
Referenced by PostmasterStateMachine().
Definition at line 761 of file shmem.c.
References ereport, errcode(), errmsg, ERROR, fb(), and ShmemAllocRaw().
Referenced by InitShmemAllocator(), and StatsShmemInit().
Definition at line 781 of file shmem.c.
References ShmemAllocRaw().
Definition at line 795 of file shmem.c.
References Assert, fb(), ShmemAllocatorData::free_offset, PG_CACHE_LINE_SIZE, ShmemAllocatorData::shmem_lock, ShmemAllocator, ShmemBase, ShmemSegHdr, SpinLockAcquire(), SpinLockRelease(), and TYPEALIGN.
Referenced by InitShmemIndexEntry(), ShmemAlloc(), and ShmemAllocNoError().
Definition at line 974 of file shmem.c.
References Assert, fb(), lfirst, ShmemCallbacks::opaque_arg, registered_shmem_callbacks, ShmemCallbacks::request_fn, SRS_INITIAL, and SRS_REQUESTING.
Referenced by BootstrapModeMain(), PostgresSingleUserMain(), PostmasterMain(), and PostmasterStateMachine().
Definition at line 391 of file shmem.c.
References add_size(), CACHELINEALIGN, fb(), foreach_ptr, hash_estimate_size(), list_length(), pending_shmem_requests, PG_CACHE_LINE_SIZE, SHMEM_INDEX_ADDITIONAL_SIZE, and TYPEALIGN.
Referenced by CalculateShmemSize().
Definition at line 424 of file shmem.c.
References Assert, fb(), foreach_ptr, InitShmemIndexEntry(), IsUnderPostmaster, list_free_deep(), NIL, pending_shmem_requests, registered_shmem_callbacks, SRS_DONE, and SRS_INITIALIZING.
Referenced by CreateSharedMemoryAndSemaphores().
Definition at line 1006 of file shmem.c.
References Assert, AttachShmemIndexEntry(), fb(), InitShmemIndexEntry(), IsUnderPostmaster, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), name, SHMEM_KIND_STRUCT, ShmemIndexLock, SRS_DONE, SRS_INITIALIZING, and SRS_REQUESTING.
Referenced by ShmemInitHash().
| void ShmemRequestInternal | ( | ShmemStructOpts * | options, |
| ShmemRequestKind | kind | ||
| ) |
Definition at line 336 of file shmem.c.
References elog, ereport, errmsg, ERROR, fb(), foreach_ptr, IsUnderPostmaster, lappend(), palloc(), pending_shmem_requests, pg_nextpower2_size_t, SHMEM_ATTACH_UNKNOWN_SIZE, and SRS_REQUESTING.
Referenced by ShmemRequestHashWithOpts(), ShmemRequestStructWithOpts(), and SimpleLruRequestWithOpts().
| void ShmemRequestStructWithOpts | ( | const ShmemStructOpts * | options | ) |
Definition at line 316 of file shmem.c.
References fb(), memcpy(), MemoryContextAlloc(), SHMEM_KIND_STRUCT, ShmemRequestInternal(), and TopMemoryContext.
Definition at line 275 of file shmem.c.
Referenced by pg_get_shmem_allocations_numa().
|
static |
Definition at line 170 of file shmem.c.
Referenced by CallShmemCallbacksAfterStartup(), InitShmemAllocator(), ResetShmemAllocator(), ShmemGetRequestedSize(), ShmemInitRequested(), and ShmemRequestInternal().
|
static |
Definition at line 158 of file shmem.c.
Referenced by RegisterShmemCallbacks(), ShmemCallRequestCallbacks(), and ShmemInitRequested().
|
static |
Definition at line 247 of file shmem.c.
Referenced by InitShmemAllocator(), pg_get_shmem_allocations(), and ShmemAllocRaw().
|
static |
Definition at line 244 of file shmem.c.
Referenced by InitShmemAllocator(), ShmemAddrIsValid(), and ShmemAllocRaw().
|
static |
Definition at line 245 of file shmem.c.
Referenced by InitShmemAllocator(), and ShmemAddrIsValid().
|
static |
Definition at line 253 of file shmem.c.
Referenced by AttachShmemIndexEntry(), CallShmemCallbacksAfterStartup(), InitShmemAllocator(), InitShmemIndexEntry(), pg_get_shmem_allocations(), and pg_get_shmem_allocations_numa().
|
static |
Definition at line 243 of file shmem.c.
Referenced by InitShmemAllocator(), pg_get_shmem_allocations(), pg_get_shmem_allocations_numa(), and ShmemAllocRaw().