libfoedus-core
FOEDUS Core Library
foedus::soc::SharedMemoryRepo Class Referencefinal

Repository of all shared memory in one FOEDUS instance. More...

Detailed Description

Repository of all shared memory in one FOEDUS instance.

These are the memories shared across SOCs, which are allocated at initialization. Be super careful on objects placed in these shared memories. You can't put objects with heap-allocated contents, such as std::string.

Definition at line 463 of file shared_memory_repo.hpp.

#include <shared_memory_repo.hpp>

Public Member Functions

 SharedMemoryRepo ()
 
 ~SharedMemoryRepo ()
 
 SharedMemoryRepo (const SharedMemoryRepo &other)=delete
 
SharedMemoryRepooperator= (const SharedMemoryRepo &other)=delete
 
ErrorStack allocate_shared_memories (uint64_t upid, Eid eid, const EngineOptions &options)
 Master process creates shared memories by calling this method. More...
 
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 by calling this method. More...
 
void mark_for_release ()
 Marks shared memories as being removed so that it will be reclaimed when all processes detach it. More...
 
void deallocate_shared_memories ()
 Detaches and releases the shared memories. More...
 
void * get_global_memory ()
 
GlobalMemoryAnchorsget_global_memory_anchors ()
 
void * get_global_user_memory ()
 
void change_master_status (MasterEngineStatus::StatusCode new_status)
 
MasterEngineStatus::StatusCode get_master_status () const
 
void * get_node_memory (SocId node)
 
NodeMemoryAnchorsget_node_memory_anchors (SocId node)
 
void change_child_status (SocId node, ChildEngineStatus::StatusCode new_status)
 
ChildEngineStatus::StatusCode get_child_status (SocId node) const
 
ThreadMemoryAnchorsget_thread_memory_anchors (thread::ThreadId thread_id)
 
void * get_volatile_pool (SocId node)
 

Static Public Member Functions

static uint64_t calculate_global_memory_size (uint64_t xml_size, const EngineOptions &options)
 
static uint64_t calculate_node_memory_size (const EngineOptions &options)
 

Constructor & Destructor Documentation

foedus::soc::SharedMemoryRepo::SharedMemoryRepo ( )
inline

Definition at line 465 of file shared_memory_repo.hpp.

465  :
466  soc_count_(0),
467  my_soc_id_(0),
468  node_memories_(CXX11_NULLPTR),
469  node_memory_anchors_(CXX11_NULLPTR) {}
#define CXX11_NULLPTR
Used in public headers in place of "nullptr" of C++11.
Definition: cxx11.hpp:132
foedus::soc::SharedMemoryRepo::~SharedMemoryRepo ( )
inline

Definition at line 470 of file shared_memory_repo.hpp.

References deallocate_shared_memories().

void deallocate_shared_memories()
Detaches and releases the shared memories.

Here is the call graph for this function:

foedus::soc::SharedMemoryRepo::SharedMemoryRepo ( const SharedMemoryRepo other)
delete

Member Function Documentation

ErrorStack foedus::soc::SharedMemoryRepo::allocate_shared_memories ( uint64_t  upid,
Eid  eid,
const EngineOptions options 
)

Master process creates shared memories by calling this method.

Definition at line 96 of file shared_memory_repo.cpp.

References foedus::soc::align_2mb(), foedus::memory::SharedMemory::alloc(), calculate_global_memory_size(), calculate_node_memory_size(), CHECK_ERROR, deallocate_shared_memories(), foedus::memory::SharedMemory::get_block(), foedus::soc::get_self_path(), foedus::soc::MasterEngineStatus::kInitial, foedus::soc::kMaxSocs, foedus::kRetOk, foedus::soc::GlobalMemoryAnchors::master_status_memory_, foedus::EngineOptions::memory_, foedus::memory::MemoryOptions::rigorous_memory_boundary_check_, foedus::memory::MemoryOptions::rigorous_page_boundary_check_, foedus::externalize::Externalizable::save_to_stream(), and foedus::soc::MasterEngineStatus::status_code_.

Referenced by foedus::soc::SocManagerPimpl::initialize_master().

