PostgreSQL Source Code
git master
|
#include "storage/dsm_impl.h"
Go to the source code of this file.
Macros | |
#define | DSM_CREATE_NULL_IF_MAXSEGMENTS 0x0001 |
Typedefs | |
typedef struct dsm_segment | dsm_segment |
typedef void(* | on_dsm_detach_callback) (dsm_segment *, Datum arg) |
Functions | |
void | dsm_cleanup_using_control_segment (dsm_handle old_control_handle) |
void | dsm_postmaster_startup (struct PGShmemHeader *) |
void | dsm_backend_shutdown (void) |
void | dsm_detach_all (void) |
size_t | dsm_estimate_size (void) |
void | dsm_shmem_init (void) |
dsm_segment * | dsm_create (Size size, int flags) |
dsm_segment * | dsm_attach (dsm_handle h) |
void | dsm_detach (dsm_segment *seg) |
void | dsm_pin_mapping (dsm_segment *seg) |
void | dsm_unpin_mapping (dsm_segment *seg) |
void | dsm_pin_segment (dsm_segment *seg) |
void | dsm_unpin_segment (dsm_handle handle) |
dsm_segment * | dsm_find_mapping (dsm_handle handle) |
void * | dsm_segment_address (dsm_segment *seg) |
Size | dsm_segment_map_length (dsm_segment *seg) |
dsm_handle | dsm_segment_handle (dsm_segment *seg) |
void | on_dsm_detach (dsm_segment *seg, on_dsm_detach_callback function, Datum arg) |
void | cancel_on_dsm_detach (dsm_segment *seg, on_dsm_detach_callback function, Datum arg) |
void | reset_on_dsm_detach (void) |
typedef struct dsm_segment dsm_segment |
typedef void(* on_dsm_detach_callback) (dsm_segment *, Datum arg) |
void cancel_on_dsm_detach | ( | dsm_segment * | seg, |
on_dsm_detach_callback | function, | ||
Datum | arg | ||
) |
Definition at line 1147 of file dsm.c.
References dsm_segment_detach_callback::arg, arg, slist_mutable_iter::cur, dsm_segment_detach_callback::function, dsm_segment::on_detach, pfree(), slist_container, slist_delete_current(), and slist_foreach_modify.
Referenced by shm_mq_detach(), and test_shm_mq_setup().
dsm_segment* dsm_attach | ( | dsm_handle | h | ) |
Definition at line 665 of file dsm.c.
References Assert, dsm_segment::control_slot, dlist_iter::cur, dlist_container, dlist_foreach, dsm_backend_startup(), dsm_control, dsm_create_descriptor(), dsm_detach(), dsm_impl_op(), dsm_init_done, dsm_main_space_begin, DSM_OP_ATTACH, dsm_segment_list, elog, ERROR, dsm_control_item::first_page, FPM_PAGE_SIZE, dsm_segment::handle, dsm_control_item::handle, i, dsm_segment::impl_private, INVALID_CONTROL_SLOT, is_main_region_dsm_handle(), IsUnderPostmaster, dsm_control_header::item, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), dsm_segment::mapped_address, dsm_segment::mapped_size, dsm_control_header::nitems, nitems, dsm_control_item::npages, and dsm_control_item::refcnt.
Referenced by AttachSession(), autoprewarm_database_main(), dsa_attach(), get_segment_by_index(), GetNamedDSMSegment(), ParallelApplyWorkerMain(), ParallelWorkerMain(), and test_shm_mq_main().
void dsm_backend_shutdown | ( | void | ) |
Definition at line 757 of file dsm.c.
References dlist_head_element, dlist_is_empty(), dsm_detach(), and dsm_segment_list.
Referenced by shmem_exit().
void dsm_cleanup_using_control_segment | ( | dsm_handle | old_control_handle | ) |
Definition at line 238 of file dsm.c.
References DEBUG1, DEBUG2, dsm_control_segment_sane(), dsm_impl_op(), DSM_OP_ATTACH, DSM_OP_DESTROY, DSM_OP_DETACH, elog, dsm_control_item::handle, i, is_main_region_dsm_handle(), dsm_control_header::item, LOG, dsm_control_header::nitems, nitems, and dsm_control_item::refcnt.
Referenced by PGSharedMemoryCreate().
dsm_segment* dsm_create | ( | Size | size, |
int | flags | ||
) |
Definition at line 516 of file dsm.c.
References Assert, dsm_segment::control_slot, dlist_delete(), dsm_backend_startup(), dsm_control, dsm_create_descriptor(), DSM_CREATE_NULL_IF_MAXSEGMENTS, DSM_HANDLE_INVALID, dsm_impl_op(), dsm_init_done, dsm_main_space_begin, DSM_OP_CREATE, DSM_OP_DESTROY, ereport, errcode(), errmsg(), ERROR, dsm_control_item::first_page, FPM_PAGE_SIZE, FreePageManagerGet(), FreePageManagerPut(), dsm_segment::handle, dsm_control_item::handle, i, dsm_segment::impl_private, dsm_control_item::impl_private_pm_handle, is_main_region_dsm_handle(), IsPostmasterEnvironment, IsUnderPostmaster, dsm_control_header::item, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), make_main_region_dsm_handle(), dsm_segment::mapped_address, dsm_segment::mapped_size, dsm_control_header::maxitems, dsm_control_header::nitems, nitems, dsm_segment::node, dsm_control_item::npages, pfree(), pg_global_prng_state, pg_prng_uint32(), dsm_control_item::pinned, dsm_control_item::refcnt, ResourceOwnerForgetDSM(), dsm_segment::resowner, size, and WARNING.
Referenced by apw_load_buffers(), dsa_create_ext(), GetNamedDSMSegment(), GetSessionDsmHandle(), InitializeParallelDSM(), make_new_segment(), pa_setup_dsm(), and setup_dynamic_shared_memory().
void dsm_detach | ( | dsm_segment * | seg | ) |
Definition at line 803 of file dsm.c.
References dsm_segment_detach_callback::arg, arg, Assert, dsm_segment::control_slot, dlist_delete(), dsm_control, dsm_impl_op(), dsm_main_space_begin, DSM_OP_DESTROY, DSM_OP_DETACH, dsm_control_item::first_page, FreePageManagerPut(), dsm_segment_detach_callback::function, dsm_segment::handle, dsm_control_item::handle, HOLD_INTERRUPTS, dsm_segment::impl_private, INVALID_CONTROL_SLOT, is_main_region_dsm_handle(), dsm_control_header::item, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), dsm_segment::mapped_address, dsm_segment::mapped_size, dsm_segment::node, dsm_control_item::npages, dsm_segment::on_detach, pfree(), dsm_control_item::pinned, dsm_control_item::refcnt, ResourceOwnerForgetDSM(), dsm_segment::resowner, RESUME_INTERRUPTS, slist_container, slist_is_empty(), slist_pop_head_node(), and WARNING.
Referenced by apw_load_buffers(), autoprewarm_database_main(), check_for_freed_segments_locked(), destroy_superblock(), DestroyParallelContext(), DetachSession(), dsa_detach(), dsm_attach(), dsm_backend_shutdown(), dsm_detach_all(), pa_free_worker_info(), pa_shutdown(), ParallelWorkerShutdown(), ResOwnerReleaseDSM(), test_shm_mq(), test_shm_mq_main(), and test_shm_mq_pipelined().
void dsm_detach_all | ( | void | ) |
Definition at line 775 of file dsm.c.
References dlist_head_element, dlist_is_empty(), dsm_control, dsm_control_handle, dsm_control_impl_private, dsm_control_mapped_size, dsm_detach(), dsm_impl_op(), DSM_OP_DETACH, dsm_segment_list, and ERROR.
Referenced by postmaster_child_launch().
size_t dsm_estimate_size | ( | void | ) |
Definition at line 470 of file dsm.c.
References min_dynamic_shared_memory.
Referenced by CalculateShmemSize(), and dsm_shmem_init().
dsm_segment* dsm_find_mapping | ( | dsm_handle | handle | ) |
Definition at line 1076 of file dsm.c.
References dlist_iter::cur, dlist_container, dlist_foreach, dsm_segment_list, and dsm_segment::handle.
Referenced by GetNamedDSMSegment().
void dsm_pin_mapping | ( | dsm_segment * | seg | ) |
Definition at line 915 of file dsm.c.
References ResourceOwnerForgetDSM(), and dsm_segment::resowner.
Referenced by AttachSession(), dsa_pin_mapping(), GetNamedDSMSegment(), and GetSessionDsmHandle().
void dsm_pin_segment | ( | dsm_segment * | seg | ) |
Definition at line 955 of file dsm.c.
References dsm_segment::control_slot, dsm_control, dsm_impl_pin_segment(), elog, ERROR, dsm_segment::handle, dsm_segment::impl_private, dsm_control_item::impl_private_pm_handle, is_main_region_dsm_handle(), dsm_control_header::item, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), dsm_control_item::pinned, and dsm_control_item::refcnt.
Referenced by dsa_create_ext(), GetNamedDSMSegment(), and make_new_segment().
void dsm_postmaster_startup | ( | struct PGShmemHeader * | shim | ) |
Definition at line 177 of file dsm.c.
References Assert, DEBUG2, dsm_cleanup_for_mmap(), dsm_control, PGShmemHeader::dsm_control, dsm_control_bytes_needed(), dsm_control_handle, dsm_control_impl_private, dsm_control_mapped_size, DSM_HANDLE_INVALID, DSM_IMPL_MMAP, dsm_impl_op(), DSM_OP_CREATE, dsm_postmaster_shutdown(), dynamic_shared_memory_type, elog, ERROR, IsUnderPostmaster, dsm_control_header::magic, MaxBackends, dsm_control_header::maxitems, dsm_control_header::nitems, on_shmem_exit(), PG_DYNSHMEM_CONTROL_MAGIC, PG_DYNSHMEM_FIXED_SLOTS, PG_DYNSHMEM_SLOTS_PER_BACKEND, pg_global_prng_state, pg_prng_uint32(), and PointerGetDatum().
Referenced by CreateSharedMemoryAndSemaphores().
void* dsm_segment_address | ( | dsm_segment * | seg | ) |
Definition at line 1095 of file dsm.c.
References Assert, and dsm_segment::mapped_address.
Referenced by apw_load_buffers(), AttachSession(), autoprewarm_database_main(), dsa_attach(), dsa_create_ext(), get_segment_by_index(), GetNamedDSMSegment(), GetSessionDsmHandle(), InitializeParallelDSM(), make_new_segment(), pa_setup_dsm(), ParallelApplyWorkerMain(), ParallelWorkerMain(), setup_dynamic_shared_memory(), and test_shm_mq_main().
dsm_handle dsm_segment_handle | ( | dsm_segment * | seg | ) |
Definition at line 1123 of file dsm.c.
References dsm_segment::handle.
Referenced by apw_load_buffers(), destroy_superblock(), dsa_create_ext(), GetNamedDSMSegment(), GetSessionDsmHandle(), LaunchParallelWorkers(), make_new_segment(), pa_launch_parallel_worker(), ResOwnerPrintDSM(), and setup_background_workers().
Size dsm_segment_map_length | ( | dsm_segment * | seg | ) |
Definition at line 1105 of file dsm.c.
References Assert, dsm_segment::mapped_address, and dsm_segment::mapped_size.
void dsm_shmem_init | ( | void | ) |
Definition at line 479 of file dsm.c.
References dsm_estimate_size(), dsm_main_space_begin, FPM_PAGE_SIZE, FreePageManagerInitialize(), FreePageManagerPut(), ShmemInitStruct(), and size.
Referenced by CreateOrAttachShmemStructs().
void dsm_unpin_mapping | ( | dsm_segment * | seg | ) |
Definition at line 934 of file dsm.c.
References Assert, CurrentResourceOwner, ResourceOwnerEnlarge(), ResourceOwnerRememberDSM(), and dsm_segment::resowner.
void dsm_unpin_segment | ( | dsm_handle | handle | ) |
Definition at line 988 of file dsm.c.
References Assert, dsm_control, dsm_impl_op(), dsm_impl_unpin_segment(), dsm_main_space_begin, DSM_OP_DESTROY, elog, ERROR, dsm_control_item::first_page, FreePageManagerPut(), dsm_control_item::handle, i, dsm_control_item::impl_private_pm_handle, INVALID_CONTROL_SLOT, is_main_region_dsm_handle(), dsm_control_header::item, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), dsm_control_header::nitems, dsm_control_item::npages, dsm_control_item::pinned, dsm_control_item::refcnt, and WARNING.
Referenced by destroy_superblock(), and dsa_release_in_place().
void on_dsm_detach | ( | dsm_segment * | seg, |
on_dsm_detach_callback | function, | ||
Datum | arg | ||
) |
Definition at line 1132 of file dsm.c.
References dsm_segment_detach_callback::arg, arg, dsm_segment_detach_callback::function, MemoryContextAlloc(), dsm_segment_detach_callback::node, dsm_segment::on_detach, slist_push_head(), and TopMemoryContext.
Referenced by dsa_attach(), dsa_attach_in_place(), dsa_create_ext(), dsa_create_in_place_ext(), pq_redirect_to_shm_mq(), setup_background_workers(), SharedFileSetAttach(), SharedFileSetInit(), SharedRecordTypmodRegistryAttach(), SharedRecordTypmodRegistryInit(), and shm_mq_attach().
void reset_on_dsm_detach | ( | void | ) |
Definition at line 1170 of file dsm.c.
References dsm_segment::control_slot, dlist_iter::cur, dlist_container, dlist_foreach, dsm_segment_list, INVALID_CONTROL_SLOT, dsm_segment::on_detach, pfree(), slist_container, slist_is_empty(), and slist_pop_head_node().
Referenced by on_exit_reset().