]> www.infradead.org Git - users/jedix/linux-maple.git/commit
maple_tree: use vacant nodes to reduce worst case allocations
authorSidhartha Kumar <sidhartha.kumar@oracle.com>
Mon, 7 Apr 2025 18:40:59 +0000 (18:40 +0000)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 8 Apr 2025 20:01:43 +0000 (16:01 -0400)
commit301c6c2690ef47bce41da27323fcbf340eb39888
treecb8572487706f65cb6a553cd3393e1e71f74b70e
parent95b5bec568f3c632a06b70b2205585066a0c1f36
maple_tree: use vacant nodes to reduce worst case allocations

In order to determine the store type for a maple tree operation, a walk
of the tree is done through mas_wr_walk(). This function descends the
tree until a spanning write is detected or we reach a leaf node. While
descending, keep track of the height at which we encounter a node with
available space. This is done by checking if mas->end is less than the
number of slots a given node type can fit.

Now that the height of the vacant node is tracked, we can use the
difference between the height of the tree and the height of the vacant
node to know how many levels we will have to propagate creating new
nodes. Update mas_prealloc_calc() to consider the vacant height and
reduce the number of worst-case allocations.

Rebalancing and spanning stores are not supported and fall back to using
the full height of the tree for allocations.

Update preallocation testing assertions to take into account vacant
height.

Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
include/linux/maple_tree.h
lib/maple_tree.c
tools/testing/radix-tree/maple.c