Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[smpi+mc] When restoring a snapshot, always remap the SMPI privatisation segment
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 17 Oct 2014 12:50:21 +0000 (14:50 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 17 Oct 2014 12:50:21 +0000 (14:50 +0200)
After restoring the global variables in a snapshot, the global
variable containing the currently active SMPI privatization segment is
overwritten. As a consequence, the segment SMPI thinks active might be
inconsistent with the currently active segment (which the kernels
knows about).

In this case, we want to remap the segment regardless of what SMPI
thinks.

We might be more clever to avoid unecessary segment switch if the
segment which is really mapped is the same as the one we want.

src/mc/mc_checkpoint.c
src/smpi/private.h
src/smpi/smpi_bench.c

index 5bc8464..07e80ab 100644 (file)
@@ -679,7 +679,13 @@ void MC_restore_snapshot(mc_snapshot_t snapshot)
     }
   }
   if(snapshot->privatization_index >= 0) {
-    smpi_switch_data_segment(snapshot->privatization_index);
+    // We just rewrote the global variables.
+    // The privatisation segment SMPI thinks
+    // is mapped might be inconsistent with the segment which
+    // is really mapped in memory (kernel state).
+    // We ask politely SMPI to map the segment anyway,
+    // even if it thinks it is the current one:
+    smpi_really_switch_data_segment(snapshot->privatization_index);
   }
 #endif
 
index 659424d..eb9a550 100644 (file)
@@ -435,7 +435,9 @@ extern char* start_data_exe; //start of the data+bss segment of the executable
 extern int size_data_exe; //size of the data+bss segment of the executable
 
 
-void smpi_switch_data_segment(int);
+void smpi_switch_data_segment(int dest);
+void smpi_really_switch_data_segment(int dest);
+
 void smpi_get_executable_global_size(void);
 void smpi_initialize_global_memory_segments(void);
 void smpi_destroy_global_memory_segments(void);
index f7b0c26..bf0fb7f 100644 (file)
@@ -607,23 +607,29 @@ void* smpi_shared_set_call(const char* func, const char* input, void* data) {
 #define TOPAGE(addr) (void *)(((unsigned long)(addr) / xbt_pagesize) * xbt_pagesize)
 
 
-/*
- * - read the executable data+bss section addresses and sizes
- * - for each process create a copy of these sections with mmap
- * - store them in a dynar
- *
+/** Map a given SMPI privatization segment (make a SMPI process active)
  */
+void smpi_switch_data_segment(int dest){
 
+  if (smpi_loaded_page==dest)//no need to switch either
+   return;
 
+  // So the job:
+  smpi_really_switch_data_segment(dest);
+}
 
-void smpi_switch_data_segment(int dest){
+/** Map a given SMPI privatization segment (make a SMPI process active)
+ *  even if SMPI thinks it is already active
+ *
+ *  When doing a state restoration, the state of the restored variables
+ *  might not be consistent with the state of the virtual memory.
+ *  In this case, we to change the data segment.
+ */
+void smpi_really_switch_data_segment(int dest) {
 
   if(size_data_exe == 0)//no need to switch
     return;
 
-  if (smpi_loaded_page==dest)//no need to switch either
-    return;
-
 #ifdef HAVE_MMAP
   int i;
   if(smpi_loaded_page==-1){//initial switch, do the copy from the real page here