1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:57:45 +00:00

Kernel: Wrap RegionTree objects in SpinlockProtected

This makes locking them much more straightforward, and we can remove
a bunch of confusing use of AddressSpace::m_lock. That lock will also
be converted to use of SpinlockProtected in a subsequent patch.
This commit is contained in:
Andreas Kling 2022-08-23 12:28:04 +02:00
parent 352d6545a9
commit dc9d2c1b10
9 changed files with 251 additions and 234 deletions

View file

@ -10,6 +10,7 @@
#include <AK/RedBlackTree.h>
#include <AK/Vector.h>
#include <Kernel/Library/LockWeakPtr.h>
#include <Kernel/Locking/SpinlockProtected.h>
#include <Kernel/Memory/AllocationStrategy.h>
#include <Kernel/Memory/PageDirectory.h>
#include <Kernel/Memory/Region.h>
@ -26,8 +27,8 @@ public:
PageDirectory& page_directory() { return *m_page_directory; }
PageDirectory const& page_directory() const { return *m_page_directory; }
auto& regions() { return m_region_tree.regions(); }
auto const& regions() const { return m_region_tree.regions(); }
SpinlockProtected<RegionTree>& region_tree() { return m_region_tree; }
SpinlockProtected<RegionTree> const& region_tree() const { return m_region_tree; }
void dump_regions();
@ -62,8 +63,6 @@ public:
size_t amount_purgeable_volatile() const;
size_t amount_purgeable_nonvolatile() const;
auto& region_tree() { return m_region_tree; }
private:
AddressSpace(NonnullLockRefPtr<PageDirectory>, VirtualRange total_range);
@ -71,7 +70,11 @@ private:
LockRefPtr<PageDirectory> m_page_directory;
RegionTree m_region_tree;
// NOTE: The total range is also in the RegionTree, but since it never changes,
// it's nice to have it in a place where we can access it without locking.
VirtualRange m_total_range;
SpinlockProtected<RegionTree> m_region_tree;
bool m_enforces_syscall_regions { false };
};