mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 10:00:16 +02:00
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.
This commit is contained in:
1 file changed
+10
@@ -262,9 +262,19 @@ fextl::vector<MemoryRegion> 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));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user