summaryrefslogtreecommitdiff
path: root/Kernel/Memory
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-01-30 16:07:59 +0100
committerAndreas Kling <kling@serenityos.org>2022-01-30 16:21:59 +0100
commita44316fa8b43aa346e0ccb9e8e5a15a8371c9bfc (patch)
treec3b4bb682609263e09f0ba9c97e95784429bda5e /Kernel/Memory
parentfcd3844da6159e796d14a588ac058f5674d8b7c6 (diff)
downloadserenity-a44316fa8b43aa346e0ccb9e8e5a15a8371c9bfc.zip
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.
Diffstat (limited to 'Kernel/Memory')
-rw-r--r--Kernel/Memory/AddressSpace.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/Kernel/Memory/AddressSpace.cpp b/Kernel/Memory/AddressSpace.cpp
index a4379186b8..ea47ee91a3 100644
--- a/Kernel/Memory/AddressSpace.cpp
+++ b/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();
}