Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MC::Region: Also remove the permanent_addr thingy
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 31 May 2019 10:36:16 +0000 (12:36 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 31 May 2019 12:31:37 +0000 (14:31 +0200)
That was needed for the MMAP privatization of SMPI, which is gone.

src/mc/sosp/RegionSnapshot.cpp
src/mc/sosp/RegionSnapshot.hpp
src/mc/sosp/mc_snapshot.cpp
src/mc/sosp/mc_snapshot.hpp
src/mc/sosp/mc_snapshot_test.cpp

index f9d07da..006ff2b 100644 (file)
@@ -22,17 +22,14 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_RegionSnaphot, mc, "Logging specific to regio
 namespace simgrid {
 namespace mc {
 
-RegionSnapshot::RegionSnapshot(RegionType region_type, void* start_addr, void* permanent_addr, size_t size)
-    : region_type_(region_type), start_addr_(start_addr), size_(size), permanent_addr_(permanent_addr)
+RegionSnapshot::RegionSnapshot(RegionType region_type, void* start_addr, size_t size)
+    : region_type_(region_type), start_addr_(start_addr), size_(size)
 {
   simgrid::mc::RemoteClient* process = &mc_model_checker->process();
 
   xbt_assert((((uintptr_t)start_addr) & (xbt_pagesize - 1)) == 0, "Start address not at the beginning of a page");
-  xbt_assert((((uintptr_t)permanent_addr) & (xbt_pagesize - 1)) == 0,
-             "Permanent address not at the beginning of a page");
 
-  chunks_ =
-      ChunkedData(mc_model_checker->page_store(), *process, RemotePtr<void>(permanent_addr), mmu::chunk_count(size));
+  chunks_ = ChunkedData(mc_model_checker->page_store(), *process, RemotePtr<void>(start_addr), mmu::chunk_count(size));
 }
 
 /** @brief Restore a region from a snapshot
@@ -41,13 +38,13 @@ RegionSnapshot::RegionSnapshot(RegionType region_type, void* start_addr, void* p
  */
 void RegionSnapshot::restore()
 {
-      xbt_assert(((permanent_address().address()) & (xbt_pagesize - 1)) == 0, "Not at the beginning of a page");
-      xbt_assert(simgrid::mc::mmu::chunk_count(size()) == chunks().page_count());
+  xbt_assert(((start().address()) & (xbt_pagesize - 1)) == 0, "Not at the beginning of a page");
+  xbt_assert(simgrid::mc::mmu::chunk_count(size()) == get_chunks().page_count());
 
-      for (size_t i = 0; i != chunks().page_count(); ++i) {
-        void* target_page = (void*)simgrid::mc::mmu::join(i, (std::uintptr_t)(void*)permanent_address().address());
-        const void* source_page = chunks().page(i);
-        mc_model_checker->process().write_bytes(source_page, xbt_pagesize, remote(target_page));
+  for (size_t i = 0; i != get_chunks().page_count(); ++i) {
+    void* target_page       = (void*)simgrid::mc::mmu::join(i, (std::uintptr_t)(void*)start().address());
+    const void* source_page = get_chunks().page(i);
+    mc_model_checker->process().write_bytes(source_page, xbt_pagesize, remote(target_page));
       }
 }
 
index edcc51c..4fd5287 100644 (file)
@@ -34,21 +34,10 @@ protected:
   /** @brief Size of the data region in bytes */
   std::size_t size_ = 0;
 
-  /** @brief Permanent virtual address of the region
-   *
-   * This is usually the same address as the simuilated process address.
-   * However, when using SMPI privatization of global variables,
-   * each SMPI process has its own set of global variables stored
-   * at a different virtual address. The scheduler maps those region
-   * on the region of the global variables.
-   *
-   * */
-  void* permanent_addr_ = nullptr;
-
   ChunkedData chunks_;
 
 public:
-  RegionSnapshot(RegionType type, void* start_addr, void* permanent_addr, size_t size);
+  RegionSnapshot(RegionType type, void* start_addr, size_t size);
   ~RegionSnapshot()                     = default;
   RegionSnapshot(RegionSnapshot const&) = delete;
   RegionSnapshot& operator=(RegionSnapshot const&) = delete;
@@ -57,7 +46,6 @@ public:
       , object_info_(that.object_info_)
       , start_addr_(that.start_addr_)
       , size_(that.size_)
-      , permanent_addr_(that.permanent_addr_)
       , chunks_(std::move(that.chunks_))
   {
     that.clear();
@@ -68,7 +56,6 @@ public:
     object_info_        = that.object_info_;
     start_addr_         = that.start_addr_;
     size_               = that.size_;
-    permanent_addr_     = that.permanent_addr_;
     chunks_             = std::move(that.chunks_);
     that.clear();
     return *this;
@@ -83,10 +70,9 @@ public:
     object_info_    = nullptr;
     start_addr_     = nullptr;
     size_           = 0;
-    permanent_addr_ = nullptr;
   }
 
-  ChunkedData const& chunks() const { return chunks_; }
+  ChunkedData const& get_chunks() const { return chunks_; }
 
   simgrid::mc::ObjectInformation* object_info() const { return object_info_; }
   void object_info(simgrid::mc::ObjectInformation* info) { object_info_ = info; }
@@ -95,7 +81,6 @@ public:
 
   RemotePtr<void> start() const { return remote(start_addr_); }
   RemotePtr<void> end() const { return remote((char*)start_addr_ + size_); }
-  RemotePtr<void> permanent_address() const { return remote(permanent_addr_); }
   std::size_t size() const { return size_; }
   RegionType region_type() const { return region_type_; }
 
index 50275e2..97341f6 100644 (file)
@@ -94,14 +94,14 @@ void simgrid::mc::Snapshot::snapshot_regions(simgrid::mc::RemoteClient* process)
   snapshot_regions_.clear();
 
   for (auto const& object_info : process->object_infos)
-    add_region(simgrid::mc::RegionType::Data, object_info.get(), object_info->start_rw, object_info->start_rw,
+    add_region(simgrid::mc::RegionType::Data, object_info.get(), object_info->start_rw,
                object_info->end_rw - object_info->start_rw);
 
   xbt_mheap_t heap = process->get_heap();
   void* start_heap = heap->base;
   void* end_heap   = heap->breakval;
 
-  add_region(simgrid::mc::RegionType::Heap, nullptr, start_heap, start_heap, (char*)end_heap - (char*)start_heap);
+  add_region(simgrid::mc::RegionType::Heap, nullptr, start_heap, (char*)end_heap - (char*)start_heap);
   heap_bytes_used_     = mmalloc_get_bytes_used_remote(heap->heaplimit, process->get_malloc_info());
 }
 
@@ -299,15 +299,14 @@ Snapshot::Snapshot(int _num_state, RemoteClient* process)
   snapshot_ignore_restore(this);
 }
 
-void Snapshot::add_region(RegionType type, ObjectInformation* object_info, void* start_addr, void* permanent_addr,
-                          std::size_t size)
+void Snapshot::add_region(RegionType type, ObjectInformation* object_info, void* start_addr, std::size_t size)
 {
   if (type == simgrid::mc::RegionType::Data)
     xbt_assert(object_info, "Missing object info for object.");
   else if (type == simgrid::mc::RegionType::Heap)
     xbt_assert(not object_info, "Unexpected object info for heap region.");
 
-  simgrid::mc::RegionSnapshot* region = new RegionSnapshot(type, start_addr, permanent_addr, size);
+  simgrid::mc::RegionSnapshot* region = new RegionSnapshot(type, start_addr, size);
   region->object_info(object_info);
   snapshot_regions_.push_back(std::unique_ptr<simgrid::mc::RegionSnapshot>(std::move(region)));
 }
index 5bc51ad..11496c2 100644 (file)
@@ -18,7 +18,7 @@ static XBT_ALWAYS_INLINE void* mc_translate_address_region(uintptr_t addr, simgr
   auto split                = simgrid::mc::mmu::split(addr - region->start().address());
   auto pageno               = split.first;
   auto offset               = split.second;
-  const void* snapshot_page = region->chunks().page(pageno);
+  const void* snapshot_page = region->get_chunks().page(pageno);
   return (char*)snapshot_page + offset;
 }
 
@@ -92,8 +92,7 @@ public:
   std::vector<s_mc_snapshot_ignored_data_t> ignored_data_;
 
 private:
-  void add_region(RegionType type, ObjectInformation* object_info, void* start_addr, void* permanent_addr,
-                  std::size_t size);
+  void add_region(RegionType type, ObjectInformation* object_info, void* start_addr, std::size_t size);
   void snapshot_regions(simgrid::mc::RemoteClient* process);
   void snapshot_stacks(simgrid::mc::RemoteClient* process);
 };
index 8357f62..87dbca3 100644 (file)
@@ -74,12 +74,12 @@ snap_test_helper::prologue_return snap_test_helper::prologue(int n)
   // Init memory and take snapshots:
   init_memory(source, byte_size);
   simgrid::mc::RegionSnapshot* region0 =
-      new simgrid::mc::RegionSnapshot(simgrid::mc::RegionType::Unknown, source, source, byte_size);
+      new simgrid::mc::RegionSnapshot(simgrid::mc::RegionType::Unknown, source, byte_size);
   for (int i = 0; i < n; i += 2) {
     init_memory((char*)source + i * xbt_pagesize, xbt_pagesize);
   }
   simgrid::mc::RegionSnapshot* region =
-      new simgrid::mc::RegionSnapshot(simgrid::mc::RegionType::Unknown, source, source, byte_size);
+      new simgrid::mc::RegionSnapshot(simgrid::mc::RegionType::Unknown, source, byte_size);
 
   void* destination = mmap(nullptr, byte_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
   INFO("Could not allocate destination memory");
@@ -171,7 +171,7 @@ void snap_test_helper::read_pointer()
   prologue_return ret = prologue(1);
   memcpy(ret.src, &mc_model_checker, sizeof(void*));
   simgrid::mc::RegionSnapshot* region2 =
-      new simgrid::mc::RegionSnapshot(simgrid::mc::RegionType::Unknown, ret.src, ret.src, ret.size);
+      new simgrid::mc::RegionSnapshot(simgrid::mc::RegionType::Unknown, ret.src, ret.size);
   INFO("Mismtach in MC_region_read_pointer()");
   REQUIRE(MC_region_read_pointer(region2, ret.src) == mc_model_checker);