99  {
101  init_empty(options);
102 
103  // We place a serialized EngineOptions in the beginning of shared memory.
104  std::stringstream options_stream;
105  options.save_to_stream(&options_stream);
106  std::string xml(options_stream.str());
107  uint64_t xml_size = xml.size();
108 
109  // construct unique meta files using PID.
110  uint64_t global_memory_size = align_2mb(calculate_global_memory_size(xml_size, options));
111  std::string global_memory_path = get_self_path(upid, eid) + std::string("_global");
112  const bool global_hugepages = !options.memory_.rigorous_memory_boundary_check_;
113  CHECK_ERROR(global_memory_.alloc(global_memory_path, global_memory_size, 0, global_hugepages));
114 
115  // from now on, be very careful to not exit without releasing this shared memory.
116 
117  set_global_memory_anchors(xml_size, options, true);
119 
120  // copy the EngineOptions string into the beginning of the global memory
121  std::memcpy(global_memory_.get_block(), &xml_size, sizeof(xml_size));
122  std::memcpy(global_memory_.get_block() + sizeof(xml_size), xml.data(), xml_size);
123 
124  // the following is parallelized
125  uint64_t node_memory_size = align_2mb(calculate_node_memory_size(options));
126  ErrorStack alloc_results[kMaxSocs];
127  std::vector< std::thread > alloc_threads;
128  for (uint16_t node = 0; node < soc_count_; ++node) {
129  alloc_threads.emplace_back(std::thread(
130  SharedMemoryRepo::allocate_one_node,
131  upid,
132  eid,
133  node,
134  node_memory_size,
135  options.memory_.rigorous_memory_boundary_check_,
136  options.memory_.rigorous_page_boundary_check_,
137  alloc_results + node,
138  this));
139  }
140 
141  ErrorStack last_error;
142  bool failed = false;
143  for (uint16_t node = 0; node < soc_count_; ++node) {
144  alloc_threads[node].join();
145  if (alloc_results[node].is_error()) {
146  std::cerr << "[FOEDUS] Failed to allocate node shared memory for node-" << node
147  << ". " << alloc_results[node] << std::endl;
148  last_error = alloc_results[node];
149  failed = true;
150  }
151  }
152 
153  if (failed) {
155  return last_error;
156  }
157 
158  for (uint16_t node = 0; node < soc_count_; ++node) {
159  set_node_memory_anchors(node, options, true);
160  }
161 
162  return kRetOk;
163 }
void deallocate_shared_memories()
Detaches and releases the shared memories.
char * get_block() const
Returns the memory block.
std::string get_self_path(uint64_t upid, Eid eid)
uint64_t align_2mb(uint64_t value)
static uint64_t calculate_global_memory_size(uint64_t xml_size, const EngineOptions &options)
static uint64_t calculate_node_memory_size(const EngineOptions &options)
#define CHECK_ERROR(x)
This macro calls x and checks its returned value.
const ErrorStack kRetOk
Normal return value for no-error case.
MasterEngineStatus * master_status_memory_
This tiny piece of memory contains the current status of the master engine and its synchronization me...
ErrorStack alloc(const std::string &meta_path, uint64_t size, int numa_node, bool use_hugepages)
Newly allocate a shared memory of given size on given NUMA node.
const uint16_t kMaxSocs
Maximum number of SOCs.
Definition: soc_id.hpp:35
Master engine has just started.

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorStack foedus::soc::SharedMemoryRepo::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 by calling this method.

Parameters
[in]master_upidUniversal (or Unique) ID of the master process. This is the parameter that has to be passed from the master process to child processes.
[in]master_eidEngine ID of the master process. This is another parameter that has to be passed from the master process to child processes.
[in]my_soc_idSOC ID of this node.
[out]optionsOne of the shared memory contains the EngineOption values. This method also retrieves them from the shared memory.

Definition at line 165 of file shared_memory_repo.cpp.

References ASSERT_ND, foedus::memory::SharedMemory::attach(), change_child_status(), CHECK_ERROR, deallocate_shared_memories(), ERROR_STACK, foedus::memory::SharedMemory::get_block(), foedus::soc::get_master_path(), foedus::memory::SharedMemory::is_null(), foedus::kErrorCodeSocShmAttachFailed, foedus::soc::ChildEngineStatus::kFatalError, foedus::kRetOk, foedus::externalize::Externalizable::load_from_string(), foedus::EngineOptions::memory_, and foedus::memory::MemoryOptions::rigorous_memory_boundary_check_.

Referenced by foedus::soc::SocManagerPimpl::initialize_child().

