A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
remove a few smells in instrumentation
[simgrid.git]
/
src
/
mc
/
PageStore.hpp
diff --git
a/src/mc/PageStore.hpp
b/src/mc/PageStore.hpp
index
9296a32
..
979e02f
100644
(file)
--- a/
src/mc/PageStore.hpp
+++ b/
src/mc/PageStore.hpp
@@
-7,19
+7,16
@@
#ifndef SIMGRID_MC_PAGESTORE_HPP
#define SIMGRID_MC_PAGESTORE_HPP
#ifndef SIMGRID_MC_PAGESTORE_HPP
#define SIMGRID_MC_PAGESTORE_HPP
-#include <stdint.h>
-
+#include <cstdint>
#include <vector>
#include <vector>
-#include <boost/array.hpp>
-#include <boost/utility.hpp>
-#include <boost/unordered_map.hpp>
-#include <boost/unordered_set.hpp>
+#include <unordered_map>
+#include <unordered_set>
-#include <xbt.h>
+#include <xbt
/base
.h>
-#include "mc_mmu.h"
-#include "
mc_forward.h
"
+#include "
src/mc/
mc_mmu.h"
+#include "
src/mc/mc_forward.hpp
"
namespace simgrid {
namespace mc {
namespace simgrid {
namespace mc {
@@
-27,9
+24,9
@@
namespace mc {
/** @brief Storage for snapshot memory pages
*
* The first (lower) layer of the per-page snapshot mechanism is a page
/** @brief Storage for snapshot memory pages
*
* The first (lower) layer of the per-page snapshot mechanism is a page
- * store: it
'
s responsibility is to store immutable shareable
- * reference-counted memory pages independently of the snapshoting
- * logic. Snapshot management and representation
, soft-dirty tracking
is
+ * store: its responsibility is to store immutable shareable
+ * reference-counted memory pages independently of the snapshot
t
ing
+ * logic. Snapshot management and representation is
* handled to an higher layer. READMORE
*
* Data structure:
* handled to an higher layer. READMORE
*
* Data structure:
@@
-78,40
+75,37
@@
namespace mc {
*/
class PageStore {
public: // Types
*/
class PageStore {
public: // Types
- typedef uint64_t hash_type;
+ typedef
std::
uint64_t hash_type;
private: // Types
// We are using a cheap hash to index a page.
// We should expect collision and we need to associate multiple page indices
// to the same hash.
private: // Types
// We are using a cheap hash to index a page.
// We should expect collision and we need to associate multiple page indices
// to the same hash.
- typedef
boost::unordered_set<
size_t> page_set_type;
- typedef
boost
::unordered_map<hash_type, page_set_type> pages_map_type;
+ typedef
std::unordered_set<std::
size_t> page_set_type;
+ typedef
std
::unordered_map<hash_type, page_set_type> pages_map_type;
private: // Fields:
private: // Fields:
- /** First page
- *
- * mc_page_store_get_page expects that this is the first field.
- * */
+ /** First page */
void* memory_;
/** Number of available pages in virtual memory */
void* memory_;
/** Number of available pages in virtual memory */
- size_t capacity_;
+ s
td::s
ize_t capacity_;
/** Top of the used pages (index of the next available page) */
/** Top of the used pages (index of the next available page) */
- size_t top_index_;
+ s
td::s
ize_t top_index_;
/** Page reference count */
/** Page reference count */
- std::vector<uint64_t> page_counts_;
+ std::vector<
std::
uint64_t> page_counts_;
/** Index of available pages before the top */
/** Index of available pages before the top */
- std::vector<size_t> free_pages_;
+ std::vector<s
td::s
ize_t> free_pages_;
/** Index from page hash to page index */
pages_map_type hash_index_;
private: // Methods
/** Index from page hash to page index */
pages_map_type hash_index_;
private: // Methods
- void resize(size_t size);
- size_t alloc_page();
- void remove_page(size_t pageno);
+ void resize(s
td::s
ize_t size);
+ s
td::s
ize_t alloc_page();
+ void remove_page(s
td::s
ize_t pageno);
public: // Constructors
PageStore(PageStore const&) = delete;
PageStore& operator=(PageStore const&) = delete;
public: // Constructors
PageStore(PageStore const&) = delete;
PageStore& operator=(PageStore const&) = delete;
- explicit PageStore(size_t size);
+ explicit PageStore(s
td::s
ize_t size);
~PageStore();
public: // Methods
~PageStore();
public: // Methods
@@
-125,7
+119,7
@@
public: // Methods
* it is added to the `free_pages_` list and removed from the `hash_index_`.
*
* */
* it is added to the `free_pages_` list and removed from the `hash_index_`.
*
* */
- void unref_page(size_t pageno);
+ void unref_page(s
td::s
ize_t pageno);
/** @brief Increment the refcount for a given page
*
/** @brief Increment the refcount for a given page
*
@@
-140,60
+134,63
@@
public: // Methods
void ref_page(size_t pageno);
/** @brief Store a page in the page store */
void ref_page(size_t pageno);
/** @brief Store a page in the page store */
- size_t store_page(void* page);
+ s
td::s
ize_t store_page(void* page);
/** @brief Get a page from its page number
*
* @param Number of the memory page in the store
* @return Start of the page
*/
/** @brief Get a page from its page number
*
* @param Number of the memory page in the store
* @return Start of the page
*/
- const void* get_page(size_t pageno) const;
+ const void* get_page(s
td::s
ize_t pageno) const;
public: // Debug/test methods
/** @brief Get the number of references for a page */
public: // Debug/test methods
/** @brief Get the number of references for a page */
- s
ize_t get_ref(
size_t pageno);
+ s
td::size_t get_ref(std::
size_t pageno);
/** @brief Get the number of used pages */
/** @brief Get the number of used pages */
- size_t size();
+ s
td::s
ize_t size();
/** @brief Get the capacity of the page store
*
* The capacity is expanded by a system call (mremap).
* */
/** @brief Get the capacity of the page store
*
* The capacity is expanded by a system call (mremap).
* */
- size_t capacity();
+ s
td::s
ize_t capacity();
};
inline __attribute__((always_inline))
};
inline __attribute__((always_inline))
-void PageStore::unref_page(size_t pageno) {
- if ((--this->page_counts_[pageno]) == 0)
{
+void PageStore::unref_page(s
td::s
ize_t pageno) {
+ if ((--this->page_counts_[pageno]) == 0)
this->remove_page(pageno);
this->remove_page(pageno);
- }
}
inline __attribute__((always_inline))
}
inline __attribute__((always_inline))
-void PageStore::ref_page(size_t pageno) {
+void PageStore::ref_page(size_t pageno)
+{
++this->page_counts_[pageno];
}
inline __attribute__((always_inline))
++this->page_counts_[pageno];
}
inline __attribute__((always_inline))
-const void* PageStore::get_page(size_t pageno) const {
- return mc_page_from_number(this->memory_, pageno);
+const void* PageStore::get_page(std::size_t pageno) const
+{
+ return (void*) simgrid::mc::mmu::join(pageno, (std::uintptr_t) this->memory_);
}
inline __attribute__((always_inline))
}
inline __attribute__((always_inline))
-size_t PageStore::get_ref(size_t pageno) {
+std::size_t PageStore::get_ref(std::size_t pageno)
+{
return this->page_counts_[pageno];
}
inline __attribute__((always_inline))
return this->page_counts_[pageno];
}
inline __attribute__((always_inline))
-size_t PageStore::size() {
+s
td::s
ize_t PageStore::size() {
return this->top_index_ - this->free_pages_.size();
}
inline __attribute__((always_inline))
return this->top_index_ - this->free_pages_.size();
}
inline __attribute__((always_inline))
-size_t PageStore::capacity() {
+std::size_t PageStore::capacity()
+{
return this->capacity_;
}
return this->capacity_;
}