Browse Source

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.
Andreas Kling 3 years ago
parent
commit
a44316fa8b
1 changed files with 6 additions and 4 deletions
  1. 6 4
      Kernel/Memory/AddressSpace.cpp

+ 6 - 4
Kernel/Memory/AddressSpace.cpp

@@ -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();
 }