169  {
171 
172  std::string base = get_master_path(master_upid, master_eid);
173  std::string global_memory_path = base + std::string("_global");
174  const bool global_hugepages = !options->memory_.rigorous_memory_boundary_check_;
175  global_memory_.attach(global_memory_path, global_hugepages);
176  if (global_memory_.is_null()) {
179  }
180 
181  // read the options from global_memory
182  uint64_t xml_size = 0;
183  std::memcpy(&xml_size, global_memory_.get_block(), sizeof(xml_size));
184  ASSERT_ND(xml_size > 0);
185  std::string xml(global_memory_.get_block() + sizeof(xml_size), xml_size);
186  CHECK_ERROR(options->load_from_string(xml));
187 
188  my_soc_id_ = my_soc_id;
189  init_empty(*options);
190  set_global_memory_anchors(xml_size, *options, false);
191 
192  bool failed = false;
193  for (uint16_t node = 0; node < soc_count_; ++node) {
194  std::string node_memory_str = base + std::string("_node_") + std::to_string(node);
195  node_memories_[node].attach(node_memory_str, !options->memory_.rigorous_memory_boundary_check_);
196  if (node_memories_[node].is_null()) {
197  failed = true;
198  } else {
199  set_node_memory_anchors(node, *options, false);
200  }
201  }
202 
203  if (failed) {
204  if (!node_memories_[my_soc_id].is_null()) {
205  // then we can at least notify the error via the shared memory
207  }
210  }
211  return kRetOk;
212 }
0x0C02 : "SOC : Failed to attach a shared memory." .
Definition: error_code.hpp:221
#define ERROR_STACK(e)
Instantiates ErrorStack with the given foedus::error_code, creating an error stack with the current f...
void deallocate_shared_memories()
Detaches and releases the shared memories.
char * get_block() const
Returns the memory block.
std::string get_master_path(uint64_t master_upid, Eid master_eid)
void attach(const std::string &meta_path, bool use_hugepages)
Attach an already-allocated shared memory so that this object points to the memory.
#define CHECK_ERROR(x)
This macro calls x and checks its returned value.
const ErrorStack kRetOk
Normal return value for no-error case.
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'...
Definition: assert_nd.hpp:72
bool is_null() const
Returns if this object doesn't hold a valid memory block.
The child engine observed some unrecoverable error and has exit.

Here is the call graph for this function:

Here is the caller graph for this function:

uint64_t foedus::soc::SharedMemoryRepo::calculate_global_memory_size ( uint64_t  xml_size,
const EngineOptions options 
)
static

Definition at line 365 of file shared_memory_repo.cpp.

References foedus::soc::align_4kb(), foedus::soc::GlobalMemoryAnchors::kLogManagerMemorySize, foedus::soc::GlobalMemoryAnchors::kMasterStatusMemorySize, foedus::soc::GlobalMemoryAnchors::kMetaLoggerSize, foedus::soc::GlobalMemoryAnchors::kRestartManagerMemorySize, foedus::soc::GlobalMemoryAnchors::kSavepointManagerMemorySize, foedus::soc::GlobalMemoryAnchors::kSnapshotManagerMemorySize, foedus::soc::GlobalMemoryAnchors::kStorageManagerMemorySize, foedus::soc::GlobalMemoryAnchors::kStorageMemorySize, foedus::soc::GlobalMemoryAnchors::kXctManagerMemorySize, foedus::storage::StorageOptions::max_storages_, foedus::storage::StorageOptions::partitioner_data_memory_mb_, foedus::soc::SocOptions::shared_user_memory_size_kb_, foedus::EngineOptions::soc_, and foedus::EngineOptions::storage_.

Referenced by allocate_shared_memories(), and foedus::EngineOptions::calculate_required_memory().

