1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:07:35 +00:00

Optimize PageDirectory destruction.

Remove an extra hash lookup and only iterate over the actually-used
PhysicalPages that we need to clean up.
This commit is contained in:
Andreas Kling 2018-12-31 15:18:02 +01:00
parent edac1d6748
commit 3e37a1f5c3
2 changed files with 4 additions and 15 deletions

View file

@ -106,14 +106,6 @@ RetainPtr<PhysicalPage> MemoryManager::allocate_page_table(PageDirectory& page_d
return physical_page; 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) void MemoryManager::remove_identity_mapping(LinearAddress laddr, size_t size)
{ {
InterruptDisabler disabler; InterruptDisabler disabler;
@ -796,13 +788,11 @@ PageDirectory::~PageDirectory()
#ifdef MM_DEBUG #ifdef MM_DEBUG
dbgprintf("MM: ~PageDirectory K%x\n", this); dbgprintf("MM: ~PageDirectory K%x\n", this);
#endif #endif
for (size_t i = 0; i < 1024; ++i) { for (auto& it : m_physical_pages) {
auto page_table = m_physical_pages.get(i); auto& page_table = *it.value;
if (!page_table.is_null()) {
#ifdef MM_DEBUG #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 #endif
MM.deallocate_page_table(*this, i); MM.remove_identity_mapping(LinearAddress(page_table.paddr().get()), PAGE_SIZE);
}
} }
} }

View file

@ -208,7 +208,6 @@ private:
void flush_tlb(LinearAddress); void flush_tlb(LinearAddress);
RetainPtr<PhysicalPage> allocate_page_table(PageDirectory&, unsigned index); RetainPtr<PhysicalPage> allocate_page_table(PageDirectory&, unsigned index);
void deallocate_page_table(PageDirectory&, unsigned index);
void map_protected(LinearAddress, size_t length); void map_protected(LinearAddress, size_t length);