X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f99825c9a9bf0ab802f611630da8cb18d3b90f23..d2cfdb071826e6a57a2601a401444531689de1ad:/src/mc/mc_process.cpp diff --git a/src/mc/mc_process.cpp b/src/mc/mc_process.cpp index 1cc3a38ed7..2a70cb52c9 100644 --- a/src/mc/mc_process.cpp +++ b/src/mc/mc_process.cpp @@ -71,6 +71,7 @@ static const char *const FILTERED_LIBS[] = { "libm", "libpthread", "librt", + "libsigc", "libstdc++", "libunwind", "libunwind-x86_64", @@ -130,6 +131,7 @@ static ssize_t pread_whole(int fd, void *buf, size_t count, std::uint64_t offset } else if (res==0) { return -1; } else if (errno != EINTR) { + perror("pread_whole"); return -1; } } @@ -170,6 +172,14 @@ static void MC_zero_buffer_init(void) close(fd); } +static +int open_process_file(pid_t pid, const char* file, int flags) +{ + char buff[50]; + snprintf(buff, sizeof(buff), "/proc/%li/%s", (long) pid, file); + return open(buff, flags); +} + } namespace simgrid { @@ -212,6 +222,8 @@ Process::Process(pid_t pid, int sockfd) process->heap = NULL; process->heap_info = NULL; process->init_memory_map_info(); + process->clear_refs_fd_ = -1; + process->pagemap_fd_ = -1; // Open the memory file if (process->is_self()) @@ -283,6 +295,11 @@ Process::~Process() free(process->heap_info); process->heap_info = NULL; + + if (process->clear_refs_fd_ >= 0) + close(process->clear_refs_fd_); + if (process->pagemap_fd_ >= 0) + close(process->pagemap_fd_); } /** Refresh the information about the process @@ -524,6 +541,7 @@ const void *Process::read_bytes(void* buffer, std::size_t size, std::shared_ptr const& info = this->find_object_info_rw((void*)address.address()); // Segment overlap is not handled. +#ifdef HAVE_SMPI if (info.get() && info.get()->privatized()) { if (process_index < 0) xbt_die("Missing process index"); @@ -543,6 +561,7 @@ const void *Process::read_bytes(void* buffer, std::size_t size, size_t offset = address.address() - (std::uint64_t)info->start_rw; address = remote((char*)privatisation_region.address + offset); } +#endif } if (this->is_self()) { @@ -639,5 +658,29 @@ void Process::ignore_region(std::uint64_t addr, std::size_t size) ignored_regions_.begin() + position, region); } +void Process::reset_soft_dirty() +{ + if (this->clear_refs_fd_ < 0) { + this->clear_refs_fd_ = open_process_file(pid_, "clear_refs", O_WRONLY|O_CLOEXEC); + if (this->clear_refs_fd_ < 0) + xbt_die("Could not open clear_refs file for soft-dirty tracking. Run as root?"); + } + if(::write(this->clear_refs_fd_, "4\n", 2) != 2) + xbt_die("Could not reset softdirty bits"); +} + +void Process::read_pagemap(uint64_t* pagemap, size_t page_start, size_t page_count) +{ + if (pagemap_fd_ < 0) { + pagemap_fd_ = open_process_file(pid_, "pagemap", O_RDONLY|O_CLOEXEC); + if (pagemap_fd_ < 0) + xbt_die("Could not open pagemap file for soft-dirty tracking. Run as root?"); + } + ssize_t bytesize = sizeof(uint64_t) * page_count; + off_t offset = sizeof(uint64_t) * page_start; + if (pread_whole(pagemap_fd_, pagemap, bytesize, offset) != bytesize) + xbt_die("Could not read pagemap"); +} + } }