diff --git a/executer/kernel/mcctrl/syscall.c b/executer/kernel/mcctrl/syscall.c index f6111ed5..68f50ef0 100644 --- a/executer/kernel/mcctrl/syscall.c +++ b/executer/kernel/mcctrl/syscall.c @@ -972,20 +972,23 @@ static int pager_req_create(ihk_os_t os, int fd, uintptr_t result_pa) goto out; } - /* OpenMPI /tmp shared memory hack */ + /* Shared memory hack */ { char *pathbuf, *fullpath; pathbuf = kmalloc(PATH_MAX, GFP_ATOMIC); if (pathbuf) { fullpath = d_path(&file->f_path, pathbuf, PATH_MAX); if (!IS_ERR(fullpath)) { - if (!strncmp("/tmp/ompi.", fullpath, 10)) { + if (!strncmp("/tmp/ompi.", fullpath, 10) || + !strncmp("/dev/shm/", fullpath, 9)) { dprintk("%s: treating %s as a device file..\n", __func__, fullpath); kfree(pathbuf); + error = -ESRCH; goto out; } + kfree(pathbuf); } } @@ -1430,14 +1433,15 @@ static int pager_req_map(ihk_os_t os, int fd, size_t len, off_t off, #define ANY_WHERE 0 if (prot_and_flags & MAP_LOCKED) prot_and_flags |= MAP_POPULATE; - /* OpenMPI /tmp shared memory hack */ + /* Shared memory hack */ { char *pathbuf, *fullpath; pathbuf = kmalloc(PATH_MAX, GFP_ATOMIC); if (pathbuf) { fullpath = d_path(&file->f_path, pathbuf, PATH_MAX); if (!IS_ERR(fullpath)) { - if (!strncmp("/tmp/ompi.", fullpath, 10)) { + if (!strncmp("/tmp/ompi.", fullpath, 10) || + !strncmp("/dev/shm/", fullpath, 9)) { dprintk("%s: pre-populating %s..\n", __func__, fullpath); prot_and_flags |= MAP_POPULATE; @@ -1614,10 +1618,27 @@ retry: #else fault = handle_mm_fault(current->mm, vma, va, flags); #endif +#ifdef SC_DEBUG if (fault != 0) { - printk("%s: error: faulting %lx at off: %lu\n", - __FUNCTION__, va, off); + char *pathbuf = NULL; + char *fullpath; + + if (vma->vm_file) { + pathbuf = kmalloc(PATH_MAX, GFP_ATOMIC); + if (pathbuf) { + fullpath = d_path(&vma->vm_file->f_path, + pathbuf, PATH_MAX); + if (!IS_ERR(fullpath)) { + printk("%s: WARNING: couldn't fault 0x%lx" + " at off: %lu in %s\n", + __FUNCTION__, va, off, fullpath); + } + + kfree(pathbuf); + } + } } +#endif page_fault_attempted = 1; goto retry; diff --git a/kernel/syscall.c b/kernel/syscall.c index 0d2a2f8b..17959681 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -1812,6 +1812,7 @@ do_mmap(const uintptr_t addr0, const size_t len0, const int prot, __func__, flags, memobj->path, memobj->flags, pgshift, p2align); pgshift = PAGE_SHIFT; p2align = PAGE_P2ALIGN; + populated_mapping = 1; } #ifdef ATTACHED_MIC /* @@ -1849,6 +1850,13 @@ do_mmap(const uintptr_t addr0, const size_t len0, const int prot, #ifdef PROFILE_ENABLE profile_event_add(PROFILE_mmap_device_file, len); #endif // PROFILE_ENABLE + if (memobj->path && + (!strncmp("/tmp/ompi.", memobj->path, 10) || + !strncmp("/dev/shm/", memobj->path, 9))) { + pgshift = PAGE_SHIFT; + p2align = PAGE_P2ALIGN; + populated_mapping = 1; + } } } if (error) {