SWDEV-419034 - Use MADV_HUGEPAGE for large host allocations

Change-Id: I80bb1839cdd47eb64a97467c8b01fcdf37195ad5
Этот коммит содержится в:
Satyanvesh Dittakavi
2023-08-25 13:29:24 +00:00
родитель f3dc04a50d
Коммит 94e70bee26
+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
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;
}