367  {
368  const uint64_t kBoundarySize = sizeof(assorted::ProtectedBoundary);
369  uint64_t total = 0;
370  total += align_4kb(sizeof(xml_size) + xml_size) + kBoundarySize; // options_xml_
371  total += GlobalMemoryAnchors::kMasterStatusMemorySize + kBoundarySize;
372  total += GlobalMemoryAnchors::kLogManagerMemorySize + kBoundarySize;
373  total += GlobalMemoryAnchors::kMetaLoggerSize + kBoundarySize;
374  total += GlobalMemoryAnchors::kRestartManagerMemorySize + kBoundarySize;
375  total += GlobalMemoryAnchors::kSavepointManagerMemorySize + kBoundarySize;
376  total += GlobalMemoryAnchors::kSnapshotManagerMemorySize + kBoundarySize;
377  total += GlobalMemoryAnchors::kStorageManagerMemorySize + kBoundarySize;
378  total += GlobalMemoryAnchors::kXctManagerMemorySize + kBoundarySize;
379  total +=
380  align_4kb(sizeof(storage::PartitionerMetadata) * options.storage_.max_storages_)
381  + kBoundarySize;
382  total +=
383  (static_cast<uint64_t>(options.storage_.partitioner_data_memory_mb_) << 20)
384  + kBoundarySize;
385  total +=
386  align_4kb(sizeof(storage::StorageId) * options.storage_.max_storages_)
387  + kBoundarySize;
388  total +=
389  static_cast<uint64_t>(GlobalMemoryAnchors::kStorageMemorySize) * options.storage_.max_storages_
390  + kBoundarySize;
391  total += align_4kb(1024ULL * options.soc_.shared_user_memory_size_kb_) + kBoundarySize;
392  return total;
393 }
uint32_t StorageId
Unique ID for storage.
Definition: storage_id.hpp:55
uint64_t align_4kb(uint64_t value)

Here is the call graph for this function:

Here is the caller graph for this function:

uint64_t foedus::soc::SharedMemoryRepo::calculate_node_memory_size ( const EngineOptions options)
static

Definition at line 505 of file shared_memory_repo.cpp.

References foedus::soc::align_4kb(), foedus::soc::NodeMemoryAnchors::kChildStatusMemorySize, foedus::soc::NodeMemoryAnchors::kLoggerMemorySize, foedus::soc::NodeMemoryAnchors::kLogReducerMemorySize, foedus::soc::ThreadMemoryAnchors::kMcsRwAsyncMappingMemorySize, foedus::soc::ThreadMemoryAnchors::kMcsRwLockMemorySize, foedus::soc::ThreadMemoryAnchors::kMcsWwLockMemorySize, foedus::soc::NodeMemoryAnchors::kPagePoolMemorySize, foedus::soc::NodeMemoryAnchors::kProcManagerMemorySize, foedus::soc::ThreadMemoryAnchors::kTaskInputMemorySize, foedus::soc::ThreadMemoryAnchors::kTaskOutputMemorySize, foedus::soc::ThreadMemoryAnchors::kThreadMemorySize, foedus::EngineOptions::log_, foedus::snapshot::SnapshotOptions::log_reducer_buffer_mb_, foedus::log::LogOptions::loggers_per_node_, foedus::proc::ProcOptions::max_proc_count_, foedus::storage::StorageOptions::max_storages_, foedus::EngineOptions::memory_, foedus::memory::MemoryOptions::page_pool_size_mb_per_node_, foedus::EngineOptions::proc_, foedus::EngineOptions::snapshot_, foedus::EngineOptions::storage_, foedus::EngineOptions::thread_, and foedus::thread::ThreadOptions::thread_count_per_group_.

Referenced by allocate_shared_memories(), and foedus::EngineOptions::calculate_required_memory().

