mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:07:35 +00:00
Kernel: Return an already destructed PhysicalPage to the allocators
By making sure the PhysicalPage instance is fully destructed the allocators will have a chance to reclaim the PhysicalPageEntry for free-list purposes. Just pass them the physical address of the page that was freed, which is enough to lookup the PhysicalPageEntry later.
This commit is contained in:
parent
87dc4c3d2c
commit
c1006a3689
6 changed files with 32 additions and 28 deletions
|
@ -27,14 +27,21 @@ PhysicalAddress PhysicalPage::paddr() const
|
|||
return MM.get_physical_address(*this);
|
||||
}
|
||||
|
||||
void PhysicalPage::return_to_freelist() const
|
||||
void PhysicalPage::free_this()
|
||||
{
|
||||
VERIFY((paddr().get() & ~PAGE_MASK) == 0);
|
||||
if (m_may_return_to_freelist) {
|
||||
auto paddr = MM.get_physical_address(*this);
|
||||
bool is_supervisor = m_supervisor;
|
||||
|
||||
if (m_supervisor)
|
||||
MM.deallocate_supervisor_physical_page(*this);
|
||||
else
|
||||
MM.deallocate_user_physical_page(*this);
|
||||
this->~PhysicalPage(); // delete in place
|
||||
|
||||
if (is_supervisor)
|
||||
MM.deallocate_supervisor_physical_page(paddr);
|
||||
else
|
||||
MM.deallocate_user_physical_page(paddr);
|
||||
} else {
|
||||
this->~PhysicalPage(); // delete in place
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue