diff options
author | Andreas Kling <kling@serenityos.org> | 2022-04-02 20:01:29 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-03 21:51:58 +0200 |
commit | 02a95a196f02b838c1538b527bcc7b98a6afe2eb (patch) | |
tree | a8fd04f4aa59a0c15b5cce2e8c7cafde12c2bd21 /Kernel/Syscalls | |
parent | 90a7b9e5b48c270aa5ca0b6aea361d29257d3925 (diff) | |
download | serenity-02a95a196f02b838c1538b527bcc7b98a6afe2eb.zip |
Kernel: Use AddressSpace region tree for range allocation
This patch stops using VirtualRangeAllocator in AddressSpace and instead
looks for holes in the region tree when allocating VM space.
There are many benefits:
- VirtualRangeAllocator is non-intrusive and would call kmalloc/kfree
when used. This new solution is allocation-free. This was a source
of unpleasant MM/kmalloc deadlocks.
- We consolidate authority on what the address space looks like in a
single place. Previously, we had both the range allocator *and* the
region tree both being used to determine if an address was valid.
Now there is only the region tree.
- Deallocation of VM when splitting regions is no longer complicated,
as we don't need to keep two separate trees in sync.
Diffstat (limited to 'Kernel/Syscalls')
-rw-r--r-- | Kernel/Syscalls/clock.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/mmap.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/Kernel/Syscalls/clock.cpp b/Kernel/Syscalls/clock.cpp index b6668b989b..a7e1ff4fd4 100644 --- a/Kernel/Syscalls/clock.cpp +++ b/Kernel/Syscalls/clock.cpp @@ -17,7 +17,7 @@ ErrorOr<FlatPtr> Process::sys$map_time_page() auto& vmobject = TimeManagement::the().time_page_vmobject(); - auto range = TRY(address_space().page_directory().range_allocator().try_allocate_randomized(PAGE_SIZE, PAGE_SIZE)); + auto range = TRY(address_space().try_allocate_randomized(PAGE_SIZE, PAGE_SIZE)); auto* region = TRY(address_space().allocate_region_with_vmobject(range, vmobject, 0, "Kernel time page"sv, PROT_READ, true)); return region->vaddr().get(); } diff --git a/Kernel/Syscalls/mmap.cpp b/Kernel/Syscalls/mmap.cpp index 3a77238396..8cdbd57466 100644 --- a/Kernel/Syscalls/mmap.cpp +++ b/Kernel/Syscalls/mmap.cpp @@ -193,7 +193,7 @@ ErrorOr<FlatPtr> Process::sys$mmap(Userspace<Syscall::SC_mmap_params const*> use auto range = TRY([&]() -> ErrorOr<Memory::VirtualRange> { if (map_randomized) - return address_space().page_directory().range_allocator().try_allocate_randomized(rounded_size, alignment); + return address_space().try_allocate_randomized(rounded_size, alignment); // If MAP_FIXED is specified, existing mappings that intersect the requested range are removed. if (map_fixed) |