VM: Pass a PhysicalPage by rvalue reference when returning it to the freelist.

This makes no functional difference, but it makes it clear that
MemoryManager and PhysicalRegion take over the actual physical
page represented by this PhysicalPage instance.
This commit is contained in:
Sergey Bugaev 2019-06-14 14:56:21 +03:00 committed by Andreas Kling
parent 7710e48d83
commit 118cb391dd
Notes: sideshowbarker 2024-07-19 13:36:55 +09:00
5 changed files with 12 additions and 12 deletions

View File

@ -458,7 +458,7 @@ RetainPtr<Region> MemoryManager::allocate_kernel_region(size_t size, String&& na
return region;
}
void MemoryManager::deallocate_user_physical_page(PhysicalPage& page)
void MemoryManager::deallocate_user_physical_page(PhysicalPage&& page)
{
for (auto& region : m_user_physical_regions) {
if (!region->contains(page)) {
@ -468,7 +468,7 @@ void MemoryManager::deallocate_user_physical_page(PhysicalPage& page)
continue;
}
region->return_page(page);
region->return_page(move(page));
m_user_physical_pages_used--;
return;
@ -515,7 +515,7 @@ RetainPtr<PhysicalPage> MemoryManager::allocate_user_physical_page(ShouldZeroFil
return page;
}
void MemoryManager::deallocate_supervisor_physical_page(PhysicalPage& page)
void MemoryManager::deallocate_supervisor_physical_page(PhysicalPage&& page)
{
for (auto& region : m_super_physical_regions) {
if (!region->contains(page)) {
@ -525,7 +525,7 @@ void MemoryManager::deallocate_supervisor_physical_page(PhysicalPage& page)
continue;
}
region->return_page(page);
region->return_page(move(page));
m_super_physical_pages_used--;
return;

View File

@ -63,8 +63,8 @@ public:
RetainPtr<PhysicalPage> allocate_user_physical_page(ShouldZeroFill);
RetainPtr<PhysicalPage> allocate_supervisor_physical_page();
void deallocate_user_physical_page(PhysicalPage&);
void deallocate_supervisor_physical_page(PhysicalPage&);
void deallocate_user_physical_page(PhysicalPage&&);
void deallocate_supervisor_physical_page(PhysicalPage&&);
void remap_region(PageDirectory&, Region&);

View File

@ -23,7 +23,7 @@ PhysicalPage::PhysicalPage(PhysicalAddress paddr, bool supervisor, bool may_retu
{
}
void PhysicalPage::return_to_freelist()
void PhysicalPage::return_to_freelist() &&
{
ASSERT((paddr().get() & ~PAGE_MASK) == 0);
@ -32,9 +32,9 @@ void PhysicalPage::return_to_freelist()
m_retain_count = 1;
if (m_supervisor)
MM.deallocate_supervisor_physical_page(*this);
MM.deallocate_supervisor_physical_page(move(*this));
else
MM.deallocate_user_physical_page(*this);
MM.deallocate_user_physical_page(move(*this));
#ifdef MM_DEBUG
dbgprintf("MM: P%x released to freelist\n", m_paddr.get());

View File

@ -23,7 +23,7 @@ public:
ASSERT(m_retain_count);
if (!--m_retain_count) {
if (m_may_return_to_freelist)
return_to_freelist();
move(*this).return_to_freelist();
else
delete this;
}
@ -38,7 +38,7 @@ private:
PhysicalPage(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist = true);
~PhysicalPage() {}
void return_to_freelist();
void return_to_freelist() &&;
word m_retain_count { 1 };
bool m_may_return_to_freelist { true };

View File

@ -25,7 +25,7 @@ public:
RetainPtr<PhysicalPage> take_free_page(bool supervisor);
void return_page_at(PhysicalAddress addr);
void return_page(PhysicalPage& page) { return_page_at(page.paddr()); }
void return_page(PhysicalPage&& page) { return_page_at(page.paddr()); }
private:
PhysicalRegion(PhysicalAddress lower, PhysicalAddress upper);