18 #ifndef FOEDUS_SOC_SHARED_MEMORY_REPO_HPP_
19 #define FOEDUS_SOC_SHARED_MEMORY_REPO_HPP_
104 static_cast<int>(new_status) == static_cast<int>(
status_code_) + 1);
181 static_cast<int>(new_status) == static_cast<int>(
status_code_) + 1);
235 void clear() { std::memset(
this, 0,
sizeof(*
this)); }
325 void clear() { std::memset(
this, 0,
sizeof(*
this)); }
491 uint64_t master_upid,
571 void set_global_memory_anchors(
574 bool reset_boundaries);
575 void put_global_memory_boundary(
577 const std::string& name,
578 bool reset_boundaries) {
582 if (reset_boundaries) {
583 boundary->
reset(name);
592 void set_node_memory_anchors(
SocId node,
const EngineOptions& options,
bool reset_boundaries);
593 void put_node_memory_boundary(
596 const std::string& name,
597 bool reset_boundaries) {
598 char* base = node_memories_[node].
get_block();
599 assorted::ProtectedBoundary* boundary
600 =
reinterpret_cast<assorted::ProtectedBoundary*
>(base + (*position));
601 if (reset_boundaries) {
602 boundary->
reset(name);
608 *position +=
sizeof(assorted::ProtectedBoundary);
613 static void allocate_one_node(
617 uint64_t node_memory_size,
618 bool rigorous_memory_boundary_check,
619 bool rigorous_page_boundary_check,
620 ErrorStack* alloc_result,
625 sizeof(MasterEngineStatus) <= (1 << 12),
626 "Size of MasterEngineStatus exceeds 4kb");
629 sizeof(ChildEngineStatus) <= (1 << 12),
630 "Size of ChildEngineStatus exceeds 4kb");
634 #endif // FOEDUS_SOC_SHARED_MEMORY_REPO_HPP_
xct::McsRwAsyncMapping * mcs_rw_async_mappings_memories_
uint32_t protected_boundaries_count_
To be a POD, we avoid vector and instead uses a fix-sized array.
ErrorStack allocate_shared_memories(uint64_t upid, Eid eid, const EngineOptions &options)
Master process creates shared memories by calling this method.
NodeMemoryAnchors & operator=(const NodeMemoryAnchors &other)=delete
void * get_global_memory()
Definitions of IDs in this package and a few related constant values.
char * options_xml_
The xml itself.
GlobalMemoryAnchors & operator=(const GlobalMemoryAnchors &other)=delete
The master engine has normally terminated.
ModuleType initialized_modules_
The module that has been most recently initialized in this node.
Forward declarations of classes in log manager package.
A 4kb dummy data placed between separate memory regions so that we can check if/where a bogus memory ...
#define CXX11_NULLPTR
Used in public headers in place of "nullptr" of C++11.
void change_master_status(MasterEngineStatus::StatusCode new_status)
void reset(const std::string &boundary_name)
Fills the block with magic words.
storage::StorageId * storage_name_sort_memory_
This memory stores the ID of storages sorted by their names.
uint32_t StorageId
Unique ID for storage.
uint64_t options_xml_length_
The beginning of global memory is an XML-serialized EngineOption.
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
void * partitioner_data_
Data block to place detailed information of partitioners.
xct::McsRwExtendedBlock * mcs_rw_extended_lock_memories_
The master is waiting for child engines to terminate.
proc::LocalProcId * proc_name_sort_memory_
This memory stores the ID of procedures sorted by their names.
GlobalMemoryAnchors * get_global_memory_anchors()
log::LogManagerControlBlock * log_manager_memory_
Tiny memory for log manager.
Typedefs of ID types used in thread package.
StatusCode
These statuses represent each step described in SocManager comment.
log::LoggerControlBlock ** logger_memories_
Status and synchronization mechanism for loggers on this node.
void * volatile_page_pool_
By far the largest memory for volatile page pool on this node.
Shared data of ThreadPimpl.
void deallocate_shared_memories()
Detaches and releases the shared memories.
Forward declarations of classes in transaction package.
void change_status_atomic(StatusCode new_status)
Update the value of status_code_ with fence.
char * get_block() const
Returns the memory block.
void change_status_atomic(StatusCode new_status)
Update the value of status_code_ with fence.
ThreadLocalOrdinal decompose_numa_local_ordinal(ThreadId global_id)
Extracts local ordinal from the given globally unique ID of Thread (core).
Whenever child observes this, they will call _exit() asap.
Shared data in StorageManagerPimpl.
Brings error stacktrace information as return value of functions.
void * get_volatile_pool(SocId node)
Reader-writer (RW) MCS lock classes.
void * user_memory_
This 'user memory' can be used for arbitrary purporses by the user to communicate between SOCs...
Forward declarations of classes in snapshot manager package.
StatusCode read_status_atomic() const
Read status_code_ with fence.
Same as GlobalMemoryAnchors except this is for node_memories_.
Typedefs of ID types used in SOC package.
void mark_for_release()
Marks shared memories as being removed so that it will be reclaimed when all processes detach it...
Part of NodeMemoryAnchors for each thread.
NodeMemoryAnchors * get_node_memory_anchors(SocId node)
log::MetaLogControlBlock * meta_logger_memory_
Tiny memory for metadata logger.
Shared data in XctManagerPimpl.
void * task_input_memory_
Input buffer for an impersonated task.
ModuleType initialized_modules_
The module that has been most recently initialized in master.
Forward declarations of classes in restart package.
storage::StorageControlBlock * storage_memories_
Status of each storage instance is stored in this shared memory.
Child engine successfully attached shared memory and waiting for master's kWaitingForChildInitializat...
ModuleType
Enumerates modules in FOEDUS engine.
3 << 19 is for FixedSavepoint.
ChildEngineStatus()=delete
Represents memory shared between processes.
proc::ProcManagerControlBlock * proc_manager_memory_
ProcManagers's status and its synchronization mechanism on this node.
The child engine has normally terminated.
storage::StorageManagerControlBlock * storage_manager_memory_
Tiny memory for storage manager.
uint32_t protected_boundaries_count_
To be a POD, we avoid vector and instead uses a fix-sized array.
void change_uninit_atomic(ModuleType value)
Forward declarations of classes in storage package.
storage::PartitionerMetadata * partitioner_metadata_
Tiny metadata memory for partitioners.
Pre-allocated MCS block for WW-locks.
Definitions of IDs in this package and a few related constant values.
Current status of master engine.
ErrorStack attach_shared_memories(uint64_t master_upid, Eid master_eid, SocId my_soc_id, EngineOptions *options)
Child processes (emulated or not) set a reference to shared memory and receive the EngnieOption value...
#define CXX11_FINAL
Used in public headers in place of "final" of C++11.
static uint64_t calculate_global_memory_size(uint64_t xml_size, const EngineOptions &options)
Pre-allocated MCS block for extended version of RW-locks.
Shared data in LogManagerPimpl.
xct::McsWwBlock * mcs_ww_lock_memories_
Pre-allocated MCS block for each thread.
Done all initialization and running transactions.
ThreadMemoryAnchors & operator=(const ThreadMemoryAnchors &other)=delete
SharedMemoryRepo & operator=(const SharedMemoryRepo &other)=delete
Shared data for LogReducer.
Typedefs of ID types used in procedure package.
thread::ThreadControlBlock * thread_memory_
Status and synchronization mechanism for impersonation of this thread.
Just a marker to denote that the memory region represents a data page.
std::pair< ProcName, Proc > ProcAndName
Set of option values given to the engine at start-up.
Child engine has successfully initialized all modules and is now waiting for master's kRunning status...
snapshot::LogReducerControlBlock * log_reducer_memory_
Tiny control memory for LogReducer in this node.
xct::McsRwSimpleBlock * mcs_rw_simple_lock_memories_
ThreadGroupId decompose_numa_node(ThreadId global_id)
Extracts NUMA node ID from the given globally unique ID of Thread (core).
Shared data in SavepointManagerPimpl.
Current status of a child SOC engine.
#define CXX11_STATIC_ASSERT(expr, message)
Used in public headers in place of "static_assert" of C++11.
static uint64_t calculate_node_memory_size(const EngineOptions &options)
void * log_reducer_buffers_[2]
Actual buffers for LogReducer.
xct::XctManagerControlBlock * xct_manager_memory_
Tiny memory for xct manager.
Repository of all shared memory in one FOEDUS instance.
MasterEngineStatus()=delete
Forward declarations of classes in memory package.
Just a set of pointers within global_memory_ for ease of use.
snapshot::SnapshotManagerControlBlock * snapshot_manager_memory_
Tiny memory for snapshot manager.
void * get_node_memory(SocId node)
storage::Page * log_reducer_root_info_pages_
This is the 'output' of the reducer in this node.
Shared data in PagePoolPimpl.
Shared data in SnapshotManagerPimpl.
Forward declarations of classes in SOC package.
Shared data in RestartManagerPimpl.
uint16_t SocId
Represents an ID of an SOC, or NUMA node.
ThreadMemoryAnchors * thread_anchors_
Anchors for each thread.
#define CXX11_FUNC_DELETE
Used in public headers in place of " = delete" of C++11.
Forward declarations of classes in savepoint manager package.
void change_init_atomic(ModuleType value)
Child engine has just started.
uint16_t ThreadId
Typedef for a global ID of Thread (core), which is unique across NUMA nodes.
void change_init_atomic(ModuleType value)
proc::ProcAndName * proc_memory_
Procedure list on this node.
MasterEngineStatus * master_status_memory_
This tiny piece of memory contains the current status of the master engine and its synchronization me...
This small control block is used to synchronize the access to the array.
void allocate_arrays(const EngineOptions &options)
Atomic fence methods and load/store with fences that work for both C++11/non-C++11 code...
void change_uninit_atomic(ModuleType value)
ChildEngineStatus * child_status_memory_
This tiny piece of memory contains the current status of the child engine on this node...
savepoint::SavepointManagerControlBlock * savepoint_manager_memory_
Tiny memory for savepoint manager.
uint32_t LocalProcId
Represents a locally-unique ID of a procedure in one SOC.
uint64_t Eid
An Engine ID to differentiate two Engine objects instantiated in the same process.
assorted::ProtectedBoundary * protected_boundaries_[kMaxBoundaries]
sanity check boundaries to detect bogus memory accesses that overrun a memory region ...
Done all initialization and running transactions.
void change_child_status(SocId node, ChildEngineStatus::StatusCode new_status)
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
restart::RestartManagerControlBlock * restart_manager_memory_
Tiny memory for restart manager.
Forward declarations of classes in thread package.
ThreadMemoryAnchors * get_thread_memory_anchors(thread::ThreadId thread_id)
ModuleType uninitialized_modules_
The module that has been most recently closed in master.
Forward declarations of classes in proc package.
A base layout of shared data for all storage types.
bool protected_boundaries_needs_release_
whether we have invoked mprotect on them
StatusCode read_status_atomic() const
Read status_code_ with fence.
memory::PagePoolControlBlock * volatile_pool_status_
PagePool's status and its synchronization mechanism for the volatile pool on this node...
bool protected_boundaries_needs_release_
whether we have invoked mprotect on them
ModuleType uninitialized_modules_
The module that has been most recently closed in this node.
ChildEngineStatus::StatusCode get_child_status(SocId node) const
void * get_global_user_memory()
Master engine successfully allocated shared memory and waiting for child's attach.
assorted::ProtectedBoundary * protected_boundaries_[kMaxBoundaries]
sanity check boundaries to detect bogus memory accesses that overrun a memory region ...
Master engine successfully confirmed child's attach and reserved the reclamation of the shared memori...
StatusCode
These statuses represent each step described in SocManager comment.
Master engine has just started.
The child engine observed some unrecoverable error and has exit.
MasterEngineStatus::StatusCode get_master_status() const
void memory_fence_acq_rel()
Equivalent to std::atomic_thread_fence(std::memory_order_acq_rel).
void * task_output_memory_
Output buffer for an impersonated task.