Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Only enable KSM on snapshots and not on main memory
authorGabriel Corona <gabriel.corona@loria.fr>
Mon, 14 Apr 2014 11:00:27 +0000 (13:00 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Mon, 14 Apr 2014 13:03:09 +0000 (15:03 +0200)
Merging pages on the main memory will generate page faults on write
and we won't gain much memory.

src/mc/mc_checkpoint.c
src/mc/mc_global.c
src/xbt/mmalloc/mmorecore.c

index e455677..d287c80 100644 (file)
@@ -54,7 +54,7 @@ static void local_variable_free_voidp(void *v){
 
 static void MC_region_destroy(mc_mem_region_t reg)
 {
-  xbt_free(reg->data);
+  munmap(reg->data, reg->size);
   xbt_free(reg);
 }
 
@@ -87,8 +87,9 @@ static mc_mem_region_t MC_region_new(int type, void *start_addr, size_t size)
   mc_mem_region_t new_reg = xbt_new(s_mc_mem_region_t, 1);
   new_reg->start_addr = start_addr;
   new_reg->size = size;
-  new_reg->data = xbt_malloc(size);
+  new_reg->data = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
   memcpy(new_reg->data, start_addr, size);
+  madvise(new_reg->data, size, MADV_MERGEABLE);
 
   XBT_DEBUG("New region : type : %d, data : %p (real addr %p), size : %zu", type, new_reg->data, start_addr, size);
   
index 55cf908..acbc818 100644 (file)
@@ -800,14 +800,6 @@ static void MC_init_debug_info(void) {
   mc_libsimgrid_info = MC_find_object_info(maps, libsimgrid_path, 0);
   mc_object_infos[1] = mc_libsimgrid_info;
 
-#ifdef MADV_MERGEABLE
-  for(int i=0; i!=mc_object_infos_size; ++i) {
-    void* start = mc_object_infos[i]->start_rw;
-    void* end = mc_object_infos[i]->end_rw;
-    madvise(start, (char*)end - (char*)start, MADV_MERGEABLE);
-  }
-#endif
-
   // Use information of the other objects:
   MC_post_process_object_info(mc_binary_info);
   MC_post_process_object_info(mc_libsimgrid_info);
index 38f6d8b..9fbf7a9 100644 (file)
@@ -124,10 +124,6 @@ void *mmorecore(struct mdesc *mdp, ssize_t size)
         abort();
       }
 
-#ifdef MADV_MERGEABLE
-      madvise(mapto, mapbytes, MADV_MERGEABLE);
-#endif
-
       if (mdp->top == 0)
         mdp->base = mdp->breakval = mapto;