]> www.infradead.org Git - users/jedix/linux-maple.git/commit
maple_tree: use height and depth consistently
authorSidhartha Kumar <sidhartha.kumar@oracle.com>
Thu, 10 Apr 2025 19:14:42 +0000 (19:14 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 12 May 2025 00:48:28 +0000 (17:48 -0700)
commitf9d3a963fef4d3377b7ee122408cf2cdf37b3181
tree054d3b334a67eb9e6068249fbef4381a0d97068e
parent28092a652f9c17773aa6ca0f62f73738d756b914
maple_tree: use height and depth consistently

For the maple tree, the root node is defined to have a depth of 0 with a
height of 1.  Each level down from the node, these values are incremented
by 1.  Various code paths define a root with depth 1 which is inconsisent
with the definition.  Modify the code to be consistent with this
definition.

In mas_spanning_rebalance(), l_mas.depth was being used to track the
height based on the number of iterations done in the main loop.  This
information was then used in mas_put_in_tree() to set the height.  Rather
than overload the l_mas.depth field to track height, simply keep track of
height in the local variable new_height and directly pass this to
mas_wmb_replace() which will be passed into mas_put_in_tree().  This
allows up to remove writes to l_mas.depth.

Link: https://lkml.kernel.org/r/20250410191446.2474640-3-sidhartha.kumar@oracle.com
Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Wei Yang <richard.weiyang@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/maple_tree.c
tools/testing/radix-tree/maple.c