+ int low_page_start_offset = ALIGN_UP(start_offset, PAGE_SIZE);
+ int low_page_stop_offset = start_block_offset < ALIGN_DOWN(stop_offset, PAGE_SIZE) ? start_block_offset : ALIGN_DOWN(stop_offset, PAGE_SIZE);
+ if(low_page_start_offset < low_page_stop_offset) {
+ void* pos = (void*)((unsigned long)mem + low_page_start_offset);
+ void* res = mmap(pos, low_page_stop_offset-low_page_start_offset, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED | MAP_POPULATE,
+ smpi_shared_malloc_bogusfile, 0);
+ xbt_assert(res == pos, "Could not map folded virtual memory (%s). Do you perhaps need to increase the "
+ "size of the mapped file using --cfg=smpi/shared-malloc-blocksize=newvalue (default 1048576) ?"
+ "You can also try using the sysctl vm.max_map_count",
+ strerror(errno));
+ }
+ if(low_page_stop_offset <= stop_block_offset) {
+ int high_page_stop_offset = stop_offset == size ? size : ALIGN_DOWN(stop_offset, PAGE_SIZE);
+ if(high_page_stop_offset > stop_block_offset) {
+ void* pos = (void*)((unsigned long)mem + stop_block_offset);
+ void* res = mmap(pos, high_page_stop_offset-stop_block_offset, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED | MAP_POPULATE,
+ smpi_shared_malloc_bogusfile, 0);
+ xbt_assert(res == pos, "Could not map folded virtual memory (%s). Do you perhaps need to increase the "
+ "size of the mapped file using --cfg=smpi/shared-malloc-blocksize=newvalue (default 1048576) ?"
+ "You can also try using the sysctl vm.max_map_count",
+ strerror(errno));
+ }
+ }