237#define ShmemIndexLock (&ShmemAllocator->index_lock)
256#define SHMEM_INDEX_KEYSIZE (48)
263#define SHMEM_INDEX_ADDITIONAL_SIZE (128)
343 elog(
ERROR,
"shared memory request is missing 'name' option");
348 elog(
ERROR,
"invalid size %zd for shared memory request for \"%s\"",
354 elog(
ERROR,
"SHMEM_ATTACH_UNKNOWN_SIZE cannot be used during startup");
356 elog(
ERROR,
"invalid size %zd for shared memory request for \"%s\"",
361 elog(
ERROR,
"invalid alignment %zu for shared memory request for \"%s\"",
366 elog(
ERROR,
"ShmemRequestStruct can only be called from a shmem_request callback");
373 (
errmsg(
"shared memory struct \"%s\" is already registered",
404 size_t alignment =
request->options->alignment;
450 if (callbacks->init_fn)
451 callbacks->init_fn(callbacks->opaque_arg);
517 size_t allocated_size;
524 elog(
ERROR,
"shared memory struct \"%s\" is already initialized",
name);
530 errmsg(
"could not create ShmemIndex entry for data structure \"%s\"",
547 errmsg(
"not enough shared memory for data structure"
548 " \"%s\" (%zu bytes requested)",
593 (
errmsg(
"could not find ShmemIndex entry for data structure \"%s\"",
603 (
errmsg(
"shared memory struct \"%s\" was created with"
604 " different size: existing %zu, requested %zu",
673 if (offset >
seghdr->totalsize)
676 errmsg(
"out of shared memory (%zu bytes requested)",
773 errmsg(
"out of shared memory (%zu bytes requested)",
883 elog(
ERROR,
"cannot request shared memory at this time");
1055 errmsg(
"requested shared memory size overflows size_t")));
1070 errmsg(
"requested shared memory size overflows size_t")));
1078#define PG_GET_SHMEM_SIZES_COLS 4
1093 memset(nulls, 0,
sizeof(nulls));
1135#define PG_GET_SHMEM_NUMA_SIZES_COLS 3
1150 elog(
ERROR,
"libnuma initialization failed or NUMA is not supported on this platform");
1184 elog(
DEBUG1,
"NUMA: page-faulting shared memory segments for proper NUMA readouts");
1206 (
char *)
ent->location +
ent->allocated_size);
1207 total_len = (endptr - startptr);
1236 elog(
ERROR,
"failed NUMA pages inquiry status: %m");
1259 elog(
ERROR,
"invalid NUMA node id outside of allowed range "
1264 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)
static bool pg_mul_size_overflow(size_t a, size_t b, size_t *result)
static bool pg_add_size_overflow(size_t a, size_t b, size_t *result)
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)
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 add_size(Size s1, Size s2)
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)
Size mul_size(Size s1, Size s2)
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)