libhsakmt: Use MADV_HUGEPAGE for large allocations

For large memory allocations (>2MB) the thunk should use the
MADV_HUGEPAGE flag for madvise call to optimize allocation performance
on certain operating systems that rely on madvise hint when Traspatent
Huge Pages is not set to always.

Suggested-by: Joseph Greathouse <joseph.greathouse@amd.com>
Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Change-Id: Ic0c753f89a177b0f715942d6e2a7108b08a85f20
Este commit está contenido en:
Rajneesh Bhardwaj
2023-10-11 15:08:04 -04:00
cometido por Rajneesh Bhardwaj
padre a226542fc3
commit 5047eb161f
+13 -7
Ver fichero
@@ -1772,14 +1772,20 @@ static int bind_mem_to_numa(uint32_t node_id, void *mem,
static void *fmm_allocate_host_gpu(uint32_t node_id, void *address,
uint64_t MemorySizeInBytes, HsaMemFlags mflags)
{
void *mem;
manageable_aperture_t *aperture;
uint64_t mmap_offset;
uint32_t ioc_flags;
uint64_t size;
int32_t gpu_drm_fd;
uint32_t gpu_id;
vm_object_t *vm_obj = NULL;
int flags = MADV_DONTFORK;
uint64_t mmap_offset;
int32_t gpu_drm_fd;
uint32_t ioc_flags;
uint32_t gpu_id;
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;
@@ -1830,7 +1836,7 @@ static void *fmm_allocate_host_gpu(uint32_t node_id, void *address,
* fork. This avoids MMU notifiers and evictions due to user
* memory mappings on fork.
*/
madvise(mem, MemorySizeInBytes, MADV_DONTFORK);
madvise(mem, MemorySizeInBytes, flags);
/* Create userptr BO */
mmap_offset = (uint64_t)mem;