summaryrefslogtreecommitdiff
path: root/Kernel/MemoryManager.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-12-31 15:18:02 +0100
committerAndreas Kling <awesomekling@gmail.com>2018-12-31 15:18:02 +0100
commit3e37a1f5c3822382b19384d5ac11c12b830b782b (patch)
treee5f7cdcf2268b3f3247830aa2b3646bf21b77f96 /Kernel/MemoryManager.cpp
parentedac1d6748edec57256ae336e3847999aecf694d (diff)
downloadserenity-3e37a1f5c3822382b19384d5ac11c12b830b782b.zip
Optimize PageDirectory destruction.
Remove an extra hash lookup and only iterate over the actually-used PhysicalPages that we need to clean up.
Diffstat (limited to 'Kernel/MemoryManager.cpp')
-rw-r--r--Kernel/MemoryManager.cpp18
1 files changed, 4 insertions, 14 deletions
diff --git a/Kernel/MemoryManager.cpp b/Kernel/MemoryManager.cpp
index e7d02b944d..fb0e929474 100644
--- a/Kernel/MemoryManager.cpp
+++ b/Kernel/MemoryManager.cpp
@@ -106,14 +106,6 @@ RetainPtr<PhysicalPage> MemoryManager::allocate_page_table(PageDirectory& page_d
return physical_page;
}
-void MemoryManager::deallocate_page_table(PageDirectory& page_directory, unsigned index)
-{
- auto it = page_directory.m_physical_pages.find(index);
- ASSERT(it != page_directory.m_physical_pages.end());
- remove_identity_mapping(LinearAddress((*it).value->paddr().get()), PAGE_SIZE);
- page_directory.m_physical_pages.set(index, nullptr);
-}
-
void MemoryManager::remove_identity_mapping(LinearAddress laddr, size_t size)
{
InterruptDisabler disabler;
@@ -796,13 +788,11 @@ PageDirectory::~PageDirectory()
#ifdef MM_DEBUG
dbgprintf("MM: ~PageDirectory K%x\n", this);
#endif
- for (size_t i = 0; i < 1024; ++i) {
- auto page_table = m_physical_pages.get(i);
- if (!page_table.is_null()) {
+ for (auto& it : m_physical_pages) {
+ auto& page_table = *it.value;
#ifdef MM_DEBUG
- dbgprintf("MM: deallocating user page table P%x\n", page_table->paddr().get());
+ dbgprintf("MM: deallocating user page table P%x\n", page_table.paddr().get());
#endif
- MM.deallocate_page_table(*this, i);
- }
+ MM.remove_identity_mapping(LinearAddress(page_table.paddr().get()), PAGE_SIZE);
}
}