diff options
author | Andreas Kling <kling@serenityos.org> | 2022-04-05 01:07:23 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-05 01:15:22 +0200 |
commit | f0f97e1db028050a5014a6950a4a5c43bd424aff (patch) | |
tree | 4b7e1c79a41e8794e60fef057b5d620a3ff3416a /Kernel/Memory/MemoryManager.cpp | |
parent | e3e1d79a7d92b931892ecbe26761363b41cf6e96 (diff) | |
download | serenity-f0f97e1db028050a5014a6950a4a5c43bd424aff.zip |
Kernel: Take the RegionTree spinlock when inspecting tree from outside
This patch adds RegionTree::get_lock() which exposes the internal lock
inside RegionTree. We can then lock it from the outside when doing
lookups or traversal.
This solution is not very beautiful, we should find a way to protect
this data with SpinlockProtected or something similar. This is a stopgap
patch to try and fix the currently flaky CI.
Diffstat (limited to 'Kernel/Memory/MemoryManager.cpp')
-rw-r--r-- | Kernel/Memory/MemoryManager.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Kernel/Memory/MemoryManager.cpp b/Kernel/Memory/MemoryManager.cpp index e6cc5b7d74..7bce3b3504 100644 --- a/Kernel/Memory/MemoryManager.cpp +++ b/Kernel/Memory/MemoryManager.cpp @@ -664,6 +664,8 @@ Region* MemoryManager::kernel_region_from_vaddr(VirtualAddress vaddr) return nullptr; SpinlockLocker lock(s_mm_lock); + SpinlockLocker tree_locker(MM.m_region_tree.get_lock()); + auto* region = MM.m_region_tree.regions().find_largest_not_above(vaddr.get()); if (!region || !region->contains(vaddr)) return nullptr; @@ -1167,6 +1169,7 @@ void MemoryManager::unregister_kernel_region(Region& region) { VERIFY(region.is_kernel()); SpinlockLocker lock(s_mm_lock); + SpinlockLocker tree_locker(m_region_tree.get_lock()); m_region_tree.regions().remove(region.vaddr().get()); } @@ -1181,6 +1184,7 @@ void MemoryManager::dump_kernel_regions() dbgln("BEGIN{} END{} SIZE{} ACCESS NAME", addr_padding, addr_padding, addr_padding); SpinlockLocker lock(s_mm_lock); + SpinlockLocker tree_locker(m_region_tree.get_lock()); for (auto const& region : m_region_tree.regions()) { dbgln("{:p} -- {:p} {:p} {:c}{:c}{:c}{:c}{:c}{:c} {}", region.vaddr().get(), |