X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/026942606020b281e430912ea77340fc2a13bf5f..a75f0026f40bb64ebf43eecd6010406e5b7bcad1:/src/mc/sosp/mc_snapshot.cpp diff --git a/src/mc/sosp/mc_snapshot.cpp b/src/mc/sosp/mc_snapshot.cpp index c7296a6778..fbe1a4297d 100644 --- a/src/mc/sosp/mc_snapshot.cpp +++ b/src/mc/sosp/mc_snapshot.cpp @@ -38,7 +38,7 @@ const void* MC_region_read_fragmented(simgrid::mc::RegionSnapshot* region, void* // Read each page: while (simgrid::mc::mmu::split((std::uintptr_t)addr).first != page_end) { - void* snapshot_addr = mc_translate_address_region_chunked((uintptr_t)addr, region); + void* snapshot_addr = mc_translate_address_region((uintptr_t)addr, region); void* next_page = (void*)simgrid::mc::mmu::join(simgrid::mc::mmu::split((std::uintptr_t)addr).first + 1, 0); size_t readable = (char*)next_page - (char*)addr; memcpy(dest, snapshot_addr, readable); @@ -48,7 +48,7 @@ const void* MC_region_read_fragmented(simgrid::mc::RegionSnapshot* region, void* } // Read the end: - void* snapshot_addr = mc_translate_address_region_chunked((uintptr_t)addr, region); + void* snapshot_addr = mc_translate_address_region((uintptr_t)addr, region); memcpy(dest, snapshot_addr, size); return target; @@ -68,12 +68,8 @@ int MC_snapshot_region_memcmp(const void* addr1, simgrid::mc::RegionSnapshot* re // Using alloca() for large allocations may trigger stack overflow: // use malloc if the buffer is too big. bool stack_alloc = size < 64; - void* buffer1a = nullptr; - void* buffer2a = nullptr; - if (region1 != nullptr && region1->storage_type() != simgrid::mc::StorageType::Flat) - buffer1a = stack_alloc ? alloca(size) : ::operator new(size); - if (region2 != nullptr && region2->storage_type() != simgrid::mc::StorageType::Flat) - buffer2a = stack_alloc ? alloca(size) : ::operator new(size); + void* buffer1a = stack_alloc ? alloca(size) : ::operator new(size); + void* buffer2a = stack_alloc ? alloca(size) : ::operator new(size); const void* buffer1 = MC_region_read(region1, buffer1a, addr1, size); const void* buffer2 = MC_region_read(region2, buffer2a, addr2, size); int res; @@ -107,13 +103,6 @@ void simgrid::mc::Snapshot::snapshot_regions(simgrid::mc::RemoteClient* process) add_region(simgrid::mc::RegionType::Heap, nullptr, start_heap, start_heap, (char*)end_heap - (char*)start_heap); heap_bytes_used_ = mmalloc_get_bytes_used_remote(heap->heaplimit, process->get_malloc_info()); - privatization_index_ = simgrid::mc::ProcessIndexMissing; - -#if HAVE_SMPI - if (mc_model_checker->process().privatized() && MC_smpi_process_count()) - // snapshot->privatization_index = smpi_loaded_page - mc_model_checker->process().read_variable("smpi_loaded_page", &privatization_index_, sizeof(privatization_index_)); -#endif } /** @brief Checks whether the variable is in scope for a given IP. @@ -134,7 +123,7 @@ static bool valid_variable(simgrid::mc::Variable* var, simgrid::mc::Frame* scope return true; } -static void fill_local_variables_values(mc_stack_frame_t stack_frame, simgrid::mc::Frame* scope, int process_index, +static void fill_local_variables_values(mc_stack_frame_t stack_frame, simgrid::mc::Frame* scope, std::vector& result) { if (not scope || not scope->range.contain(stack_frame->ip)) @@ -157,7 +146,7 @@ static void fill_local_variables_values(mc_stack_frame_t stack_frame, simgrid::m else if (not current_variable.location_list.empty()) { simgrid::dwarf::Location location = simgrid::dwarf::resolve( current_variable.location_list, current_variable.object_info, &(stack_frame->unw_cursor), - (void*)stack_frame->frame_base, &mc_model_checker->process(), process_index); + (void*)stack_frame->frame_base, &mc_model_checker->process()); if (not location.in_memory()) xbt_die("Cannot handle non-address variable"); @@ -171,15 +160,14 @@ static void fill_local_variables_values(mc_stack_frame_t stack_frame, simgrid::m // Recursive processing of nested scopes: for (simgrid::mc::Frame& nested_scope : scope->scopes) - fill_local_variables_values(stack_frame, &nested_scope, process_index, result); + fill_local_variables_values(stack_frame, &nested_scope, result); } -static std::vector get_local_variables_values(std::vector& stack_frames, - int process_index) +static std::vector get_local_variables_values(std::vector& stack_frames) { std::vector variables; for (s_mc_stack_frame_t& stack_frame : stack_frames) - fill_local_variables_values(&stack_frame, stack_frame.frame, process_index, variables); + fill_local_variables_values(&stack_frame, stack_frame.frame, variables); return variables; } @@ -245,13 +233,12 @@ void simgrid::mc::Snapshot::snapshot_stacks(simgrid::mc::RemoteClient* process) // Read the context from remote process: unw_context_t context; - mc_model_checker->process().read_bytes(&context, sizeof(context), remote(stack.context)); + process->read_bytes(&context, sizeof(context), remote(stack.context)); - st.context.initialize(&mc_model_checker->process(), &context); + st.context.initialize(process, &context); st.stack_frames = unwind_stack_frames(&st.context); - st.local_variables = get_local_variables_values(st.stack_frames, stack.process_index); - st.process_index = stack.process_index; + st.local_variables = get_local_variables_values(st.stack_frames); unw_word_t sp = st.stack_frames[0].sp; @@ -267,18 +254,17 @@ static void snapshot_handle_ignore(simgrid::mc::Snapshot* snapshot) xbt_assert(snapshot->process()); // Copy the memory: - for (auto const& region : mc_model_checker->process().ignored_regions()) { + for (auto const& region : snapshot->process()->ignored_regions()) { s_mc_snapshot_ignored_data_t ignored_data; ignored_data.start = (void*)region.addr; ignored_data.data.resize(region.size); // TODO, we should do this once per privatization segment: - snapshot->process()->read_bytes(ignored_data.data.data(), region.size, remote(region.addr), - simgrid::mc::ProcessIndexDisabled); + snapshot->process()->read_bytes(ignored_data.data.data(), region.size, remote(region.addr)); snapshot->ignored_data_.push_back(std::move(ignored_data)); } // Zero the memory: - for (auto const& region : mc_model_checker->process().ignored_regions()) + for (auto const& region : snapshot->process()->ignored_regions()) snapshot->process()->clear_bytes(remote(region.addr), region.size); } static void snapshot_ignore_restore(simgrid::mc::Snapshot* snapshot) @@ -292,11 +278,10 @@ Snapshot::Snapshot(int _num_state, RemoteClient* process) , num_state_(_num_state) , heap_bytes_used_(0) , enabled_processes_() - , privatization_index_(0) , hash_(0) { for (auto const& p : process->actors()) - enabled_processes_.insert(p.copy.getBuffer()->get_pid()); + enabled_processes_.insert(p.copy.get_buffer()->get_pid()); snapshot_handle_ignore(this); @@ -322,23 +307,14 @@ void Snapshot::add_region(RegionType type, ObjectInformation* object_info, void* else if (type == simgrid::mc::RegionType::Heap) xbt_assert(not object_info, "Unexpected object info for heap region."); - simgrid::mc::RegionSnapshot* region; -#if HAVE_SMPI - const bool privatization_aware = object_info && mc_model_checker->process().privatized(*object_info); - if (privatization_aware && MC_smpi_process_count()) - region = new RegionPrivatized(type, start_addr, permanent_addr, size); - else -#endif - region = simgrid::mc::region(type, start_addr, permanent_addr, size); - + simgrid::mc::RegionSnapshot* region = simgrid::mc::region(type, start_addr, permanent_addr, size); region->object_info(object_info); snapshot_regions_.push_back(std::unique_ptr(std::move(region))); } -const void* Snapshot::read_bytes(void* buffer, std::size_t size, RemotePtr address, int process_index, - ReadOptions options) const +const void* Snapshot::read_bytes(void* buffer, std::size_t size, RemotePtr address, ReadOptions options) const { - RegionSnapshot* region = this->get_region((void*)address.address(), process_index); + RegionSnapshot* region = this->get_region((void*)address.address()); if (region) { const void* res = MC_region_read(region, buffer, (void*)address.address(), size); if (buffer == res || options & ReadOptions::lazy()) @@ -348,14 +324,13 @@ const void* Snapshot::read_bytes(void* buffer, std::size_t size, RemotePtr return buffer; } } else - return this->process()->read_bytes(buffer, size, address, process_index, options); + return this->process()->read_bytes(buffer, size, address, options); } /** @brief Find the snapshoted region from a pointer * * @param addr Pointer - * @param process_index rank requesting the region * */ -RegionSnapshot* Snapshot::get_region(const void* addr, int process_index) const +RegionSnapshot* Snapshot::get_region(const void* addr) const { size_t n = snapshot_regions_.size(); for (size_t i = 0; i != n; ++i) { @@ -363,22 +338,6 @@ RegionSnapshot* Snapshot::get_region(const void* addr, int process_index) const if (not(region && region->contain(simgrid::mc::remote(addr)))) continue; - if (region->storage_type() == simgrid::mc::StorageType::Privatized) { -#if HAVE_SMPI - // Use the current process index of the snapshot: - if (process_index == simgrid::mc::ProcessIndexDisabled) - process_index = privatization_index_; - xbt_assert(process_index >= 0, "Missing process index"); - xbt_assert(process_index < (int)region->privatized_data().size(), "Invalid process index"); - - RegionSnapshot* priv_region = region->privatized_data()[process_index].get(); - xbt_assert(priv_region->contain(simgrid::mc::remote(addr))); - return priv_region; -#else - xbt_die("Privatized region in a non SMPI build (this should not happen)"); -#endif - } - return region; } @@ -386,12 +345,12 @@ RegionSnapshot* Snapshot::get_region(const void* addr, int process_index) const } /** @brief Find the snapshoted region from a pointer, with a hinted_region */ -RegionSnapshot* Snapshot::get_region(const void* addr, int process_index, RegionSnapshot* hinted_region) const +RegionSnapshot* Snapshot::get_region(const void* addr, RegionSnapshot* hinted_region) const { if (hinted_region->contain(simgrid::mc::remote(addr))) return hinted_region; else - return get_region(addr, process_index); + return get_region(addr); } void Snapshot::restore(RemoteClient* process) @@ -404,12 +363,6 @@ void Snapshot::restore(RemoteClient* process) region.get()->restore(); } - // Fix the privatization mmap if needed - if (privatization_index_ >= 0) { - s_mc_message_restore_t message{MC_MESSAGE_RESTORE, privatization_index_}; - process->getChannel().send(message); - } - snapshot_ignore_restore(this); process->clear_cache(); }