mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:28:12 +00:00
Kernel: Detach AnonymousVMObject from shared COW pages set once emptied
We currently overcommit for COW when forking a process and cloning its memory regions. Both the parent and child process share a set of. committed COW pages. If there's COW sharing across more than two processeses within a lineage (e.g parent, child & grandchild), it's possible to exhaust these pages. When the shared set is emptied, the next COW fault in each process must detach from the shared set and fall back to on demand allocation. This patch makes sure that we detach from the shared set once we discover it to be empty (during COW fault handling). This fixes an issue where we'd try to allocate from an exhausted shared set while building GNU binutils inside SerenityOS.
This commit is contained in:
parent
89a9ae7d0c
commit
843d0d0d15
1 changed files with 5 additions and 6 deletions
|
@ -307,15 +307,14 @@ PageFaultResponse AnonymousVMObject::handle_cow_fault(size_t page_index, Virtual
|
|||
|
||||
auto& page_slot = physical_pages()[page_index];
|
||||
|
||||
// If we were sharing committed COW pages with another process, and the other process
|
||||
// has exhausted the supply, we can stop counting the shared pages.
|
||||
if (m_shared_committed_cow_pages && m_shared_committed_cow_pages->is_empty())
|
||||
m_shared_committed_cow_pages = nullptr;
|
||||
|
||||
if (page_slot->ref_count() == 1) {
|
||||
dbgln_if(PAGE_FAULT_DEBUG, " >> It's a COW page but nobody is sharing it anymore. Remap r/w");
|
||||
set_should_cow(page_index, false);
|
||||
|
||||
// If we were sharing committed COW pages with another process, and the other process
|
||||
// has exhausted the supply, we can stop counting the shared pages.
|
||||
if (m_shared_committed_cow_pages && m_shared_committed_cow_pages->is_empty())
|
||||
m_shared_committed_cow_pages = nullptr;
|
||||
|
||||
return PageFaultResponse::Continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue