From 9cb9f4c21e32746429fc7bbb9e626c60fda69233 Mon Sep 17 00:00:00 2001 From: DH Date: Sun, 30 Nov 2025 19:33:42 +0300 Subject: [PATCH] orbis: vmem: merge direct regions merge anonymous regions --- kernel/orbis/src/vmem.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/kernel/orbis/src/vmem.cpp b/kernel/orbis/src/vmem.cpp index dadf38b77..b83c987dd 100644 --- a/kernel/orbis/src/vmem.cpp +++ b/kernel/orbis/src/vmem.cpp @@ -56,14 +56,24 @@ struct VirtualMemoryAllocation { isRelated(const VirtualMemoryAllocation &other, rx::AddressRange selfRange, [[maybe_unused]] rx::AddressRange rightRange) const { if (flags != other.flags || flagsEx != other.flagsEx || - prot != other.prot || type != other.type || device != other.device || - name != other.name) { + prot != other.prot || type != other.type || device != other.device) { return false; } + if (!isAllocated()) { return true; } + bool isAnon = std::string_view(name).starts_with("anon:"); + + if (isAnon) { + if (!std::string_view(other.name).starts_with("anon:")) { + return false; + } + } else if (name != other.name) { + return false; + } + if (device == nullptr || flags == orbis::vmem::BlockFlags::PooledMemory) { return true; } @@ -450,8 +460,6 @@ std::pair orbis::vmem::mapFile( return {{}, ErrorCode::INVAL}; } - allocFlags |= AllocationFlags::NoMerge; - if (prot) { blockFlags |= BlockFlags::Commited; }