From c28c344f785b32dd2cc2d76efb0a05bafbc6edf6 Mon Sep 17 00:00:00 2001 From: Felix Kuehling Date: Tue, 21 Feb 2017 14:13:05 -0500 Subject: [PATCH] Avoid COW after fork for API-allocated system memory Change-Id: I5c7175114c4e6411d3beb5557e16cb71ddb01189 Signed-off-by: Felix Kuehling [ROCm/ROCR-Runtime commit: 64104fc8d966b354f0f3885c22f65517388e86f8] --- projects/rocr-runtime/src/fmm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/projects/rocr-runtime/src/fmm.c b/projects/rocr-runtime/src/fmm.c index bb9b7ca8bf..3dc51ab6e8 100644 --- a/projects/rocr-runtime/src/fmm.c +++ b/projects/rocr-runtime/src/fmm.c @@ -1139,6 +1139,11 @@ static void* fmm_allocate_host_gpu(uint32_t node_id, uint64_t MemorySizeInBytes, return NULL; } + /* Mappings in the DGPU aperture don't need to be copied on + * fork. This avoids MMU notifiers and evictions due to user + * memory mappings on fork. */ + madvise(mem, MemorySizeInBytes, MADV_DONTFORK); + /* Create userptr BO */ mmap_offset = (uint64_t)mem; ioc_flags |= KFD_IOC_ALLOC_MEM_FLAGS_USERPTR;