PostgreSQL Source Code
git master
|
Go to the source code of this file.
Typedefs | |
typedef struct dsa_area | dsa_area |
typedef uint64 | dsa_pointer |
typedef pg_atomic_uint64 | dsa_pointer_atomic |
typedef dsm_handle | dsa_handle |
#define DSA_ALLOC_HUGE 0x01 /* allow huge allocation (> 1 GB) */ |
#define DSA_ALLOC_NO_OOM 0x02 /* no failure if out-of-memory */ |
#define dsa_allocate | ( | area, | |
size | |||
) | dsa_allocate_extended(area, size, 0) |
#define dsa_allocate0 | ( | area, | |
size | |||
) | dsa_allocate_extended(area, size, DSA_ALLOC_ZERO) |
#define dsa_create | ( | tranch_id | ) |
#define dsa_create_in_place | ( | place, | |
size, | |||
tranch_id, | |||
segment | |||
) |
#define DSA_DEFAULT_INIT_SEGMENT_SIZE ((size_t) (1 * 1024 * 1024)) |
#define DSA_HANDLE_INVALID ((dsa_handle) DSM_HANDLE_INVALID) |
#define DSA_MAX_SEGMENT_SIZE ((size_t) 1 << DSA_OFFSET_WIDTH) |
#define DSA_OFFSET_WIDTH 40 /* 1024 segments of size up to 1TB */ |
#define dsa_pointer_atomic_compare_exchange pg_atomic_compare_exchange_u64 |
#define dsa_pointer_atomic_fetch_add pg_atomic_fetch_add_u64 |
#define dsa_pointer_atomic_init pg_atomic_init_u64 |
#define dsa_pointer_atomic_read pg_atomic_read_u64 |
#define dsa_pointer_atomic_write pg_atomic_write_u64 |
#define DsaPointerIsValid | ( | x | ) | ((x) != InvalidDsaPointer) |
#define InvalidDsaPointer ((dsa_pointer) 0) |
typedef dsm_handle dsa_handle |
typedef uint64 dsa_pointer |
typedef pg_atomic_uint64 dsa_pointer_atomic |
dsa_pointer dsa_allocate_extended | ( | dsa_area * | area, |
size_t | size, | ||
int | flags | ||
) |
Definition at line 671 of file dsa.c.
References alloc_object(), AllocHugeSizeIsValid, AllocSizeIsValid, Assert, dsa_area::control, DSA_ALLOC_HUGE, DSA_ALLOC_NO_OOM, DSA_ALLOC_ZERO, DSA_AREA_LOCK, dsa_free(), dsa_get_address(), DSA_MAKE_POINTER, DSA_SCLASS_BLOCK_OF_SPANS, DSA_SCLASS_LOCK, DSA_SCLASS_SPAN_LARGE, dsa_size_class_map, DSA_SIZE_CLASS_MAP_QUANTUM, dsa_size_classes, DsaPointerIsValid, elog, ereport, errcode(), errdetail(), errmsg(), ERROR, FATAL, dsa_segment_map::fpm, FPM_PAGE_SIZE, fpm_size_to_pages, FreePageManagerGet(), get_best_segment(), get_segment_index, init_span(), InvalidDsaPointer, lengthof, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), make_new_segment(), dsa_segment_map::pagemap, dsa_area_control::pools, and size.
Referenced by dshash_create(), and pagetable_allocate().
dsa_area* dsa_attach | ( | dsa_handle | handle | ) |
Definition at line 510 of file dsa.c.
References attach_internal(), dsa_on_dsm_detach_release_in_place(), dsm_attach(), dsm_segment_address(), ereport, errcode(), errmsg(), ERROR, on_dsm_detach(), and PointerGetDatum().
Referenced by init_dsm_registry(), logicalrep_launcher_attach_dshmem(), and TidStoreAttach().
dsa_area* dsa_attach_in_place | ( | void * | place, |
dsm_segment * | segment | ||
) |
Definition at line 545 of file dsa.c.
References attach_internal(), DSA_HANDLE_INVALID, dsa_on_dsm_detach_release_in_place(), on_dsm_detach(), and PointerGetDatum().
Referenced by AttachSession(), ParallelQueryMain(), and pgstat_attach_shmem().
dsa_area* dsa_create_ext | ( | int | tranche_id, |
size_t | init_segment_size, | ||
size_t | max_segment_size | ||
) |
Definition at line 421 of file dsa.c.
References create_internal(), dsa_on_dsm_detach_release_in_place(), dsm_create(), dsm_pin_segment(), dsm_segment_address(), dsm_segment_handle(), on_dsm_detach(), and PointerGetDatum().
Referenced by TidStoreCreateShared().
dsa_area* dsa_create_in_place_ext | ( | void * | place, |
size_t | size, | ||
int | tranche_id, | ||
dsm_segment * | segment, | ||
size_t | init_segment_size, | ||
size_t | max_segment_size | ||
) |
Definition at line 471 of file dsa.c.
References create_internal(), dsa_on_dsm_detach_release_in_place(), DSM_HANDLE_INVALID, on_dsm_detach(), PointerGetDatum(), and size.
void dsa_detach | ( | dsa_area * | area | ) |
Definition at line 1952 of file dsa.c.
References dsm_detach(), dsa_area::high_segment_index, i, pfree(), dsa_segment_map::segment, and dsa_area::segment_maps.
Referenced by DetachSession(), ExecParallelCleanup(), ParallelQueryMain(), pgstat_detach_shmem(), StatsShmemInit(), test_basic(), test_dsa_basic(), test_dsa_resowners(), test_empty(), test_random(), TidStoreDestroy(), and TidStoreDetach().
void dsa_dump | ( | dsa_area * | area | ) |
Definition at line 1088 of file dsa.c.
References check_for_freed_segments_locked(), dsa_area::control, DSA_AREA_LOCK, DSA_FULLNESS_CLASSES, dsa_get_address(), DSA_NUM_SEGMENT_BINS, DSA_NUM_SIZE_CLASSES, DSA_POINTER_FORMAT, DSA_SCLASS_BLOCK_OF_SPANS, DSA_SCLASS_LOCK, DSA_SCLASS_SPAN_LARGE, DSA_SEGMENT_INDEX_NONE, dsa_size_classes, DsaPointerIsValid, dsa_segment_map::fpm, fpm_largest, fprintf, get_segment_by_index(), dsa_area_control::handle, dsa_segment_map::header, i, j, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), dsa_segment_map::mapped_address, dsa_area_control::max_total_segment_size, dsa_area_span::nallocatable, dsa_segment_header::next, dsa_area_span::nextspan, dsa_area_span::nmax, dsa_area_span::npages, dsa_area_control::pinned, dsa_area_control::pools, dsa_area_control::refcnt, dsa_area_control::segment_bins, dsa_area_pool::spans, dsa_area_span::start, dsa_area_control::total_segment_size, and dsa_segment_header::usable_pages.
void dsa_free | ( | dsa_area * | area, |
dsa_pointer | dp | ||
) |
Definition at line 826 of file dsa.c.
References add_span_to_fullness_class(), Assert, check_for_freed_segments(), destroy_superblock(), DSA_AREA_LOCK, DSA_EXTRACT_OFFSET, DSA_EXTRACT_SEGMENT_NUMBER, DSA_FULLNESS_CLASSES, dsa_get_address(), DSA_SCLASS_LOCK, DSA_SCLASS_SPAN_LARGE, dsa_size_classes, DSA_SUPERBLOCK_SIZE, dsa_area_span::fclass, dsa_area_span::firstfree, dsa_segment_map::fpm, FPM_PAGE_SIZE, FreePageManagerPut(), get_segment_by_index(), InvalidDsaPointer, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), dsa_area_span::nallocatable, NextFreeObjectIndex, dsa_area_span::nmax, dsa_area_span::npages, dsa_segment_map::pagemap, dsa_area_span::prevspan, rebin_segment(), size, dsa_area_span::size_class, dsa_area_span::start, and unlink_span().
Referenced by delete_item_from_bucket(), delete_key_from_bucket(), destroy_superblock(), dsa_allocate_extended(), dshash_create(), dshash_destroy(), ExecHashTableDetach(), ExecHashTableDetachBatch(), ExecParallelCleanup(), ExecParallelHashIncreaseNumBatches(), ExecParallelHashIncreaseNumBuckets(), ExecParallelHashRepartitionFirst(), ExecParallelReinitialize(), find_or_make_matching_shared_tupledesc(), pagetable_free(), pgstat_free_entry(), resize(), RT_FREE(), RT_FREE_LEAF(), RT_FREE_NODE(), tbm_free_shared_area(), test_dsa_basic(), and test_dsa_resowners().
void* dsa_get_address | ( | dsa_area * | area, |
dsa_pointer | dp | ||
) |
Definition at line 942 of file dsa.c.
References Assert, check_for_freed_segments(), DSA_EXTRACT_OFFSET, DSA_EXTRACT_SEGMENT_NUMBER, DSA_MAX_SEGMENTS, DsaPointerIsValid, get_segment_by_index(), dsa_segment_map::mapped_address, dsa_area::segment_maps, and unlikely.
Referenced by add_span_to_fullness_class(), alloc_object(), delete_item_from_bucket(), delete_key_from_bucket(), destroy_superblock(), dsa_allocate_extended(), dsa_dump(), dsa_free(), dsa_trim(), dshash_attach(), dshash_create(), dshash_destroy(), dshash_dump(), dshash_seq_next(), ensure_active_superblock(), ensure_valid_bucket_pointers(), ExecHashTableDetachBatch(), ExecParallelHashEnsureBatchAccessors(), ExecParallelHashFirstTuple(), ExecParallelHashIncreaseNumBatches(), ExecParallelHashIncreaseNumBuckets(), ExecParallelHashJoinSetUpBatches(), ExecParallelHashNextTuple(), ExecParallelHashPopChunkQueue(), ExecParallelHashRepartitionRest(), ExecParallelHashTableAlloc(), ExecParallelHashTableSetCurrentBatch(), ExecParallelHashTupleAlloc(), find_in_bucket(), find_or_make_matching_shared_tupledesc(), init_span(), insert_into_bucket(), insert_item_into_bucket(), lookup_rowtype_tupdesc_internal(), pagetable_allocate(), ParallelQueryMain(), pgstat_build_snapshot(), pgstat_get_entry_ref(), pgstat_init_entry(), pgstat_reinit_entry(), pgstat_reset_matching_entries(), pgstat_write_statsfile(), resize(), RT_PTR_SET_LOCAL(), SerializeParamExecParams(), share_tupledesc(), shared_record_table_compare(), shared_record_table_hash(), tbm_attach_shared_iterate(), tbm_free_shared_area(), tbm_prepare_shared_iterate(), test_dsa_basic(), test_dsa_resowners(), transfer_first_span(), and unlink_span().
dsa_handle dsa_get_handle | ( | dsa_area * | area | ) |
Definition at line 498 of file dsa.c.
References Assert, dsa_area::control, DSA_HANDLE_INVALID, and dsa_area_control::handle.
Referenced by init_dsm_registry(), logicalrep_launcher_attach_dshmem(), parallel_vacuum_init(), and parallel_vacuum_reset_dead_items().
size_t dsa_get_total_size | ( | dsa_area * | area | ) |
Definition at line 1027 of file dsa.c.
References dsa_area::control, DSA_AREA_LOCK, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), size, and dsa_area_control::total_segment_size.
Referenced by RT_MEMORY_USAGE().
size_t dsa_minimum_size | ( | void | ) |
Definition at line 1196 of file dsa.c.
References FPM_PAGE_SIZE, MAXALIGN, and size.
Referenced by create_internal(), ExecInitParallelPlan(), and pgstat_dsa_init_size().
void dsa_on_dsm_detach_release_in_place | ( | dsm_segment * | segment, |
Datum | place | ||
) |
Definition at line 576 of file dsa.c.
References DatumGetPointer(), and dsa_release_in_place().
Referenced by dsa_attach(), dsa_attach_in_place(), dsa_create_ext(), and dsa_create_in_place_ext().
void dsa_on_shmem_exit_release_in_place | ( | int | code, |
Datum | place | ||
) |
Definition at line 590 of file dsa.c.
References DatumGetPointer(), and dsa_release_in_place().
void dsa_pin | ( | dsa_area * | area | ) |
Definition at line 975 of file dsa.c.
References dsa_area::control, DSA_AREA_LOCK, elog, ERROR, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), dsa_area_control::pinned, and dsa_area_control::refcnt.
Referenced by init_dsm_registry(), logicalrep_launcher_attach_dshmem(), and StatsShmemInit().
void dsa_pin_mapping | ( | dsa_area * | area | ) |
Definition at line 635 of file dsa.c.
References dsm_pin_mapping(), dsa_area::high_segment_index, i, dsa_area::resowner, dsa_segment_map::segment, and dsa_area::segment_maps.
Referenced by AttachSession(), GetSessionDsmHandle(), init_dsm_registry(), logicalrep_launcher_attach_dshmem(), pgstat_attach_shmem(), and test_create().
void dsa_release_in_place | ( | void * | place | ) |
Definition at line 605 of file dsa.c.
References Assert, DSA_SEGMENT_HEADER_MAGIC, DSM_HANDLE_INVALID, dsm_unpin_segment(), dsa_area_control::handle, dsa_area_control::high_segment_index, i, dsa_area_control::lock, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), dsa_segment_header::magic, dsa_area_control::refcnt, dsa_area_control::segment_handles, and dsa_area_control::segment_header.
Referenced by dsa_on_dsm_detach_release_in_place(), dsa_on_shmem_exit_release_in_place(), and pgstat_detach_shmem().
void dsa_set_size_limit | ( | dsa_area * | area, |
size_t | limit | ||
) |
Definition at line 1018 of file dsa.c.
References dsa_area::control, DSA_AREA_LOCK, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), and dsa_area_control::max_total_segment_size.
Referenced by StatsShmemInit().
void dsa_trim | ( | dsa_area * | area | ) |
Definition at line 1043 of file dsa.c.
References dsa_area::control, destroy_superblock(), dsa_get_address(), DSA_NUM_SIZE_CLASSES, DSA_SCLASS_LOCK, DSA_SCLASS_SPAN_LARGE, DsaPointerIsValid, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), dsa_area_span::nallocatable, next, dsa_area_span::nextspan, dsa_area_span::nmax, dsa_area_control::pools, and dsa_area_pool::spans.
void dsa_unpin | ( | dsa_area * | area | ) |
Definition at line 994 of file dsa.c.
References Assert, dsa_area::control, DSA_AREA_LOCK, elog, ERROR, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), dsa_area_control::pinned, and dsa_area_control::refcnt.