kernel/vm: Remove linear search from _get_next_area_info.

This introduces VMAddressSpace::FindClosestArea() that can be used to
find the closest area to a given address in either direction. This is
now trivial and efficient since both kernel and user address spaces use
a binary search tree.

Using FindClosestArea() getting multiple area infos is sped up
dramatically as it removes the need for a linear search from the first
area to the one given in the cookie on each successive invocation.

Change-Id: I227da87d915f6f3d3ef88bfeb6be5d4c97c3baaa
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2840
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Michael Lotz
2020-05-30 02:29:41 +00:00
committed by waddlesplash
parent 6d9329be05
commit a626bdab77
6 changed files with 31 additions and 9 deletions
@@ -76,6 +76,8 @@ public:
virtual VMArea* NextArea(VMArea* area) const = 0;
virtual VMArea* LookupArea(addr_t address) const = 0;
virtual VMArea* FindClosestArea(addr_t address, bool less) const
= 0;
virtual VMArea* CreateArea(const char* name, uint32 wiring,
uint32 protection,
uint32 allocationFlags) = 0;