1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:48:10 +00:00

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.
This commit is contained in:
Andreas Kling 2022-04-05 01:07:23 +02:00
parent e3e1d79a7d
commit f0f97e1db0
4 changed files with 21 additions and 3 deletions

View file

@ -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(),