From 4a85fbe15d839396514cb6c2be3ea977d766d95e Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Fri, 17 Oct 2014 14:50:21 +0200 Subject: [PATCH] [smpi+mc] When restoring a snapshot, always remap the SMPI privatisation segment 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 | 8 +++++++- src/smpi/private.h | 4 +++- src/smpi/smpi_bench.c | 24 +++++++++++++++--------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/mc/mc_checkpoint.c b/src/mc/mc_checkpoint.c index 5bc84646fa..07e80ab57c 100644 --- a/src/mc/mc_checkpoint.c +++ b/src/mc/mc_checkpoint.c @@ -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 diff --git a/src/smpi/private.h b/src/smpi/private.h index 659424dd38..eb9a55040c 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -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); diff --git a/src/smpi/smpi_bench.c b/src/smpi/smpi_bench.c index f7b0c26c86..bf0fb7f109 100644 --- a/src/smpi/smpi_bench.c +++ b/src/smpi/smpi_bench.c @@ -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 -- 2.20.1