PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "lib/ilist.h"
#include "utils/memdebug.h"
#include "utils/memutils.h"
#include "utils/memutils_internal.h"
#include "utils/memutils_memorychunk.h"
Go to the source code of this file.
Data Structures | |
struct | SlabContext |
struct | SlabBlock |
Macros | |
#define | Slab_BLOCKHDRSZ MAXALIGN(sizeof(SlabBlock)) |
#define | Slab_CONTEXT_HDRSZ(chunksPerBlock) sizeof(SlabContext) |
#define | SLAB_BLOCKLIST_COUNT 3 |
#define | SLAB_MAXIMUM_EMPTY_BLOCKS 10 |
#define | Slab_CHUNKHDRSZ sizeof(MemoryChunk) |
#define | SlabChunkGetPointer(chk) ((void *) (((char *) (chk)) + sizeof(MemoryChunk))) |
#define | SlabBlockGetChunk(slab, block, n) |
#define | SlabIsValid(set) (PointerIsValid(set) && IsA(set, SlabContext)) |
#define | SlabBlockIsValid(block) (PointerIsValid(block) && SlabIsValid((block)->slab)) |
Typedefs | |
typedef struct SlabContext | SlabContext |
typedef struct SlabBlock | SlabBlock |
Variables | |
static pg_noinline void Size | size |
#define Slab_CHUNKHDRSZ sizeof(MemoryChunk) |
#define Slab_CONTEXT_HDRSZ | ( | chunksPerBlock | ) | sizeof(SlabContext) |
#define SlabBlockGetChunk | ( | slab, | |
block, | |||
n | |||
) |
#define SlabBlockIsValid | ( | block | ) | (PointerIsValid(block) && SlabIsValid((block)->slab)) |
#define SlabChunkGetPointer | ( | chk | ) | ((void *) (((char *) (chk)) + sizeof(MemoryChunk))) |
#define SlabIsValid | ( | set | ) | (PointerIsValid(set) && IsA(set, SlabContext)) |
typedef struct SlabContext SlabContext |
Referenced by SlabContextCreate(), SlabFree(), and SlabRealloc().
|
static |
void* SlabAlloc | ( | MemoryContext | context, |
Size | size, | ||
int | flags | ||
) |
Definition at line 630 of file slab.c.
References Assert, SlabContext::blocklist, chunk, SlabContext::chunkSize, SlabContext::chunksPerBlock, context, SlabContext::curBlocklistIndex, dlist_delete_from(), dlist_head_element, dlist_is_empty(), dlist_push_head(), SlabBlock::nfree, SlabBlock::node, size, SlabAllocFromNewBlock(), SlabAllocSetupNewChunk(), SlabBlocklistIndex(), SlabFindNextBlockListIndex(), SlabGetNextFreeChunk(), SlabIsValid, and unlikely.
|
static |
Definition at line 539 of file slab.c.
References Assert, SlabContext::blocklist, SlabContext::blockSize, chunk, SlabContext::chunksPerBlock, context, SlabContext::curBlocklistIndex, dclist_count(), dclist_pop_head_node(), dlist_container, dlist_is_empty(), dlist_push_head(), SlabContext::emptyblocks, SlabBlock::freehead, malloc, MemoryContextAllocationFailure(), SlabBlock::nfree, SlabBlock::node, SlabBlock::nunused, size, SlabBlock::slab, SlabAllocSetupNewChunk(), SlabBlockGetChunk, SlabBlocklistIndex(), SlabGetNextFreeChunk(), unlikely, and SlabBlock::unused.
Referenced by SlabAlloc().
|
inlinestatic |
Definition at line 498 of file slab.c.
References Assert, chunk, SlabContext::chunkSize, SlabContext::chunksPerBlock, context, SlabContext::fullChunkSize, MAXALIGN, MCTX_SLAB_ID, MemoryChunkGetPointer, MemoryChunkSetHdrMask(), size, Slab_CHUNKHDRSZ, SlabBlockGetChunk, VALGRIND_MAKE_MEM_NOACCESS, and VALGRIND_MAKE_MEM_UNDEFINED.
Referenced by SlabAlloc(), and SlabAllocFromNewBlock().
|
inlinestatic |
Definition at line 211 of file slab.c.
References Assert, SlabContext::blocklist_shift, and SLAB_BLOCKLIST_COUNT.
Referenced by SlabAlloc(), SlabAllocFromNewBlock(), and SlabFree().
MemoryContext SlabContextCreate | ( | MemoryContext | parent, |
const char * | name, | ||
Size | blockSize, | ||
Size | chunkSize | ||
) |
Definition at line 322 of file slab.c.
References Assert, SlabContext::blocklist, SlabContext::blocklist_shift, SlabContext::blockSize, SlabContext::chunkSize, SlabContext::chunksPerBlock, SlabContext::curBlocklistIndex, dclist_init(), dlist_init(), elog(), SlabContext::emptyblocks, ereport, errcode(), errdetail(), errmsg(), ERROR, SlabContext::fullChunkSize, i, malloc, MAXALIGN, MCTX_SLAB_ID, MEMORYCHUNK_MAX_BLOCKOFFSET, MEMORYCHUNK_MAX_VALUE, MemoryContextCreate(), MemoryContextStats(), name, Slab_BLOCKHDRSZ, SLAB_BLOCKLIST_COUNT, Slab_CHUNKHDRSZ, Slab_CONTEXT_HDRSZ, StaticAssertDecl, and TopMemoryContext.
Referenced by for(), and ReorderBufferAllocate().
void SlabDelete | ( | MemoryContext | context | ) |
|
static |
Definition at line 251 of file slab.c.
References SlabContext::blocklist, dlist_is_empty(), i, and SLAB_BLOCKLIST_COUNT.
Referenced by SlabAlloc(), and SlabFree().
void SlabFree | ( | void * | pointer | ) |
Definition at line 701 of file slab.c.
References Assert, SlabContext::blocklist, SlabContext::blockSize, chunk, SlabContext::chunkSize, SlabContext::chunksPerBlock, SlabContext::curBlocklistIndex, dclist_count(), dclist_push_head(), dlist_delete_from(), dlist_is_empty(), dlist_push_head(), elog(), SlabContext::emptyblocks, free, SlabBlock::freehead, SlabContext::fullChunkSize, SlabContext::header, MemoryContextData::mem_allocated, MemoryChunkGetBlock(), MemoryContextData::name, SlabBlock::nfree, SlabBlock::node, PointerGetMemoryChunk, SlabBlock::slab, Slab_CHUNKHDRSZ, SLAB_MAXIMUM_EMPTY_BLOCKS, SlabBlockIsValid, SlabBlocklistIndex(), SlabFindNextBlockListIndex(), unlikely, VALGRIND_MAKE_MEM_DEFINED, and WARNING.
MemoryContext SlabGetChunkContext | ( | void * | pointer | ) |
Definition at line 863 of file slab.c.
References Assert, chunk, SlabContext::header, MemoryChunkGetBlock(), PointerGetMemoryChunk, SlabBlock::slab, Slab_CHUNKHDRSZ, SlabBlockIsValid, VALGRIND_MAKE_MEM_DEFINED, and VALGRIND_MAKE_MEM_NOACCESS.
Size SlabGetChunkSpace | ( | void * | pointer | ) |
Definition at line 887 of file slab.c.
References Assert, chunk, SlabContext::fullChunkSize, MemoryChunkGetBlock(), PointerGetMemoryChunk, SlabBlock::slab, Slab_CHUNKHDRSZ, SlabBlockIsValid, VALGRIND_MAKE_MEM_DEFINED, and VALGRIND_MAKE_MEM_NOACCESS.
|
inlinestatic |
Definition at line 271 of file slab.c.
References Assert, chunk, SlabContext::chunksPerBlock, SlabBlock::freehead, SlabContext::fullChunkSize, SlabBlock::nfree, SlabBlock::nunused, SlabBlockGetChunk, SlabChunkGetPointer, SlabBlock::unused, and VALGRIND_MAKE_MEM_DEFINED.
Referenced by SlabAlloc(), and SlabAllocFromNewBlock().
bool SlabIsEmpty | ( | MemoryContext | context | ) |
void* SlabRealloc | ( | void * | pointer, |
Size | size, | ||
int | flags | ||
) |
Definition at line 826 of file slab.c.
References chunk, SlabContext::chunkSize, elog(), ERROR, MemoryChunkGetBlock(), PointerGetMemoryChunk, size, SlabBlock::slab, Slab_CHUNKHDRSZ, SlabBlockIsValid, VALGRIND_MAKE_MEM_DEFINED, and VALGRIND_MAKE_MEM_NOACCESS.
void SlabReset | ( | MemoryContext | context | ) |
Definition at line 431 of file slab.c.
References Assert, SlabContext::blocklist, SlabContext::blockSize, context, dlist_mutable_iter::cur, SlabContext::curBlocklistIndex, dclist_delete_from(), dclist_foreach_modify, dlist_container, dlist_delete(), dlist_foreach_modify, SlabContext::emptyblocks, free, i, SLAB_BLOCKLIST_COUNT, and SlabIsValid.
Referenced by SlabDelete().
void SlabStats | ( | MemoryContext | context, |
MemoryStatsPrintFunc | printfunc, | ||
void * | passthru, | ||
MemoryContextCounters * | totals, | ||
bool | print_to_stderr | ||
) |
Definition at line 929 of file slab.c.
References Assert, SlabContext::blocklist, SlabContext::blockSize, SlabContext::chunksPerBlock, context, dlist_iter::cur, dclist_count(), dlist_container, dlist_foreach, SlabContext::emptyblocks, MemoryContextCounters::freechunks, MemoryContextCounters::freespace, SlabContext::fullChunkSize, i, MemoryContextCounters::nblocks, SlabBlock::nfree, SLAB_BLOCKLIST_COUNT, Slab_CONTEXT_HDRSZ, SlabIsValid, snprintf, and MemoryContextCounters::totalspace.
pg_noinline void Size size |
Definition at line 606 of file slab.c.
Referenced by _bt_pageinit(), _crypt_blowfish_rn(), _crypt_gensalt_blowfish_rn(), _crypt_gensalt_extended_rn(), _crypt_gensalt_md5_rn(), _crypt_gensalt_traditional_rn(), _hash_pageinit(), _intbig_alloc(), _ltree_union(), _pglstat64(), _pgstat64(), add_file_to_manifest(), AddFileToBackupManifest(), addOrReplaceTuple(), ahwrite(), AlignedAllocRealloc(), alloc_object(), allocacl(), allocate_reloption(), allocateReloptStruct(), AllocSetAlloc(), AllocSetAllocChunkFromBlock(), AllocSetAllocFromNewBlock(), AllocSetAllocLarge(), AllocSetFreeIndex(), AllocSetRealloc(), AppendJumble(), ApplyLauncherShmemSize(), array_agg_array_combine(), array_agg_array_deserialize(), ASN1_STRING_to_text(), AsyncShmemInit(), AsyncShmemSize(), AutoVacuumShmemSize(), BackendStatusShmemInit(), BackendStatusShmemSize(), BackgroundWorkerShmemSize(), BF_decode(), BF_encode(), bms_copy(), box_poly(), brin_form_placeholder_tuple(), brin_form_tuple(), bringetbitmap(), brinGetTupleForHeapBlock(), bsearch_arg(), BTreeShmemSize(), BufferManagerShmemSize(), BufFileRead(), BufFileReadCommon(), BufFileReadExact(), BufFileReadMaybeEOF(), BufFileWrite(), BufTableShmemSize(), build_hash_table(), BumpAlloc(), BumpAllocChunkFromBlock(), BumpAllocFromNewBlock(), BumpAllocLarge(), calc_rank_and(), calc_rank_or(), calcstrlen(), calculate_indexes_size(), calculate_table_size(), calculate_toast_table_size(), calculate_total_relation_size(), CalculateShmemSize(), check_synchronized_standby_slots(), checkdig(), CheckpointerShmemInit(), CheckpointerShmemSize(), chooseNextStatEntry(), circle_poly(), combinebackup_per_file_cb(), compact_palloc0(), CopyIndexTuple(), CopyMultiInsertBufferFlush(), CopySnapshot(), count_usable_fds(), crc32_sz(), create_internal(), CreateAnonymousSegment(), CreateSharedMemoryAndSemaphores(), cube_a_f8(), cube_a_f8_f8(), cube_c_f8(), cube_c_f8_f8(), cube_enlarge(), cube_f8(), cube_f8_f8(), cube_inter(), cube_subset(), cube_union_v0(), datumGetSize(), decoct(), DecodeXLogRecordRequiredSpace(), dense_alloc(), digestControlFile(), doPickSplit(), dsa_allocate_extended(), dsa_create_in_place_ext(), dsa_free(), dsa_get_total_size(), dsa_minimum_size(), dshash_destroy(), dshash_memcmp(), dshash_memcpy(), dshash_memhash(), dshash_strcmp(), dshash_strcpy(), dshash_strhash(), dsm_create(), dsm_impl_posix_resize(), dsm_shmem_init(), dummy_ssl_passwd_cb(), DynaHashAlloc(), ecpg_alloc(), ecpg_auto_alloc(), ecpg_build_compat_sqlda(), ecpg_build_native_sqlda(), ecpg_get_data(), ecpg_realloc(), ecpg_sqlda_align_add_size(), ECPGdump_a_simple(), ECPGmake_array_type(), ECPGmake_simple_type(), emalloc(), entrySplitPage(), erealloc(), estimate_variable_size(), EstimateClientConnectionInfoSpace(), EstimateComboCIDStateSpace(), EstimateGUCStateSpace(), EstimateLibraryStateSpace(), EstimateSnapshotSpace(), EstimateTransactionStateSpace(), evalStandardFunc(), ExecAggEstimate(), ExecAggInitializeDSM(), ExecAggRetrieveInstrumentation(), ExecBitmapHeapEstimate(), ExecBitmapHeapInitializeDSM(), ExecBitmapHeapRetrieveInstrumentation(), ExecHashEstimate(), ExecHashInitializeDSM(), ExecHashRetrieveInstrumentation(), ExecIncrementalSortEstimate(), ExecIncrementalSortInitializeDSM(), ExecIncrementalSortRetrieveInstrumentation(), ExecMemoizeEstimate(), ExecMemoizeInitializeDSM(), ExecMemoizeRetrieveInstrumentation(), ExecParallelHashIncreaseNumBuckets(), ExecParallelHashTupleAlloc(), ExecParallelHashTuplePrealloc(), ExecSortEstimate(), ExecSortInitializeDSM(), ExecSortRetrieveInstrumentation(), executeItemOptUnwrapTarget(), fill_buffer(), fillRelOptions(), filter_get_keyword(), filter_read_item(), findoprnd(), form_and_insert_tuple(), form_and_spill_tuple(), g_int_union(), g_intbig_union(), gbt_bit_union(), gbt_bytea_union(), gbt_numeric_union(), gbt_text_union(), gbt_var_union(), GenerationAlloc(), GenerationAllocChunkFromBlock(), GenerationAllocFromNewBlock(), GenerationAllocLarge(), GenerationRealloc(), get_decomposed_size(), get_object_type(), GetFileBackupMethod(), GetNamedDSMSegment(), GetPermutation(), gets_none(), GetSessionDsmHandle(), ghstore_alloc(), ghstore_union(), gimme_pool_size(), gistfitpage(), gistnospace(), gtrgm_alloc(), gtrgm_union(), gtsquery_union(), gtsvector_alloc(), gtsvector_union(), guc_malloc(), guc_realloc(), hash_estimate_size(), index_form_tuple_context(), inet_cidr_ntop_ipv4(), inet_cidr_ntop_ipv6(), inet_cidr_pton_ipv4(), inet_cidr_pton_ipv6(), inet_net_ntop_ipv4(), inet_net_ntop_ipv6(), inet_net_pton_ipv4(), InitBufTable(), initStringInfo(), injection_shmem_request(), internal_size(), InternalIpcMemoryCreate(), json_manifest_finalize_file(), json_parse_manifest(), json_parse_manifest_incremental_chunk(), len_utf8(), LockManagerShmemSize(), LogicalTapeBackspace(), LogicalTapeRead(), LogicalTapeWrite(), LogLogicalMessage(), lrq_alloc(), ltree_crc32_sz(), ltree_gist_alloc(), ltree_union(), LWLockShmemSize(), main(), make_multirange(), makeParamList(), makeSublist(), manifest_process_file(), memcpyInnerDatum(), MemoryContextAlloc(), MemoryContextAllocAligned(), MemoryContextAllocationFailure(), MemoryContextAllocExtended(), MemoryContextAllocHuge(), MemoryContextAllocZero(), MemoryContextCheckSize(), MemoryContextSizeFailure(), mm_alloc(), moveLeafs(), multirange_size_estimate(), MultiXactShmemSize(), mXactCacheGetById(), my_sock_read(), my_sock_write(), newNode(), open_walfile(), PageAddItemExtended(), PageIndexMultiDelete(), PageIndexTupleDelete(), PageIndexTupleDeleteNoCompact(), PageSetPageSizeAndVersion(), pagetable_allocate(), palloc(), palloc0(), palloc_aligned(), palloc_extended(), path_add(), path_in(), path_poly(), path_recv(), perform_rewind(), permute(), pg_database_size_name(), pg_database_size_oid(), pg_indexes_size(), pg_inet_cidr_ntop(), pg_inet_net_ntop(), pg_inet_net_pton(), pg_malloc(), pg_malloc0(), pg_malloc_extended(), pg_malloc_internal(), pg_pread(), pg_pwrite(), pg_pwrite_zeros(), pg_realloc(), pg_relation_size(), pg_size_pretty(), pg_size_pretty_numeric(), pg_table_size(), pg_tablespace_size_name(), pg_tablespace_size_oid(), pg_total_relation_size(), PgArchShmemSize(), PGSharedMemoryCreate(), pgss_memsize(), pgstat_cmp_hash_key(), pgstat_hash_hash_key(), pgtypes_alloc(), PGTYPESnumeric_from_long(), PLyBytes_FromBytea(), PLyObject_ToBytea(), PLyUnicode_FromStringAndSize(), PMSignalShmemSize(), pnstrdup(), poly_in(), poly_path(), poly_recv(), pq_getkeepalivescount(), pq_getkeepalivesidle(), pq_getkeepalivesinterval(), pq_gettcpusertimeout(), PQdefaultSSLKeyPassHook_OpenSSL(), PQssl_passwd_cb(), PredicateLockShmemSize(), ProcArrayShmemSize(), process_source_file(), process_target_file(), ProcGlobalShmemSize(), ProcSignalShmemInit(), ProcSignalShmemSize(), random_init_pool(), range_search(), rbt_populate(), read_gucstate_binary(), read_none(), read_stream_begin_impl(), ReorderBufferCopySnap(), ReorderBufferRestoreChange(), ReorderBufferSerializeChange(), ReorderBufferSerializeTXN(), repalloc(), repalloc0(), repalloc_extended(), repalloc_huge(), ReplicationOriginShmemSize(), ReplicationSlotsShmemSize(), ReportTemporaryFileUsage(), RequestAddinShmemSpace(), ReserveXLogInsertLocation(), ReserveXLogSwitch(), resize(), RestoreSnapshot(), rot13_passphrase(), rt__int_size(), rt_cube_size(), rt_seg_size(), run_ssl_passphrase_command(), sendDir(), sendTablespace(), SerializeParamExecParams(), SerializeUncommittedEnums(), setup_simple_rel_arrays(), SharedInvalShmemSize(), shm_mq_create(), ShmemAlloc(), ShmemAllocNoError(), ShmemAllocRaw(), ShmemAllocUnlocked(), ShmemInitStruct(), sizebitvec(), SlabAlloc(), SlabAllocFromNewBlock(), SlabAllocSetupNewChunk(), SlabRealloc(), SlotSyncShmemInit(), SN_set_current(), SnapBuildRestoreContents(), SortAndUniqItems(), spgFormInnerTuple(), spgFormLeafTuple(), spgFormNodeTuple(), SpGistGetInnerTypeSize(), SpGistGetLeafTupleSize(), SpGistPageAddNewItem(), SPI_palloc(), SPI_repalloc(), ssl_external_passwd_cb(), StrategyShmemSize(), sts_flush_chunk(), sts_puttuple(), sts_read_tuple(), test_rb_tree(), testdelete(), testfind(), testfindltgt(), testleftmost(), testleftright(), testrightleft(), transfer_single_new_db(), tsqueryrecv(), tsvector_concat(), tuplesort_putbrintuple(), TwoPhaseShmemSize(), unicode_assigned(), unicode_is_normalized(), unicode_normalize_func(), verify_manifest_checksum(), verifybackup_per_file_cb(), WaitLSNShmemSize(), WalRcvShmemSize(), WalSndShmemSize(), weight_checkdig(), write_none(), write_target_range(), writeListPage(), writeTimeLineHistoryFile(), X509_NAME_to_cstring(), XLogReaderSetDecodeBuffer(), XLogRecoveryShmemSize(), and XLOGShmemSize().