505  {
506  const uint64_t kBoundarySize = sizeof(assorted::ProtectedBoundary);
507  uint64_t total = 0;
508  total += NodeMemoryAnchors::kChildStatusMemorySize + kBoundarySize;
509  total += NodeMemoryAnchors::kPagePoolMemorySize + kBoundarySize;
510  total += NodeMemoryAnchors::kProcManagerMemorySize + kBoundarySize;
511  total += align_4kb(sizeof(proc::ProcAndName) * options.proc_.max_proc_count_) + kBoundarySize;
512  total += align_4kb(sizeof(proc::LocalProcId) * options.proc_.max_proc_count_) + kBoundarySize;
513  total += NodeMemoryAnchors::kLogReducerMemorySize + kBoundarySize;
514  total += options.storage_.max_storages_ * 4096ULL + kBoundarySize;
515 
516  uint64_t loggers_per_node = options.log_.loggers_per_node_;
517  total += loggers_per_node * (NodeMemoryAnchors::kLoggerMemorySize + kBoundarySize);
518 
519  uint64_t threads_per_node = options.thread_.thread_count_per_group_;
520  total += threads_per_node * (ThreadMemoryAnchors::kThreadMemorySize + kBoundarySize);
521  total += threads_per_node * (ThreadMemoryAnchors::kTaskInputMemorySize + kBoundarySize);
522  total += threads_per_node * (ThreadMemoryAnchors::kTaskOutputMemorySize + kBoundarySize);
523  total += threads_per_node * (ThreadMemoryAnchors::kMcsWwLockMemorySize + kBoundarySize);
524  total += threads_per_node * (ThreadMemoryAnchors::kMcsRwLockMemorySize + kBoundarySize);
525  total += threads_per_node * (ThreadMemoryAnchors::kMcsRwLockMemorySize + kBoundarySize);
526  total += threads_per_node * (ThreadMemoryAnchors::kMcsRwAsyncMappingMemorySize + kBoundarySize);
527 
528  total +=
529  (static_cast<uint64_t>(options.snapshot_.log_reducer_buffer_mb_) << 20)
530  + kBoundarySize;
531 
532  // Then volatile pool at the end.
533  total +=
534  (static_cast<uint64_t>(options.memory_.page_pool_size_mb_per_node_) << 20)
535  + kBoundarySize;
536  return total;
537 }
uint64_t align_4kb(uint64_t value)
std::pair< ProcName, Proc > ProcAndName
Just a std::pair.
Definition: proc_id.hpp:119
uint32_t LocalProcId
Represents a locally-unique ID of a procedure in one SOC.
Definition: proc_id.hpp:56

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::soc::SharedMemoryRepo::change_child_status ( SocId  node,
ChildEngineStatus::StatusCode  new_status 
)

Definition at line 547 of file shared_memory_repo.cpp.

References foedus::soc::ChildEngineStatus::change_status_atomic(), and foedus::soc::NodeMemoryAnchors::child_status_memory_.

Referenced by attach_shared_memories(), foedus::soc::SocManagerPimpl::child_main_common(), and foedus::soc::SocManagerPimpl::initialize_child().

547  {
548  node_memory_anchors_[node].child_status_memory_->change_status_atomic(new_status);
549 }
void change_status_atomic(StatusCode new_status)
Update the value of status_code_ with fence.
ChildEngineStatus * child_status_memory_
This tiny piece of memory contains the current status of the child engine on this node...

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::soc::SharedMemoryRepo::change_master_status ( MasterEngineStatus::StatusCode  new_status)

Definition at line 539 of file shared_memory_repo.cpp.

References foedus::soc::MasterEngineStatus::change_status_atomic(), and foedus::soc::GlobalMemoryAnchors::master_status_memory_.

Referenced by foedus::EnginePimpl::initialize_once(), foedus::soc::SocManagerPimpl::launch_forked_children(), foedus::soc::SocManagerPimpl::launch_spawned_children(), foedus::soc::SocManagerPimpl::uninitialize_once(), foedus::EnginePimpl::uninitialize_once(), foedus::soc::SocManagerPimpl::wait_for_child_attach(), and foedus::soc::SocManagerPimpl::wait_for_child_terminate().

539  {
540  global_memory_anchors_.master_status_memory_->change_status_atomic(new_status);
541 }
void change_status_atomic(StatusCode new_status)
Update the value of status_code_ with fence.
MasterEngineStatus * master_status_memory_
This tiny piece of memory contains the current status of the master engine and its synchronization me...

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::soc::SharedMemoryRepo::deallocate_shared_memories ( )

Detaches and releases the shared memories.

In child processes, this just detaches.

Definition at line 223 of file shared_memory_repo.cpp.

References foedus::assorted::ProtectedBoundary::assert_boundary(), foedus::soc::GlobalMemoryAnchors::clear(), foedus::memory::SharedMemory::is_null(), mark_for_release(), foedus::soc::GlobalMemoryAnchors::protected_boundaries_, foedus::soc::NodeMemoryAnchors::protected_boundaries_, foedus::soc::GlobalMemoryAnchors::protected_boundaries_count_, foedus::soc::NodeMemoryAnchors::protected_boundaries_count_, foedus::soc::GlobalMemoryAnchors::protected_boundaries_needs_release_, foedus::memory::SharedMemory::release_block(), and foedus::assorted::ProtectedBoundary::release_protect().

Referenced by allocate_shared_memories(), attach_shared_memories(), foedus::soc::SocManagerPimpl::initialize_master(), foedus::soc::SocManagerPimpl::launch_forked_children(), foedus::soc::SocManagerPimpl::launch_spawned_children(), foedus::soc::SocManagerPimpl::uninitialize_once(), foedus::soc::SocManagerPimpl::wait_for_child_attach(), and ~SharedMemoryRepo().

