mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 17:55:08 +00:00
Kernel: Uncommit a shared COW page when discovering it was unshared
When we hit a COW fault and discover than no other process is sharing
the physical page, we simply remap it r/w and save ourselves the
trouble. When this happens, we can also give back (uncommit) one of our
shared committed COW pages, since we won't be needing it.
We had this optimization before, but I mistakenly removed it in
50472fd69f
since I had misunderstood
it to be the reason for a panic.
This commit is contained in:
parent
843d0d0d15
commit
dd58d0f650
4 changed files with 23 additions and 1 deletions
|
@ -315,6 +315,12 @@ PageFaultResponse AnonymousVMObject::handle_cow_fault(size_t page_index, Virtual
|
|||
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 (m_shared_committed_cow_pages) {
|
||||
m_shared_committed_cow_pages->uncommit_one();
|
||||
if (!m_shared_committed_cow_pages->is_empty())
|
||||
m_shared_committed_cow_pages = nullptr;
|
||||
}
|
||||
return PageFaultResponse::Continue;
|
||||
}
|
||||
|
||||
|
@ -368,4 +374,10 @@ NonnullRefPtr<PhysicalPage> AnonymousVMObject::SharedCommittedCowPages::take_one
|
|||
return m_committed_pages.take_one();
|
||||
}
|
||||
|
||||
void AnonymousVMObject::SharedCommittedCowPages::uncommit_one()
|
||||
{
|
||||
ScopedSpinLock locker(m_lock);
|
||||
m_committed_pages.uncommit_one();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue