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