1 /* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
11 #include "xbt/asserts.h"
14 #include "src/mc/AddressSpace.hpp"
15 #include "src/mc/ChunkedData.hpp"
16 #include "src/mc/PageStore.hpp"
21 /** Take a per-page snapshot of a region
23 * @param addr The start of the region (must be at the beginning of a page)
24 * @param page_count Number of pages of the region
25 * @return Snapshot page numbers of this new snapshot
27 ChunkedData::ChunkedData(PageStore& store, AddressSpace& as,
28 RemotePtr<void> addr, std::size_t page_count)
31 this->pagenos_.resize(page_count);
32 std::vector<char> buffer(xbt_pagesize);
34 for (size_t i = 0; i != page_count; ++i) {
36 RemotePtr<void> page = remote((void*)
37 simgrid::mc::mmu::join(i, addr.address()));
38 xbt_assert(simgrid::mc::mmu::split(page.address()).second == 0,
39 "Not at the beginning of a page");
41 /* Adding another copy (and a syscall) will probably slow things a lot.
42 TODO, optimize this somehow (at least by grouping the syscalls)
44 - reduce the number of syscalls;
45 - let the application snapshot itself;
46 - move the segments in shared memory (this will break `fork` however).
50 buffer.data(), xbt_pagesize, page,
51 simgrid::mc::ProcessIndexDisabled);
53 pagenos_[i] = store_->store_page(buffer.data());