1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:58:11 +00:00

Kernel: Implement lazy committed page allocation

By designating a committed page pool we can guarantee to have physical
pages available for lazy allocation in mappings. However, when forking
we will overcommit. The assumption is that worst-case it's better for
the fork to die due to insufficient physical memory on COW access than
the parent that created the region. If a fork wants to ensure that all
memory is available (trigger a commit) then it can use madvise.

This also means that fork now can gracefully fail if we don't have
enough physical pages available.
This commit is contained in:
Tom 2020-09-04 21:12:25 -06:00 committed by Andreas Kling
parent e21cc4cff6
commit b2a52f6208
20 changed files with 329 additions and 67 deletions

View file

@ -51,13 +51,15 @@ NonnullRefPtr<AnonymousVMObject> AnonymousVMObject::create_with_physical_page(Ph
return vmobject;
}
AnonymousVMObject::AnonymousVMObject(size_t size)
AnonymousVMObject::AnonymousVMObject(size_t size, bool initialize_pages)
: VMObject(size)
{
if (initialize_pages) {
#ifndef MAP_SHARED_ZERO_PAGE_LAZILY
for (size_t i = 0; i < page_count(); ++i)
physical_pages()[i] = MM.shared_zero_page();
for (size_t i = 0; i < page_count(); ++i)
physical_pages()[i] = MM.shared_zero_page();
#endif
}
}
AnonymousVMObject::AnonymousVMObject(PhysicalAddress paddr, size_t size)
@ -77,9 +79,14 @@ AnonymousVMObject::~AnonymousVMObject()
{
}
NonnullRefPtr<VMObject> AnonymousVMObject::clone()
RefPtr<VMObject> AnonymousVMObject::clone()
{
return adopt(*new AnonymousVMObject(*this));
}
RefPtr<PhysicalPage> AnonymousVMObject::allocate_committed_page(size_t)
{
return {};
}
}