1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 08:28:11 +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:
Tom 2021-07-07 20:28:51 -06:00 committed by Andreas Kling
parent 87dc4c3d2c
commit c1006a3689
6 changed files with 32 additions and 28 deletions

View file

@ -172,7 +172,7 @@ void PhysicalRegion::free_page_at(PhysicalAddress addr)
m_used--;
}
void PhysicalRegion::return_page(const PhysicalPage& page)
void PhysicalRegion::return_page(PhysicalAddress paddr)
{
auto returned_count = m_recently_returned.size();
if (returned_count >= m_recently_returned.capacity()) {
@ -180,10 +180,10 @@ void PhysicalRegion::return_page(const PhysicalPage& page)
// and replace the entry with this page
auto& entry = m_recently_returned[get_fast_random<u8>()];
free_page_at(entry);
entry = page.paddr();
entry = paddr;
} else {
// Still filling the return queue, just append it
m_recently_returned.append(page.paddr());
m_recently_returned.append(paddr);
}
}