|
PostgreSQL Source Code git master
|
#include "postgres.h"#include <unistd.h>#include "access/slru.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 184 of file shmem.c.
|
static |
Definition at line 580 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 898 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, pfree(), 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 637 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 511 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().
| Datum pg_get_shmem_allocations | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1045 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 1102 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 1273 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 873 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 742 of file shmem.c.
References Assert, IsUnderPostmaster, NIL, pending_shmem_requests, and SRS_INITIAL.
Referenced by PostmasterStateMachine().
Definition at line 763 of file shmem.c.
References ereport, errcode(), errmsg, ERROR, fb(), and ShmemAllocRaw().
Referenced by InitShmemAllocator().
Definition at line 783 of file shmem.c.
References ShmemAllocRaw().
Definition at line 797 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 978 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, pfree(), registered_shmem_callbacks, SRS_DONE, and SRS_INITIALIZING.
Referenced by CreateSharedMemoryAndSemaphores().
Definition at line 1010 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 315 of file shmem.c.
References fb(), memcpy(), MemoryContextAlloc(), SHMEM_KIND_STRUCT, ShmemRequestInternal(), and TopMemoryContext.
Definition at line 274 of file shmem.c.
Referenced by pg_get_shmem_allocations_numa().
|
static |
Definition at line 169 of file shmem.c.
Referenced by CallShmemCallbacksAfterStartup(), InitShmemAllocator(), ResetShmemAllocator(), ShmemGetRequestedSize(), ShmemInitRequested(), and ShmemRequestInternal().
|
static |
Definition at line 157 of file shmem.c.
Referenced by RegisterShmemCallbacks(), ShmemCallRequestCallbacks(), and ShmemInitRequested().
|
static |
Definition at line 246 of file shmem.c.
Referenced by InitShmemAllocator(), pg_get_shmem_allocations(), and ShmemAllocRaw().
|
static |
Definition at line 243 of file shmem.c.
Referenced by InitShmemAllocator(), ShmemAddrIsValid(), and ShmemAllocRaw().
|
static |
Definition at line 244 of file shmem.c.
Referenced by InitShmemAllocator(), and ShmemAddrIsValid().
|
static |
Definition at line 252 of file shmem.c.
Referenced by AttachShmemIndexEntry(), CallShmemCallbacksAfterStartup(), InitShmemAllocator(), InitShmemIndexEntry(), pg_get_shmem_allocations(), and pg_get_shmem_allocations_numa().
|
static |
Definition at line 242 of file shmem.c.
Referenced by InitShmemAllocator(), pg_get_shmem_allocations(), pg_get_shmem_allocations_numa(), and ShmemAllocRaw().