PostgreSQL Source Code git master
|
#include "postgres.h"
#include "lib/ilist.h"
#include "port/pg_bitutils.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 | GenerationContext |
struct | GenerationBlock |
Macros | |
#define | Generation_BLOCKHDRSZ MAXALIGN(sizeof(GenerationBlock)) |
#define | Generation_CHUNKHDRSZ sizeof(MemoryChunk) |
#define | FIRST_BLOCKHDRSZ |
#define | Generation_CHUNK_FRACTION 8 |
#define | GenerationIsValid(set) ((set) && IsA(set, GenerationContext)) |
#define | GenerationBlockIsValid(block) ((block) && GenerationIsValid((block)->context)) |
#define | GenerationBlockIsEmpty(b) ((b)->nchunks == 0) |
#define | ExternalChunkGetBlock(chunk) (GenerationBlock *) ((char *) chunk - Generation_BLOCKHDRSZ) |
#define | KeeperBlock(set) |
#define | IsKeeperBlock(set, block) ((block) == (KeeperBlock(set))) |
Typedefs | |
typedef struct GenerationBlock | GenerationBlock |
typedef void * | GenerationPointer |
typedef struct GenerationContext | GenerationContext |
#define ExternalChunkGetBlock | ( | chunk | ) | (GenerationBlock *) ((char *) chunk - Generation_BLOCKHDRSZ) |
Definition at line 125 of file generation.c.
#define FIRST_BLOCKHDRSZ |
Definition at line 48 of file generation.c.
#define Generation_BLOCKHDRSZ MAXALIGN(sizeof(GenerationBlock)) |
Definition at line 46 of file generation.c.
#define Generation_CHUNK_FRACTION 8 |
Definition at line 51 of file generation.c.
#define Generation_CHUNKHDRSZ sizeof(MemoryChunk) |
Definition at line 47 of file generation.c.
Definition at line 118 of file generation.c.
#define GenerationBlockIsValid | ( | block | ) | ((block) && GenerationIsValid((block)->context)) |
Definition at line 111 of file generation.c.
#define GenerationIsValid | ( | set | ) | ((set) && IsA(set, GenerationContext)) |
Definition at line 104 of file generation.c.
#define IsKeeperBlock | ( | set, | |
block | |||
) | ((block) == (KeeperBlock(set))) |
Definition at line 134 of file generation.c.
#define KeeperBlock | ( | set | ) |
Definition at line 129 of file generation.c.
typedef struct GenerationBlock GenerationBlock |
Definition at line 53 of file generation.c.
typedef struct GenerationContext GenerationContext |
typedef void* GenerationPointer |
Definition at line 55 of file generation.c.
void * GenerationAlloc | ( | MemoryContext | context, |
Size | size, | ||
int | flags | ||
) |
Definition at line 553 of file generation.c.
References GenerationContext::allocChunkLimit, Assert(), GenerationContext::block, GenerationContext::freeblock, Generation_CHUNKHDRSZ, GenerationAllocChunkFromBlock(), GenerationAllocFromNewBlock(), GenerationAllocLarge(), GenerationBlockFreeBytes(), GenerationBlockIsEmpty, GenerationIsValid, MAXALIGN, and unlikely.
Referenced by GenerationRealloc().
|
inlinestatic |
Definition at line 436 of file generation.c.
References Assert(), GenerationBlock::endptr, GenerationBlock::freeptr, Generation_CHUNKHDRSZ, MCTX_GENERATION_ID, MemoryChunkGetPointer, MemoryChunkSetHdrMask(), GenerationBlock::nchunks, VALGRIND_MAKE_MEM_NOACCESS, and VALGRIND_MAKE_MEM_UNDEFINED.
Referenced by GenerationAlloc(), and GenerationAllocFromNewBlock().
|
static |
Definition at line 484 of file generation.c.
References GenerationContext::block, GenerationContext::blocks, dlist_push_head(), Generation_BLOCKHDRSZ, Generation_CHUNKHDRSZ, GenerationAllocChunkFromBlock(), GenerationBlockInit(), malloc, GenerationContext::maxBlockSize, MemoryContextData::mem_allocated, MemoryContextAllocationFailure(), GenerationContext::nextBlockSize, GenerationBlock::node, pg_nextpower2_size_t, and VALGRIND_MEMPOOL_ALLOC.
Referenced by GenerationAlloc().
|
static |
Definition at line 363 of file generation.c.
References Assert(), GenerationBlock::blksize, GenerationContext::blocks, GenerationBlock::context, dlist_push_head(), GenerationBlock::endptr, GenerationBlock::freeptr, Generation_BLOCKHDRSZ, Generation_CHUNKHDRSZ, malloc, MAXALIGN, MCTX_GENERATION_ID, MemoryContextData::mem_allocated, MemoryChunkGetPointer, MemoryChunkSetHdrMaskExternal(), MemoryContextAllocationFailure(), MemoryContextCheckSize(), GenerationBlock::nchunks, GenerationBlock::nfree, GenerationBlock::node, VALGRIND_MAKE_MEM_NOACCESS, and VALGRIND_MEMPOOL_ALLOC.
Referenced by GenerationAlloc().
|
inlinestatic |
Definition at line 690 of file generation.c.
References Assert(), GenerationBlock::blksize, dlist_delete(), free, GenerationContext::freeblock, IsKeeperBlock, GenerationBlock::node, and VALGRIND_MEMPOOL_FREE.
Referenced by GenerationFree(), and GenerationReset().
|
inlinestatic |
Definition at line 680 of file generation.c.
References GenerationBlock::endptr, and GenerationBlock::freeptr.
Referenced by GenerationAlloc().
|
inlinestatic |
Definition at line 635 of file generation.c.
References GenerationBlock::blksize, GenerationBlock::context, GenerationBlock::endptr, GenerationBlock::freeptr, Generation_BLOCKHDRSZ, GenerationBlock::nchunks, GenerationBlock::nfree, and VALGRIND_MAKE_MEM_NOACCESS.
Referenced by GenerationAllocFromNewBlock(), and GenerationContextCreate().
|
inlinestatic |
Definition at line 656 of file generation.c.
References GenerationBlock::freeptr, Generation_BLOCKHDRSZ, GenerationBlock::nchunks, GenerationBlock::nfree, and VALGRIND_MAKE_MEM_NOACCESS.
Referenced by GenerationFree(), and GenerationReset().
MemoryContext GenerationContextCreate | ( | MemoryContext | parent, |
const char * | name, | ||
Size | minContextSize, | ||
Size | initBlockSize, | ||
Size | maxBlockSize | ||
) |
Definition at line 162 of file generation.c.
References GenerationContext::allocChunkLimit, AllocHugeSizeIsValid, Assert(), GenerationContext::block, GenerationContext::blocks, dlist_init(), dlist_push_head(), ereport, errcode(), errdetail(), errmsg(), ERROR, FIRST_BLOCKHDRSZ, GenerationContext::freeblock, Generation_BLOCKHDRSZ, Generation_CHUNK_FRACTION, Generation_CHUNKHDRSZ, GenerationBlockInit(), GenerationContext::initBlockSize, KeeperBlock, malloc, Max, MAXALIGN, GenerationContext::maxBlockSize, MCTX_GENERATION_ID, MEMORYCHUNK_MAX_BLOCKOFFSET, MEMORYCHUNK_MAX_VALUE, MemoryContextCreate(), MemoryContextStats(), Min, name, GenerationContext::nextBlockSize, GenerationBlock::node, StaticAssertDecl, TopMemoryContext, VALGRIND_CREATE_MEMPOOL, and VALGRIND_MEMPOOL_ALLOC.
Referenced by gistvacuumscan(), ReorderBufferAllocate(), and tuplestore_begin_common().
void GenerationDelete | ( | MemoryContext | context | ) |
Definition at line 344 of file generation.c.
References free, GenerationReset(), and VALGRIND_DESTROY_MEMPOOL.
void GenerationFree | ( | void * | pointer | ) |
Definition at line 718 of file generation.c.
References Assert(), GenerationContext::block, GenerationBlock::context, elog, GenerationBlock::endptr, ERROR, ExternalChunkGetBlock, GenerationContext::freeblock, Generation_CHUNKHDRSZ, GenerationBlockFree(), GenerationBlockIsValid, GenerationBlockMarkEmpty(), InvalidAllocSize, IsKeeperBlock, likely, MemoryChunkGetBlock(), MemoryChunkGetValue(), MemoryChunkIsExternal(), GenerationBlock::nchunks, GenerationBlock::nfree, PointerGetMemoryChunk, VALGRIND_MAKE_MEM_DEFINED, and WARNING.
Referenced by GenerationRealloc().
MemoryContext GenerationGetChunkContext | ( | void * | pointer | ) |
Definition at line 976 of file generation.c.
References Assert(), GenerationBlock::context, ExternalChunkGetBlock, Generation_CHUNKHDRSZ, GenerationBlockIsValid, GenerationContext::header, MemoryChunkGetBlock(), MemoryChunkIsExternal(), PointerGetMemoryChunk, VALGRIND_MAKE_MEM_DEFINED, and VALGRIND_MAKE_MEM_NOACCESS.
Size GenerationGetChunkSpace | ( | void * | pointer | ) |
Definition at line 1002 of file generation.c.
References Assert(), GenerationBlock::endptr, ExternalChunkGetBlock, Generation_CHUNKHDRSZ, GenerationBlockIsValid, MemoryChunkGetValue(), MemoryChunkIsExternal(), PointerGetMemoryChunk, VALGRIND_MAKE_MEM_DEFINED, and VALGRIND_MAKE_MEM_NOACCESS.
bool GenerationIsEmpty | ( | MemoryContext | context | ) |
Definition at line 1031 of file generation.c.
References Assert(), GenerationContext::blocks, dlist_iter::cur, dlist_container, dlist_foreach, GenerationIsValid, and GenerationBlock::nchunks.
void * GenerationRealloc | ( | void * | pointer, |
Size | size, | ||
int | flags | ||
) |
Definition at line 829 of file generation.c.
References Assert(), GenerationBlock::context, elog, GenerationBlock::endptr, ERROR, ExternalChunkGetBlock, Generation_CHUNKHDRSZ, GenerationAlloc(), GenerationBlockIsValid, GenerationFree(), MemoryChunkGetBlock(), MemoryChunkGetValue(), MemoryChunkIsExternal(), MemoryContextAllocationFailure(), name, PointerGetMemoryChunk, VALGRIND_MAKE_MEM_DEFINED, VALGRIND_MAKE_MEM_NOACCESS, VALGRIND_MAKE_MEM_UNDEFINED, and WARNING.
void GenerationReset | ( | MemoryContext | context | ) |
Definition at line 291 of file generation.c.
References Assert(), GenerationContext::block, GenerationContext::blocks, dlist_mutable_iter::cur, dlist_container, dlist_foreach_modify, dlist_has_next(), dlist_head_node(), dlist_is_empty(), FIRST_BLOCKHDRSZ, GenerationContext::freeblock, GenerationBlockFree(), GenerationBlockMarkEmpty(), GenerationIsValid, GenerationContext::initBlockSize, IsKeeperBlock, KeeperBlock, GenerationContext::nextBlockSize, and VALGRIND_MEMPOOL_TRIM.
Referenced by GenerationDelete().
void GenerationStats | ( | MemoryContext | context, |
MemoryStatsPrintFunc | printfunc, | ||
void * | passthru, | ||
MemoryContextCounters * | totals, | ||
bool | print_to_stderr | ||
) |
Definition at line 1062 of file generation.c.
References Assert(), GenerationBlock::blksize, GenerationContext::blocks, dlist_iter::cur, dlist_container, dlist_foreach, GenerationBlock::endptr, MemoryContextCounters::freechunks, GenerationBlock::freeptr, MemoryContextCounters::freespace, GenerationIsValid, MAXALIGN, MemoryContextCounters::nblocks, GenerationBlock::nchunks, GenerationBlock::nfree, snprintf, and MemoryContextCounters::totalspace.