mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:47:35 +00:00
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.
This commit is contained in:
parent
90a7b9e5b4
commit
02a95a196f
10 changed files with 158 additions and 30 deletions
|
@ -66,8 +66,12 @@ public:
|
|||
size_t amount_purgeable_volatile() const;
|
||||
size_t amount_purgeable_nonvolatile() const;
|
||||
|
||||
ErrorOr<VirtualRange> try_allocate_anywhere(size_t size, size_t alignment);
|
||||
ErrorOr<VirtualRange> try_allocate_specific(VirtualAddress base, size_t size);
|
||||
ErrorOr<VirtualRange> try_allocate_randomized(size_t size, size_t alignment);
|
||||
|
||||
private:
|
||||
explicit AddressSpace(NonnullRefPtr<PageDirectory>);
|
||||
AddressSpace(NonnullRefPtr<PageDirectory>, VirtualRange total_range);
|
||||
|
||||
void delete_all_regions_assuming_they_are_unmapped();
|
||||
|
||||
|
@ -76,6 +80,7 @@ private:
|
|||
RefPtr<PageDirectory> m_page_directory;
|
||||
|
||||
IntrusiveRedBlackTree<&Region::m_tree_node> m_regions;
|
||||
VirtualRange const m_total_range;
|
||||
|
||||
bool m_enforces_syscall_regions { false };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue