Kernel: Stop committing pages for COW of uncommitted pages on sys$fork

Uncommitted pages (shared zero pages) can not contain any existing data
and can not be modified, so there's no point to committing a bunch of
extra pages to cover for them in the forked child.
This commit is contained in:
Idan Horowitz 2022-07-10 17:58:02 +03:00 committed by Andreas Kling
parent 38696dc626
commit 8717e78918
Notes: sideshowbarker 2024-07-18 02:13:10 +09:00

View file

@ -31,7 +31,14 @@ ErrorOr<NonnullRefPtr<VMObject>> AnonymousVMObject::try_clone()
// commit the number of pages that we need to potentially allocate
// so that the parent is still guaranteed to be able to have all
// non-volatile memory available.
size_t new_cow_pages_needed = page_count();
size_t new_cow_pages_needed = 0;
for (auto const& page : m_physical_pages) {
if (!page->is_shared_zero_page())
++new_cow_pages_needed;
}
if (new_cow_pages_needed == 0)
return TRY(try_create_with_size(size(), AllocationStrategy::None));
dbgln_if(COMMIT_DEBUG, "Cloning {:p}, need {} committed cow pages", this, new_cow_pages_needed);