• Rajneesh Bhardwaj's avatar
    drm/amdgpu: Don't inherit GEM object VMAs in child process · fbcdbfde
    Rajneesh Bhardwaj authored
    When an application having open file access to a node forks, its shared
    mappings also get reflected in the address space of child process even
    though it cannot access them with the object permissions applied. With the
    existing permission checks on the gem objects, it might be reasonable to
    also create the VMAs with VM_DONTCOPY flag so a user space application
    doesn't need to explicitly call the madvise(addr, len, MADV_DONTFORK)
    system call to prevent the pages in the mapped range to appear in the
    address space of the child process. It also prevents the memory leaks
    due to additional reference counts on the mapped BOs in the child
    process that prevented freeing the memory in the parent for which we had
    worked around earlier in the user space inside the thunk library.
    
    Additionally, we faced this issue when using CRIU to checkpoint restore
    an application that had such inherited mappings in the child which
    confuse CRIU when it mmaps on restore. Having this flag set for the
    render node VMAs helps. VMAs mapped via KFD already take care of this so
    this is needed only for the render nodes.
    
    To limit the impact of the change to user space consumers such as OpenGL
    etc, limit it to KFD BOs only.
    Acked-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
    Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
    Signed-off-by: default avatarDavid Yat Sin <david.yatsin@amd.com>
    Signed-off-by: default avatarRajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
    Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
    fbcdbfde
amdgpu_gem.c 25.6 KB