1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:28:12 +00:00

LibWeb: Make VM allocation atomic for kernel regions

Instead of first allocating the VM range, and then inserting a region
with that range into the MM region tree, we now do both things in a
single atomic operation:

    - RegionTree::place_anywhere(Region&, size, alignment)
    - RegionTree::place_specifically(Region&, address, size)

To reduce the number of things we do while locking the region tree,
we also require callers to provide a constructed Region object.
This commit is contained in:
Andreas Kling 2022-04-03 15:27:47 +02:00
parent cbf52d474c
commit e852a69a06
7 changed files with 85 additions and 57 deletions

View file

@ -135,6 +135,7 @@ class MemoryManager {
friend class PageDirectory;
friend class AnonymousVMObject;
friend class Region;
friend class RegionTree;
friend class VMObject;
friend struct ::KmallocGlobalData;
@ -187,7 +188,6 @@ public:
ErrorOr<NonnullOwnPtr<Region>> allocate_kernel_region(size_t, StringView name, Region::Access access, AllocationStrategy strategy = AllocationStrategy::Reserve, Region::Cacheable = Region::Cacheable::Yes);
ErrorOr<NonnullOwnPtr<Region>> allocate_kernel_region(PhysicalAddress, size_t, StringView name, Region::Access access, Region::Cacheable = Region::Cacheable::Yes);
ErrorOr<NonnullOwnPtr<Region>> allocate_kernel_region_with_vmobject(VMObject&, size_t, StringView name, Region::Access access, Region::Cacheable = Region::Cacheable::Yes);
ErrorOr<NonnullOwnPtr<Region>> allocate_kernel_region_with_vmobject(VirtualRange const&, VMObject&, StringView name, Region::Access access, Region::Cacheable = Region::Cacheable::Yes);
struct SystemMemoryInfo {
PhysicalSize user_physical_pages { 0 };
@ -255,7 +255,6 @@ private:
void initialize_physical_pages();
void register_reserved_ranges();
void register_kernel_region(Region&);
void unregister_kernel_region(Region&);
void protect_kernel_image();