Merge pull request #1085 from Sonicadvance1/transparent_huge_pages

Enables transparent huge pages in our 64-bit VA allocator
This commit is contained in:
Stefanos Kornilios Mitsis Poiitidis authored and GitHub committed 2021-06-14 17:04:40 +03:00
commit 779aca7e95
1 file changed
+9
@@ -666,6 +666,15 @@ OSAllocator_64Bit::OSAllocator_64Bit() {
LiveRegions = ObjectAlloc->new_construct(LiveRegions, ObjectAlloc);
}
else {
// If the allocation size is large than a page, then try allowing it to be a huge page
// This enables the kernel to use transparent large pages in the allocator which can reduce memory pressure
// Considering we are allocating the entire VA space, this is a good thing
// If MADV_HUGEPAGE isn't support then this will fail harmlessly
if (AllocationSize > 4096) {
::madvise(Ptr, AllocationSize, MADV_HUGEPAGE);
}
bool Merged = false;
if (PrevReserved) {
Merged = MergeReservedRegionIfPossible(PrevReserved, reinterpret_cast<uint64_t>(Ptr), AllocationSize);