diff --git a/FEXCore/Source/Interface/Core/CPUBackend.cpp b/FEXCore/Source/Interface/Core/CPUBackend.cpp index 7e30d712f..2a6d2b8d0 100644 --- a/FEXCore/Source/Interface/Core/CPUBackend.cpp +++ b/FEXCore/Source/Interface/Core/CPUBackend.cpp @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT #include "FEXCore/IR/IR.h" #include "FEXCore/Utils/AllocatorHooks.h" +#include "Utils/PrctlUtils.h" #include "Interface/Context/Context.h" #include "Interface/Core/CPUBackend.h" #include "Interface/Core/Dispatcher/Dispatcher.h" @@ -9,6 +10,7 @@ #include "LookupCache.h" #ifndef _WIN32 +#include #include #endif @@ -357,6 +359,10 @@ namespace CPU { LogMan::Msg::EFmt("Failed to mprotect last page of code buffer."); } +#ifndef _WIN32 + prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, Ptr, Size, "FEXMemJIT"); +#endif + LookupCache = fextl::make_unique(); } diff --git a/FEXCore/Source/Utils/Allocator.cpp b/FEXCore/Source/Utils/Allocator.cpp index 062cdd444..47ccf59cb 100644 --- a/FEXCore/Source/Utils/Allocator.cpp +++ b/FEXCore/Source/Utils/Allocator.cpp @@ -1,5 +1,6 @@ // SPDX-License-Identifier: MIT #include "Utils/Allocator/HostAllocator.h" +#include "Utils/PrctlUtils.h" #include #include #include @@ -50,6 +51,10 @@ void* FEX_mmap(void* addr, size_t length, int prot, int flags, int fd, off_t off errno = -(uint64_t)Result; return (void*)-1; } + + if (flags & MAP_ANONYMOUS) { + prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, Result, length, "FEXMem"); + } return Result; } int FEX_munmap(void* addr, size_t length) { diff --git a/FEXCore/Source/Utils/PrctlUtils.h b/FEXCore/Source/Utils/PrctlUtils.h new file mode 100644 index 000000000..fdbe9238e --- /dev/null +++ b/FEXCore/Source/Utils/PrctlUtils.h @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: MIT +#pragma once + +#ifndef _WIN32 +#include +#include +#include +#include + +#ifndef PR_SET_VMA +#define PR_SET_VMA 0x53564d41 +#endif + +#ifndef PR_SET_VMA_ANON_NAME +#define PR_SET_VMA_ANON_NAME 0 +#endif +#endif