223  {
225 
226  if (!global_memory_.is_null()) {
227  if (global_memory_anchors_.protected_boundaries_needs_release_) {
228  for (uint32_t i = 0; i < global_memory_anchors_.protected_boundaries_count_; ++i) {
229  assorted::ProtectedBoundary* boundary = global_memory_anchors_.protected_boundaries_[i];
230  boundary->release_protect();
231  boundary->assert_boundary();
232  }
233  }
234  }
235  global_memory_anchors_.clear();
236 
237  // release_block() is idempotent, so just do it on all of them
238  global_memory_.release_block();
239 
240  for (uint16_t i = 0; i < soc_count_; ++i) {
241  if (node_memories_) {
242  if (node_memory_anchors_[i].protected_boundaries_needs_release_) {
243  for (uint32_t j = 0; j < node_memory_anchors_[i].protected_boundaries_count_; ++j) {
244  assorted::ProtectedBoundary* boundary = node_memory_anchors_[i].protected_boundaries_[j];
245  boundary->release_protect();
246  boundary->assert_boundary();
247  }
248  }
249 
250  node_memories_[i].release_block();
251  }
252  }
253 
254  if (node_memories_) {
255  delete[] node_memories_;
256  node_memories_ = nullptr;
257  }
258  if (node_memory_anchors_) {
259  delete[] node_memory_anchors_;
260  node_memory_anchors_ = nullptr;
261  }
262  soc_count_ = 0;
263 }
uint32_t protected_boundaries_count_
To be a POD, we avoid vector and instead uses a fix-sized array.
void mark_for_release()
Marks shared memories as being removed so that it will be reclaimed when all processes detach it...
uint32_t protected_boundaries_count_
To be a POD, we avoid vector and instead uses a fix-sized array.
assorted::ProtectedBoundary * protected_boundaries_[kMaxBoundaries]
sanity check boundaries to detect bogus memory accesses that overrun a memory region ...
ErrorCode release_protect()
Removes all access restrictions via mprotect().
bool is_null() const
Returns if this object doesn't hold a valid memory block.
bool protected_boundaries_needs_release_
whether we have invoked mprotect on them
assorted::ProtectedBoundary * protected_boundaries_[kMaxBoundaries]
sanity check boundaries to detect bogus memory accesses that overrun a memory region ...
void release_block()
Releases the memory block IF this process has an ownership.

Here is the call graph for this function:

Here is the caller graph for this function:

ChildEngineStatus::StatusCode foedus::soc::SharedMemoryRepo::get_child_status ( SocId  node) const

Definition at line 551 of file shared_memory_repo.cpp.

References foedus::soc::NodeMemoryAnchors::child_status_memory_, and foedus::soc::ChildEngineStatus::read_status_atomic().

Referenced by foedus::soc::SocManagerPimpl::wait_for_child_attach(), and foedus::soc::SocManagerPimpl::wait_for_child_terminate().

551  {
552  return node_memory_anchors_[node].child_status_memory_->read_status_atomic();
553 }
ChildEngineStatus * child_status_memory_
This tiny piece of memory contains the current status of the child engine on this node...
StatusCode read_status_atomic() const
Read status_code_ with fence.

Here is the call graph for this function:

Here is the caller graph for this function:

void* foedus::soc::SharedMemoryRepo::get_global_memory ( )
inline

Definition at line 513 of file shared_memory_repo.hpp.

References foedus::memory::SharedMemory::get_block().

Referenced by foedus::soc::SocManagerPimpl::uninitialize_once().

513 { return global_memory_.get_block(); }
char * get_block() const
Returns the memory block.

Here is the call graph for this function:

Here is the caller graph for this function:

void* foedus::soc::SharedMemoryRepo::get_global_user_memory ( )
inline

Definition at line 515 of file shared_memory_repo.hpp.

References foedus::soc::GlobalMemoryAnchors::user_memory_.

Referenced by foedus::soc::SocManager::get_shared_user_memory().

515 { return global_memory_anchors_.user_memory_; }
void * user_memory_
This 'user memory' can be used for arbitrary purporses by the user to communicate between SOCs...

Here is the caller graph for this function:

