mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 15:16:14 +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:
@@ -145,7 +145,9 @@ Region* Process::allocate_region(const Range& range, const String& name, int pro
|
||||
{
|
||||
ASSERT(range.is_valid());
|
||||
auto vmobject = PurgeableVMObject::create_with_size(range.size());
|
||||
auto region = Region::create_user_accessible(this, range, vmobject, 0, name, prot_to_region_access_flags(prot));
|
||||
if (!vmobject)
|
||||
return nullptr;
|
||||
auto region = Region::create_user_accessible(this, range, vmobject.release_nonnull(), 0, name, prot_to_region_access_flags(prot));
|
||||
if (!region->map(page_directory()))
|
||||
return nullptr;
|
||||
if (should_commit && region->can_commit() && !region->commit())
|
||||
|
||||
Reference in New Issue
Block a user