SWDEV-419034 - Use MADV_HUGEPAGE for large host allocations
Change-Id: I80bb1839cdd47eb64a97467c8b01fcdf37195ad5
This commit is contained in:
+12
-1
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008 - 2021 Advanced Micro Devices, Inc.
|
/* Copyright (c) 2008 - 2023 Advanced Micro Devices, Inc.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@@ -233,6 +233,17 @@ address Os::reserveMemory(address start, size_t size, size_t alignment, MemProt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hint to enable THP for large host allocations which can help in performance gain
|
||||||
|
constexpr size_t kLargePageSize = 2 * Mi;
|
||||||
|
if (size >= kLargePageSize) {
|
||||||
|
int status = madvise(aligned, size, MADV_HUGEPAGE);
|
||||||
|
if (status) {
|
||||||
|
ClPrint(amd::LOG_DEBUG, amd::LOG_CODE, "madvise with advice MADV_HUGEPAGE"
|
||||||
|
" starting at address %p and page size 0x%zx, returned %d, errno: %s",
|
||||||
|
aligned, size, status, strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return aligned;
|
return aligned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user