MasterEngineStatus::StatusCode foedus::soc::SharedMemoryRepo::get_master_status ( ) const

Definition at line 543 of file shared_memory_repo.cpp.

References foedus::soc::GlobalMemoryAnchors::master_status_memory_, and foedus::soc::MasterEngineStatus::read_status_atomic().

Referenced by foedus::soc::SocManagerPimpl::wait_for_master_status().

543  {
544  return global_memory_anchors_.master_status_memory_->read_status_atomic();
545 }
StatusCode read_status_atomic() const
Read status_code_ with fence.
MasterEngineStatus * master_status_memory_
This tiny piece of memory contains the current status of the master engine and its synchronization me...

Here is the call graph for this function:

Here is the caller graph for this function:

void* foedus::soc::SharedMemoryRepo::get_node_memory ( SocId  node)
inline

Definition at line 520 of file shared_memory_repo.hpp.

References foedus::memory::SharedMemory::get_block().

520 { return node_memories_[node].get_block(); }
char * get_block() const
Returns the memory block.

Here is the call graph for this function:

ThreadMemoryAnchors* foedus::soc::SharedMemoryRepo::get_thread_memory_anchors ( thread::ThreadId  thread_id)
inline

Definition at line 526 of file shared_memory_repo.hpp.

References foedus::thread::decompose_numa_local_ordinal(), foedus::thread::decompose_numa_node(), and foedus::soc::NodeMemoryAnchors::thread_anchors_.

Referenced by foedus::thread::ThreadPimpl::initialize_once(), and foedus::thread::ThreadRef::ThreadRef().

526  {
527  SocId node = thread::decompose_numa_node(thread_id);
528  uint16_t thread_ordinal = thread::decompose_numa_local_ordinal(thread_id);
529  return &node_memory_anchors_[node].thread_anchors_[thread_ordinal];
530  }
ThreadLocalOrdinal decompose_numa_local_ordinal(ThreadId global_id)
Extracts local ordinal from the given globally unique ID of Thread (core).
Definition: thread_id.hpp:139
ThreadGroupId decompose_numa_node(ThreadId global_id)
Extracts NUMA node ID from the given globally unique ID of Thread (core).
Definition: thread_id.hpp:131
uint16_t SocId
Represents an ID of an SOC, or NUMA node.
Definition: soc_id.hpp:41
ThreadMemoryAnchors * thread_anchors_
Anchors for each thread.

Here is the call graph for this function:

Here is the caller graph for this function:

void* foedus::soc::SharedMemoryRepo::get_volatile_pool ( SocId  node)
inline

Definition at line 532 of file shared_memory_repo.hpp.

References foedus::soc::NodeMemoryAnchors::volatile_page_pool_.

Referenced by foedus::memory::NumaNodeMemory::initialize_once(), and foedus::memory::NumaNodeMemoryRef::NumaNodeMemoryRef().

532 { return node_memory_anchors_[node].volatile_page_pool_; }
void * volatile_page_pool_
By far the largest memory for volatile page pool on this node.

Here is the caller graph for this function:

void foedus::soc::SharedMemoryRepo::mark_for_release ( )

Marks shared memories as being removed so that it will be reclaimed when all processes detach it.

This is part of deallocation of shared memory in master process. After calling this method, no process can attach this shared memory. So, do not call this too early. However, on the other hand, do not call this too late. If the master process dies for an unexpected reason, the shared memory remains until next reboot. Call it as soon as child processes ack-ed that they have attached the memory or that there are some issues the master process should exit. This method is idempotent, meaning you can safely call this many times.

Definition at line 214 of file shared_memory_repo.cpp.

References foedus::memory::SharedMemory::mark_for_release().

Referenced by deallocate_shared_memories(), and foedus::soc::SocManagerPimpl::wait_for_child_attach().

214  {
215  // mark_for_release() is idempotent, so just do it on all of them
216  global_memory_.mark_for_release();
217  for (uint16_t i = 0; i < soc_count_; ++i) {
218  if (node_memories_) {
219  node_memories_[i].mark_for_release();
220  }
221  }
222 }
void mark_for_release()
Marks the shared memory as being removed so that it will be reclaimed when all processes detach it...

Here is the call graph for this function:

Here is the caller graph for this function:

SharedMemoryRepo& foedus::soc::SharedMemoryRepo::operator= ( const SharedMemoryRepo other)
delete

The documentation for this class was generated from the following files: