Fix memory leaks due to stale CPU mappings

Use the aligned size of the buffer objects for CPU unmapping in
__fmm_release instead of relying on the unaligned size passed in by
the caller.

Change-Id: If986ec24e9a05d32981549fddbf143221fc40bac


[ROCm/ROCR-Runtime commit: 7a383f9d88]
This commit is contained in:
Felix Kuehling
2016-01-15 22:05:28 -05:00
parent 99325bf7c4
commit 6d856ebbff
+7 -8
View File
@@ -922,6 +922,13 @@ static void __fmm_release(void *address,
if (object->device_ids_array_size > 0)
free(object->device_ids_array);
if (address >= dgpu_shared_aperture_base &&
address <= dgpu_shared_aperture_limit) {
/* Remove any CPU mapping, but keep the address range reserved */
mmap(address, object->size, PROT_NONE,
MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE | MAP_FIXED, -1, 0);
}
args.handle = object->handle;
kmtIoctl(kfd_fd, AMDKFD_IOC_FREE_MEMORY_OF_GPU, &args);
@@ -971,14 +978,6 @@ void fmm_release(void *address, uint64_t MemorySizeInBytes)
}
}
if (found &&
address >= dgpu_shared_aperture_base &&
address <= dgpu_shared_aperture_limit) {
/* Remove any CPU mapping, but keep the address range reserved */
mmap(address, MemorySizeInBytes, PROT_NONE,
MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE | MAP_FIXED, -1, 0);
}
/*
* If memory address isn't inside of any defined aperture - it refers
* to the system memory