mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 23:27:42 +00:00
Only COW on fault if the physical page has retain_count > 1.
This makes COW pages lazily-but-transparently revert back to read/write.
This commit is contained in:
parent
2d045d2a64
commit
9e62eb4856
4 changed files with 17 additions and 2 deletions
|
@ -223,6 +223,16 @@ Region* MemoryManager::region_from_laddr(Process& process, LinearAddress laddr)
|
|||
|
||||
bool MemoryManager::copy_on_write(Process& process, Region& region, unsigned page_index_in_region)
|
||||
{
|
||||
ASSERT_INTERRUPTS_DISABLED();
|
||||
if (region.physical_pages[page_index_in_region]->retain_count() == 1) {
|
||||
#ifdef PAGE_FAULT_DEBUG
|
||||
dbgprintf(" >> It's a COW page but nobody is sharing it anymore. Remap r/w\n");
|
||||
#endif
|
||||
region.cow_map.set(page_index_in_region, false);
|
||||
remap_region_page(process.m_page_directory, region, page_index_in_region, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef PAGE_FAULT_DEBUG
|
||||
dbgprintf(" >> It's a COW page and it's time to COW!\n");
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue