mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-21 03:55:32 +00:00
vm_native.cpp: add MADV_HUGEPAGE
It enables Transparend Huge Pages for some regions on Linux. Although it can't be actively useful, it seems to do something. Maybe it's even harmful for recompilers.
This commit is contained in:
parent
27097cbcfe
commit
ab248e170c
1 changed files with 15 additions and 1 deletions
|
@ -74,6 +74,8 @@ namespace utils
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const auto orig_size = size;
|
||||
|
||||
if (!use_addr)
|
||||
{
|
||||
// Hack: Ensure aligned 64k allocations
|
||||
|
@ -107,6 +109,11 @@ namespace utils
|
|||
ptr = static_cast<u8*>(ptr) + (0x10000 - misalign);
|
||||
}
|
||||
|
||||
#ifdef MADV_HUGEPAGE
|
||||
if (orig_size % 0x200000 == 0)
|
||||
verify(HERE), ::madvise(ptr, orig_size, MADV_HUGEPAGE) != -1;
|
||||
#endif
|
||||
|
||||
return ptr;
|
||||
#endif
|
||||
}
|
||||
|
@ -151,6 +158,11 @@ namespace utils
|
|||
#endif
|
||||
verify(HERE), ::mmap(pointer, size, +prot, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0) != reinterpret_cast<void*>(-1);
|
||||
verify(HERE), ::madvise(reinterpret_cast<void*>(ptr64 & -4096), size + (ptr64 & 4095), MADV_WILLNEED) != -1;
|
||||
|
||||
#ifdef MADV_HUGEPAGE
|
||||
if (size % 0x200000 == 0)
|
||||
verify(HERE), ::madvise(reinterpret_cast<void*>(ptr64 & -4096), size + (ptr64 & 4095), MADV_HUGEPAGE) != -1;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -273,7 +285,9 @@ namespace utils
|
|||
|
||||
if (ptr64)
|
||||
{
|
||||
return reinterpret_cast<u8*>(reinterpret_cast<u64>(::mmap(reinterpret_cast<void*>(ptr64), m_size, +prot, MAP_SHARED | MAP_FIXED, m_file, 0)));
|
||||
const auto result = ::mmap(reinterpret_cast<void*>(ptr64), m_size, +prot, MAP_SHARED | MAP_FIXED, m_file, 0);
|
||||
|
||||
return reinterpret_cast<u8*>(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue