From a66544f3f4ad97312ac0b00b2f347d4f1b63ef16 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Fri, 8 May 2026 16:27:04 -0700 Subject: [PATCH] Allocator: Mark large unmapped regions as DONTDUMP coredump applications aren't smart enough to only dump resident pages, so explicitly mark our 128TB and other mapped VA ranges as DONTDUMP. This will speed up coredumps. --- FEXCore/Source/Utils/Allocator.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/FEXCore/Source/Utils/Allocator.cpp b/FEXCore/Source/Utils/Allocator.cpp index 5cad9c014..3d9944a6e 100644 --- a/FEXCore/Source/Utils/Allocator.cpp +++ b/FEXCore/Source/Utils/Allocator.cpp @@ -262,9 +262,19 @@ fextl::vector StealMemoryRegion(uintptr_t Begin, uintptr_t End) { } // Block remaining memory gaps + bool SupportsDontDump = true; for (auto RegionIt = Regions.begin(); RegionIt != Regions.end(); ++RegionIt) { auto Alloc = ::mmap(RegionIt->Ptr, RegionIt->Size, PROT_NONE, MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE | MAP_FIXED_NOREPLACE, -1, 0); + if (SupportsDontDump) { + // Mark these regions as don't dump so that coredump doesn't try dumping large unmapped regions. + // Ideally coredump would be smart enough to only dump resident pages, but here we are. + auto Result = madvise(RegionIt->Ptr, RegionIt->Size, MADV_DONTDUMP); + if (Result == -1) { + SupportsDontDump = false; + } + } + LogMan::Throw::AFmt(Alloc != MAP_FAILED, "StealMemoryRegion: mmap({}, {:x}) failed: {}", fmt::ptr(RegionIt->Ptr), RegionIt->Size, errno); LogMan::Throw::AFmt(Alloc == RegionIt->Ptr, "mmap returned {} instead of {}", Alloc, fmt::ptr(RegionIt->Ptr)); }