236#define ShmemIndexLock (&ShmemAllocator->index_lock)
255#define SHMEM_INDEX_KEYSIZE (48)
262#define SHMEM_INDEX_ADDITIONAL_SIZE (128)
342 elog(
ERROR,
"shared memory request is missing 'name' option");
347 elog(
ERROR,
"invalid size %zd for shared memory request for \"%s\"",
353 elog(
ERROR,
"SHMEM_ATTACH_UNKNOWN_SIZE cannot be used during startup");
355 elog(
ERROR,
"invalid size %zd for shared memory request for \"%s\"",
360 elog(
ERROR,
"invalid alignment %zu for shared memory request for \"%s\"",
365 elog(
ERROR,
"ShmemRequestStruct can only be called from a shmem_request callback");
372 (
errmsg(
"shared memory struct \"%s\" is already registered",
403 size_t alignment =
request->options->alignment;
449 if (callbacks->init_fn)
450 callbacks->init_fn(callbacks->opaque_arg);
516 size_t allocated_size;
523 elog(
ERROR,
"shared memory struct \"%s\" is already initialized",
name);
529 errmsg(
"could not create ShmemIndex entry for data structure \"%s\"",
546 errmsg(
"not enough shared memory for data structure"
547 " \"%s\" (%zd bytes requested)",
592 (
errmsg(
"could not find ShmemIndex entry for data structure \"%s\"",
602 (
errmsg(
"shared memory struct \"%s\" was created with"
603 " different size: existing %zu, requested %zd",
672 if (offset >
seghdr->totalsize)
675 errmsg(
"out of shared memory (%zu bytes requested)",
772 errmsg(
"out of shared memory (%zu bytes requested)",
882 elog(
ERROR,
"cannot request shared memory at this time");
1047#define PG_GET_SHMEM_SIZES_COLS 4
1062 memset(nulls, 0,
sizeof(nulls));
1104#define PG_GET_SHMEM_NUMA_SIZES_COLS 3
1119 elog(
ERROR,
"libnuma initialization failed or NUMA is not supported on this platform");
1153 elog(
DEBUG1,
"NUMA: page-faulting shared memory segments for proper NUMA readouts");
1175 (
char *)
ent->location +
ent->allocated_size);
1176 total_len = (endptr - startptr);
1205 elog(
ERROR,
"failed NUMA pages inquiry status: %m");
1228 elog(
ERROR,
"invalid NUMA node id outside of allowed range "
1233 memset(nulls, 0,
sizeof(nulls));
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define CACHELINEALIGN(LEN)
#define TYPEALIGN(ALIGNVAL, LEN)
#define Assert(condition)
#define TYPEALIGN_DOWN(ALIGNVAL, LEN)
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
Size hash_estimate_size(int64 num_entries, Size entrysize)
void * hash_seq_search(HASH_SEQ_STATUS *status)
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
int errcode(int sqlerrcode)
#define ereport(elevel,...)
#define palloc_array(type, count)
#define palloc0_array(type, count)
#define PG_RETURN_BOOL(x)
void InitMaterializedSRF(FunctionCallInfo fcinfo, uint32 flags)
List * lappend(List *list, void *datum)
void list_free_deep(List *list)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
void LWLockInitialize(LWLock *lock, int tranche_id)
void * MemoryContextAlloc(MemoryContext context, Size size)
Size add_size(Size s1, Size s2)
void pfree(void *pointer)
MemoryContext TopMemoryContext
#define CHECK_FOR_INTERRUPTS()
#define pg_nextpower2_size_t
#define PG_CACHE_LINE_SIZE
static int list_length(const List *l)
#define foreach_ptr(type, var, lst)
PGDLLIMPORT int pg_numa_get_max_node(void)
#define pg_numa_touch_mem_if_required(ptr)
PGDLLIMPORT int pg_numa_query_pages(int pid, unsigned long count, void **pages, int *status)
PGDLLIMPORT int pg_numa_init(void)
static Datum Int64GetDatum(int64 X)
static Datum Int32GetDatum(int32 X)
bool ShmemAddrIsValid(const void *addr)
Datum pg_get_shmem_allocations_numa(PG_FUNCTION_ARGS)
Datum pg_numa_available(PG_FUNCTION_ARGS)
void InitShmemAllocator(PGShmemHeader *seghdr)
void ShmemRequestStructWithOpts(const ShmemStructOpts *options)
Datum pg_get_shmem_allocations(PG_FUNCTION_ARGS)
Size pg_get_shmem_pagesize(void)
void RegisterShmemCallbacks(const ShmemCallbacks *callbacks)
static List * registered_shmem_callbacks
#define PG_GET_SHMEM_NUMA_SIZES_COLS
void * ShmemAllocNoError(Size size)
void * ShmemAlloc(Size size)
#define PG_GET_SHMEM_SIZES_COLS
void ShmemCallRequestCallbacks(void)
static void * ShmemAllocRaw(Size size, Size alignment, Size *allocated_size)
static void InitShmemIndexEntry(ShmemRequest *request)
static void CallShmemCallbacksAfterStartup(const ShmemCallbacks *callbacks)
void ShmemInitRequested(void)
static PGShmemHeader * ShmemSegHdr
void ShmemRequestInternal(ShmemStructOpts *options, ShmemRequestKind kind)
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
@ SRS_AFTER_STARTUP_ATTACH_OR_INIT
static List * pending_shmem_requests
#define SHMEM_INDEX_ADDITIONAL_SIZE
static ShmemAllocatorData * ShmemAllocator
static bool AttachShmemIndexEntry(ShmemRequest *request, bool missing_ok)
size_t ShmemGetRequestedSize(void)
static bool firstNumaTouch
void ResetShmemAllocator(void)
#define SHMEM_INDEX_KEYSIZE
#define SHMEM_ATTACH_UNKNOWN_SIZE
#define SHMEM_CALLBACKS_ALLOW_AFTER_STARTUP
HTAB * shmem_hash_create(void *location, size_t size, bool found, const char *name, int64 nelems, HASHCTL *infoP, int hash_flags)
void shmem_hash_attach(void *location, ShmemStructOpts *base_options)
void shmem_hash_init(void *location, ShmemStructOpts *base_options)
void shmem_slru_init(void *location, ShmemStructOpts *base_options)
void shmem_slru_attach(void *location, ShmemStructOpts *base_options)
static void SpinLockRelease(volatile slock_t *lock)
static void SpinLockAcquire(volatile slock_t *lock)
static void SpinLockInit(volatile slock_t *lock)
ShmemRequestCallback request_fn
ShmemInitCallback init_fn
ShmemAttachCallback attach_fn
ShmemStructOpts * options
void GetHugePageSize(Size *hugepagesize, int *mmap_flags)
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, const Datum *values, const bool *isnull)