/dev/shm: use Linux PFNs and populate mappings
Change-Id: I921c1f43c8411f896343be17e0ac6762a1bc26d1
This commit is contained in:
committed by
Masamichi Takagi
parent
5c2f9b8239
commit
f8e8b21f04
@ -972,20 +972,23 @@ static int pager_req_create(ihk_os_t os, int fd, uintptr_t result_pa)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* OpenMPI /tmp shared memory hack */
|
/* Shared memory hack */
|
||||||
{
|
{
|
||||||
char *pathbuf, *fullpath;
|
char *pathbuf, *fullpath;
|
||||||
pathbuf = kmalloc(PATH_MAX, GFP_ATOMIC);
|
pathbuf = kmalloc(PATH_MAX, GFP_ATOMIC);
|
||||||
if (pathbuf) {
|
if (pathbuf) {
|
||||||
fullpath = d_path(&file->f_path, pathbuf, PATH_MAX);
|
fullpath = d_path(&file->f_path, pathbuf, PATH_MAX);
|
||||||
if (!IS_ERR(fullpath)) {
|
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",
|
dprintk("%s: treating %s as a device file..\n",
|
||||||
__func__, fullpath);
|
__func__, fullpath);
|
||||||
kfree(pathbuf);
|
kfree(pathbuf);
|
||||||
|
|
||||||
error = -ESRCH;
|
error = -ESRCH;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
kfree(pathbuf);
|
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
|
#define ANY_WHERE 0
|
||||||
if (prot_and_flags & MAP_LOCKED) prot_and_flags |= MAP_POPULATE;
|
if (prot_and_flags & MAP_LOCKED) prot_and_flags |= MAP_POPULATE;
|
||||||
|
|
||||||
/* OpenMPI /tmp shared memory hack */
|
/* Shared memory hack */
|
||||||
{
|
{
|
||||||
char *pathbuf, *fullpath;
|
char *pathbuf, *fullpath;
|
||||||
pathbuf = kmalloc(PATH_MAX, GFP_ATOMIC);
|
pathbuf = kmalloc(PATH_MAX, GFP_ATOMIC);
|
||||||
if (pathbuf) {
|
if (pathbuf) {
|
||||||
fullpath = d_path(&file->f_path, pathbuf, PATH_MAX);
|
fullpath = d_path(&file->f_path, pathbuf, PATH_MAX);
|
||||||
if (!IS_ERR(fullpath)) {
|
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",
|
dprintk("%s: pre-populating %s..\n",
|
||||||
__func__, fullpath);
|
__func__, fullpath);
|
||||||
prot_and_flags |= MAP_POPULATE;
|
prot_and_flags |= MAP_POPULATE;
|
||||||
@ -1614,10 +1618,27 @@ retry:
|
|||||||
#else
|
#else
|
||||||
fault = handle_mm_fault(current->mm, vma, va, flags);
|
fault = handle_mm_fault(current->mm, vma, va, flags);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef SC_DEBUG
|
||||||
if (fault != 0) {
|
if (fault != 0) {
|
||||||
printk("%s: error: faulting %lx at off: %lu\n",
|
char *pathbuf = NULL;
|
||||||
__FUNCTION__, va, off);
|
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;
|
page_fault_attempted = 1;
|
||||||
goto retry;
|
goto retry;
|
||||||
|
|||||||
@ -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);
|
__func__, flags, memobj->path, memobj->flags, pgshift, p2align);
|
||||||
pgshift = PAGE_SHIFT;
|
pgshift = PAGE_SHIFT;
|
||||||
p2align = PAGE_P2ALIGN;
|
p2align = PAGE_P2ALIGN;
|
||||||
|
populated_mapping = 1;
|
||||||
}
|
}
|
||||||
#ifdef ATTACHED_MIC
|
#ifdef ATTACHED_MIC
|
||||||
/*
|
/*
|
||||||
@ -1849,6 +1850,13 @@ do_mmap(const uintptr_t addr0, const size_t len0, const int prot,
|
|||||||
#ifdef PROFILE_ENABLE
|
#ifdef PROFILE_ENABLE
|
||||||
profile_event_add(PROFILE_mmap_device_file, len);
|
profile_event_add(PROFILE_mmap_device_file, len);
|
||||||
#endif // PROFILE_ENABLE
|
#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) {
|
if (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user