From f7a3427c99763624ef5a3b236031e657a3e4e90c Mon Sep 17 00:00:00 2001 From: Philip Cox Date: Wed, 19 Aug 2020 11:54:33 -0400 Subject: [PATCH] libhsakmt: call madvise() from fmm_allocate_device This is needed to avoid additional references to mapped BOs in child processes that can prevent freeing memory in the parent process and lead to out-of-memory conditions. Change-Id: I25c90510a14dde515cc23ea5dc1f68e8d7e37a66 Signed-off-by: Philip Cox --- src/fmm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/fmm.c b/src/fmm.c index 8bcfa033c7..411fc0ee32 100644 --- a/src/fmm.c +++ b/src/fmm.c @@ -1361,6 +1361,13 @@ void *fmm_allocate_device(uint32_t gpu_id, void *address, uint64_t MemorySizeInB __fmm_release(vm_obj, aperture); return NULL; } + /* + * This madvise() call is needed to avoid additional references + * to mapped BOs in child processes that can prevent freeing + * memory in the parent process and lead to out-of-memory + * conditions. + */ + madvise(mem, MemorySizeInBytes, MADV_DONTFORK); } return mem;