Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Read smpi_process_count() from remote process
[simgrid.git] / src / mc / mc_checkpoint.c
index 82e88c3..3d92e45 100644 (file)
@@ -34,6 +34,8 @@
 #include "mc_object_info.h"
 #include "mc_mmu.h"
 #include "mc_unw.h"
+#include "mc_protocol.h"
+#include "mc_smx.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_checkpoint, mc,
                                 "Logging specific to mc_checkpoint");
@@ -202,7 +204,7 @@ static mc_mem_region_t MC_region_new_privatized(
     mc_region_type_t region_type, void *start_addr, void* permanent_addr, size_t size,
     mc_mem_region_t ref_reg)
 {
-  size_t process_count = smpi_process_count();
+  size_t process_count = MC_smpi_process_count();
   mc_mem_region_t region = xbt_new(s_mc_mem_region_t, 1);
   region->region_type = region_type;
   region->storage_type = MC_REGION_STORAGE_TYPE_PRIVATIZED;
@@ -240,7 +242,7 @@ static void MC_snapshot_add_region(int index, mc_snapshot_t snapshot, mc_region_
 
   mc_mem_region_t region;
   const bool privatization_aware = MC_object_info_is_privatized(object_info);
-  if (privatization_aware && smpi_process_count())
+  if (privatization_aware && MC_smpi_process_count())
     region = MC_region_new_privatized(type, start_addr, permanent_addr, size, ref_reg);
   else
     region = MC_region_new(type, start_addr, permanent_addr, size, ref_reg);
@@ -275,7 +277,7 @@ static void MC_get_memory_regions(mc_process_t process, mc_snapshot_t snapshot)
     MC_process_get_malloc_info(process));
 
 #ifdef HAVE_SMPI
-  if (smpi_privatize_global_variables && smpi_process_count()) {
+  if (smpi_privatize_global_variables && MC_smpi_process_count()) {
     // FIXME, cross-process
     snapshot->privatization_index = smpi_loaded_page;
   } else
@@ -701,6 +703,10 @@ static void MC_get_current_fd(mc_snapshot_t snapshot)
     if (strncmp(link, "pipe:", 5) == 0 || strncmp(link, "socket:", 7) == 0)
       continue;
 
+    // If dot_output enabled, do not handle the corresponding file
+    if (dot_output !=  NULL && strcmp(basename(link), _sg_mc_dot_output_file) == 0)
+      continue;
+
     // This is probably a shared memory used by lttng-ust:
     if(strncmp("/dev/shm/ust-shm-tmp-", link, 21)==0)
       continue;
@@ -732,15 +738,15 @@ mc_snapshot_t MC_take_snapshot(int num_state)
   snapshot->address_space.address_space_class = &mc_snapshot_class;
 
   snapshot->enabled_processes = xbt_dynar_new(sizeof(int), NULL);
+
   smx_process_t process;
-  // FIXME, cross-process support (simix_global->process_list)
-  xbt_swag_foreach(process, simix_global->process_list) {
-    xbt_dynar_push_as(snapshot->enabled_processes, int, (int)process->pid);
-  }
+  MC_EACH_SIMIX_PROCESS(process,
+    xbt_dynar_push_as(snapshot->enabled_processes, int, (int)process->pid));
 
   MC_snapshot_handle_ignore(snapshot);
 
-  MC_get_current_fd(snapshot);
+  if (_sg_mc_snapshot_fds)
+    MC_get_current_fd(snapshot);
 
   const bool use_soft_dirty = _sg_mc_sparse_checkpoint
     && _sg_mc_soft_dirty
@@ -797,12 +803,12 @@ void MC_restore_snapshot_regions(mc_snapshot_t snapshot)
 #endif
 }
 
-// FIXME, cross-process support ~ we need to implement this on the app side
-// or use some form of [remote syscall execution](http://criu.org/Remote_syscall_execution)
-// based on [parasite code execution](http://criu.org/Parasite_code).
 static inline
 void MC_restore_snapshot_fds(mc_snapshot_t snapshot)
 {
+  if (mc_mode == MC_MODE_SERVER)
+    xbt_die("FD snapshot not implemented in client/server mode.");
+
   int new_fd;
   size_t i;
   for(i=0; i < snapshot->total_fd; i++){
@@ -828,7 +834,8 @@ void MC_restore_snapshot(mc_snapshot_t snapshot)
     && MC_process_is_self(&mc_model_checker->process);
 
   MC_restore_snapshot_regions(snapshot);
-  MC_restore_snapshot_fds(snapshot);
+  if (_sg_mc_snapshot_fds)
+    MC_restore_snapshot_fds(snapshot);
   if (use_soft_dirty) {
     mc_softdirty_reset();
   }