Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions libhsakmt/src/fmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1843,7 +1843,6 @@ static void *fmm_allocate_host_gpu(uint32_t gpu_id, uint32_t node_id, void *addr
{
manageable_aperture_t *aperture;
vm_object_t *vm_obj = NULL;
int flags = MADV_DONTFORK;
uint64_t mmap_offset;
int32_t gpu_drm_fd;
uint32_t ioc_flags;
Expand All @@ -1852,11 +1851,6 @@ static void *fmm_allocate_host_gpu(uint32_t gpu_id, uint32_t node_id, void *addr
uint64_t size;
void *mem;

/* set madvise flags to HUGEPAGE always for 2MB pages */
if (MemorySizeInBytes >= (2 * 1024 * 1024))
flags |= MADV_HUGEPAGE;


if (!g_first_gpu_mem)
return NULL;

Expand Down Expand Up @@ -1895,6 +1889,12 @@ static void *fmm_allocate_host_gpu(uint32_t gpu_id, uint32_t node_id, void *addr
* memory is allocated from KFD
*/
if (!mflags.ui32.NonPaged && svm.userptr_for_paged_mem) {
int advice = MADV_NORMAL;

/* set madvise flags to HUGEPAGE always for 2MB pages */
if (MemorySizeInBytes >= (2 * 1024 * 1024))
advice = MADV_HUGEPAGE;

/* Allocate address space */
pthread_mutex_lock(&aperture->fmm_mutex);
mem = aperture_allocate_area_aligned(aperture, address, size, alignment);
Expand All @@ -1916,7 +1916,7 @@ static void *fmm_allocate_host_gpu(uint32_t gpu_id, uint32_t node_id, void *addr
* fork. This avoids MMU notifiers and evictions due to user
* memory mappings on fork.
*/
madvise(mem, MemorySizeInBytes, flags);
madvise(mem, MemorySizeInBytes, advice);

/* Create userptr BO */
mmap_offset = (uint64_t)mem;
Expand Down
Loading