diff options
author | Liam R. Howlett <Liam.Howlett@oracle.com> | 2023-07-24 20:31:50 +0200 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2023-08-18 19:12:48 +0200 |
commit | c108df767fb786586274b2435473885151d6f360 (patch) | |
tree | 898b6e38968e38bf01dc3113d7089f9b67a86910 | |
parent | maple_tree: re-introduce entry to mas_preallocate() arguments (diff) | |
download | linux-c108df767fb786586274b2435473885151d6f360.tar.xz linux-c108df767fb786586274b2435473885151d6f360.zip |
maple_tree: adjust node allocation on mas_rebalance()
mas_rebalance() is called to rebalance an insufficient node into a
single node or two sufficient nodes. The preallocation estimate is
always too many in this case as the height of the tree will never grow
and there is no possibility to have a three way split in this case, so
revise the node allocation count.
Link: https://lkml.kernel.org/r/20230724183157.3939892-9-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Peng Zhang <zhangpeng.00@bytedance.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r-- | lib/maple_tree.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 0d7e30c7d999..494f884ef17f 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3136,7 +3136,7 @@ static inline int mas_rebalance(struct ma_state *mas, * tries to combine the data in the same way. If one node contains the * entire range of the tree, then that node is used as a new root node. */ - mas_node_count(mas, 1 + empty_count * 3); + mas_node_count(mas, empty_count * 2 - 1); if (mas_is_err(mas)) return 0; |