Kernel: Add CoW support to MemoryBackedRegion

This speeds up fork by A LOT. Forking WindowServer took ~90 ms before
this and now its ~5 ms.
This commit is contained in:
2026-04-03 01:54:59 +03:00
parent c09bca56f9
commit 675c215e6a
2 changed files with 105 additions and 31 deletions

View File

@@ -28,6 +28,20 @@ namespace Kernel
private:
MemoryBackedRegion(PageTable&, size_t size, Type, PageTable::flags_t, int status_flags);
private:
struct PhysicalPage
{
PhysicalPage(paddr_t paddr)
: paddr(paddr)
{ }
~PhysicalPage();
BAN::Atomic<uint32_t> ref_count { 1 };
const paddr_t paddr;
};
BAN::Vector<PhysicalPage*> m_physical_pages;
Mutex m_mutex;
};
}