diff options
author | Tom <tomut@yahoo.com> | 2021-07-07 20:28:51 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-08 11:43:34 +0200 |
commit | c1006a368916e2070eba55937765d5bd0a1a6807 (patch) | |
tree | ac5c0aa09023fc9b66dca811ae45bd206a8ae0ee /Kernel/VM/MemoryManager.cpp | |
parent | 87dc4c3d2c21762d85c77b7b9588ff889cafb5ac (diff) | |
download | serenity-c1006a368916e2070eba55937765d5bd0a1a6807.zip |
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.
Diffstat (limited to 'Kernel/VM/MemoryManager.cpp')
-rw-r--r-- | Kernel/VM/MemoryManager.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp index 2d8754b7b5..fb3b0a5451 100644 --- a/Kernel/VM/MemoryManager.cpp +++ b/Kernel/VM/MemoryManager.cpp @@ -728,14 +728,14 @@ void MemoryManager::uncommit_user_physical_pages(size_t page_count) m_system_memory_info.user_physical_pages_committed -= page_count; } -void MemoryManager::deallocate_user_physical_page(const PhysicalPage& page) +void MemoryManager::deallocate_user_physical_page(PhysicalAddress paddr) { ScopedSpinLock lock(s_mm_lock); for (auto& region : m_user_physical_regions) { - if (!region.contains(page)) + if (!region.contains(paddr)) continue; - region.return_page(page); + region.return_page(paddr); --m_system_memory_info.user_physical_pages_used; // Always return pages to the uncommitted pool. Pages that were @@ -745,7 +745,7 @@ void MemoryManager::deallocate_user_physical_page(const PhysicalPage& page) return; } - dmesgln("MM: deallocate_user_physical_page couldn't figure out region for user page @ {}", page.paddr()); + dmesgln("MM: deallocate_user_physical_page couldn't figure out region for user page @ {}", paddr); VERIFY_NOT_REACHED(); } @@ -825,21 +825,21 @@ RefPtr<PhysicalPage> MemoryManager::allocate_user_physical_page(ShouldZeroFill s return page; } -void MemoryManager::deallocate_supervisor_physical_page(const PhysicalPage& page) +void MemoryManager::deallocate_supervisor_physical_page(PhysicalAddress paddr) { ScopedSpinLock lock(s_mm_lock); for (auto& region : m_super_physical_regions) { - if (!region.contains(page)) { - dbgln("MM: deallocate_supervisor_physical_page: {} not in {} - {}", page.paddr(), region.lower(), region.upper()); + if (!region.contains(paddr)) { + dbgln("MM: deallocate_supervisor_physical_page: {} not in {} - {}", paddr, region.lower(), region.upper()); continue; } - region.return_page(page); + region.return_page(paddr); --m_system_memory_info.super_physical_pages_used; return; } - dbgln("MM: deallocate_supervisor_physical_page couldn't figure out region for super page @ {}", page.paddr()); + dbgln("MM: deallocate_supervisor_physical_page couldn't figure out region for super page @ {}", paddr); VERIFY_NOT_REACHED(); } |