Kernel: Release page directory and MM locks sooner in space finalization

We don't need to hold these locks when tearing down the region tree.
Release them as soon as unmapping is finished.
This commit is contained in:
Andreas Kling 2022-01-30 16:07:59 +01:00
parent fcd3844da6
commit a44316fa8b
Notes: sideshowbarker 2024-07-17 19:59:34 +09:00

View file

@ -321,10 +321,12 @@ void AddressSpace::remove_all_regions(Badge<Process>)
{
VERIFY(Thread::current() == g_finalizer);
SpinlockLocker locker(m_lock);
SpinlockLocker pd_locker(m_page_directory->get_lock());
SpinlockLocker mm_locker(s_mm_lock);
for (auto& region : m_regions)
(*region).unmap_with_locks_held(Region::ShouldDeallocateVirtualRange::No, ShouldFlushTLB::No, pd_locker, mm_locker);
{
SpinlockLocker pd_locker(m_page_directory->get_lock());
SpinlockLocker mm_locker(s_mm_lock);
for (auto& region : m_regions)
(*region).unmap_with_locks_held(Region::ShouldDeallocateVirtualRange::No, ShouldFlushTLB::No, pd_locker, mm_locker);
}
m_regions.clear();
}