Skip to content

Commit

Permalink
Kernel/Memory: Fix overcommit when cloning anonymous mmap objects
Browse files Browse the repository at this point in the history
AnonymousVMObject::try_clone() computed how many shared cow pages to
commit by counting all VMObject pages that were not shared_zero_pages.

This means that lazy_committed_pages were also being included in the
count. This is a problem because the page fault handling code for
lazy_committed_pages does not allocate from
m_shared_committed_cow_pages. So more pages than necessary were being
committed.

This fixes this overcommitting problem by skipping lazy_committed_pages
when counting how many pages to commit.
  • Loading branch information
brody-qq authored and nico committed Jul 12, 2024
1 parent 1ac1db5 commit 2a164dc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Kernel/Memory/AnonymousVMObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ErrorOr<NonnullLockRefPtr<VMObject>> AnonymousVMObject::try_clone()
// non-volatile memory available.
size_t new_cow_pages_needed = 0;
for (auto const& page : m_physical_pages) {
if (!page->is_shared_zero_page())
if (!page->is_shared_zero_page() && !page->is_lazy_committed_page())
++new_cow_pages_needed;
}

Expand Down

0 comments on commit 2a164dc

Please sign in to comment.