Commit 9155e843 authored by Sidhartha Kumar's avatar Sidhartha Kumar Committed by Andrew Morton

maple_tree: remove node allocations from various write helper functions

These write helper functions are all called from store paths which
preallocate enough nodes that will be needed for the write. There is no
more need to allocate within the functions themselves.

Link: https://lkml.kernel.org/r/20240814161944.55347-15-sidhartha.kumar@oracle.comReviewed-by: default avatarLiam R. Howlett <Liam.Howlett@oracle.com>
Signed-off-by: default avatarSidhartha Kumar <sidhartha.kumar@oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 4037d44f
...@@ -2976,9 +2976,6 @@ static inline int mas_rebalance(struct ma_state *mas, ...@@ -2976,9 +2976,6 @@ static inline int mas_rebalance(struct ma_state *mas,
* tries to combine the data in the same way. If one node contains the * 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. * entire range of the tree, then that node is used as a new root node.
*/ */
mas_node_count(mas, empty_count * 2 - 1);
if (mas_is_err(mas))
return 0;
mast.orig_l = &l_mas; mast.orig_l = &l_mas;
mast.orig_r = &r_mas; mast.orig_r = &r_mas;
...@@ -3029,11 +3026,6 @@ static inline void mas_destroy_rebalance(struct ma_state *mas, unsigned char end ...@@ -3029,11 +3026,6 @@ static inline void mas_destroy_rebalance(struct ma_state *mas, unsigned char end
/* set up node. */ /* set up node. */
if (in_rcu) { if (in_rcu) {
/* Allocate for both left and right as well as parent. */
mas_node_count(mas, 3);
if (mas_is_err(mas))
return;
newnode = mas_pop_node(mas); newnode = mas_pop_node(mas);
} else { } else {
newnode = &reuse; newnode = &reuse;
...@@ -3341,10 +3333,6 @@ static int mas_split(struct ma_state *mas, struct maple_big_node *b_node) ...@@ -3341,10 +3333,6 @@ static int mas_split(struct ma_state *mas, struct maple_big_node *b_node)
trace_ma_op(__func__, mas); trace_ma_op(__func__, mas);
mas->depth = mas_mt_height(mas); mas->depth = mas_mt_height(mas);
/* Allocation failures will happen early. */
mas_node_count(mas, 1 + mas->depth * 2);
if (mas_is_err(mas))
return 0;
mast.l = &l_mas; mast.l = &l_mas;
mast.r = &r_mas; mast.r = &r_mas;
...@@ -3427,10 +3415,6 @@ static inline int mas_root_expand(struct ma_state *mas, void *entry) ...@@ -3427,10 +3415,6 @@ static inline int mas_root_expand(struct ma_state *mas, void *entry)
unsigned long *pivots; unsigned long *pivots;
int slot = 0; int slot = 0;
mas_node_count(mas, 1);
if (unlikely(mas_is_err(mas)))
return 0;
node = mas_pop_node(mas); node = mas_pop_node(mas);
pivots = ma_pivots(node, type); pivots = ma_pivots(node, type);
slots = ma_slots(node, type); slots = ma_slots(node, type);
...@@ -3699,10 +3683,6 @@ static inline int mas_new_root(struct ma_state *mas, void *entry) ...@@ -3699,10 +3683,6 @@ static inline int mas_new_root(struct ma_state *mas, void *entry)
goto done; goto done;
} }
mas_node_count(mas, 1);
if (mas_is_err(mas))
return 0;
node = mas_pop_node(mas); node = mas_pop_node(mas);
pivots = ma_pivots(node, type); pivots = ma_pivots(node, type);
slots = ma_slots(node, type); slots = ma_slots(node, type);
...@@ -3765,9 +3745,6 @@ static noinline int mas_wr_spanning_store(struct ma_wr_state *wr_mas) ...@@ -3765,9 +3745,6 @@ static noinline int mas_wr_spanning_store(struct ma_wr_state *wr_mas)
* entries per level plus a new root. * entries per level plus a new root.
*/ */
height = mas_mt_height(mas); height = mas_mt_height(mas);
mas_node_count(mas, 1 + height * 3);
if (mas_is_err(mas))
return 0;
/* /*
* Set up right side. Need to get to the next offset after the spanning * Set up right side. Need to get to the next offset after the spanning
...@@ -3851,10 +3828,6 @@ static inline bool mas_wr_node_store(struct ma_wr_state *wr_mas, ...@@ -3851,10 +3828,6 @@ static inline bool mas_wr_node_store(struct ma_wr_state *wr_mas,
/* set up node. */ /* set up node. */
if (in_rcu) { if (in_rcu) {
mas_node_count(mas, 1);
if (mas_is_err(mas))
return false;
newnode = mas_pop_node(mas); newnode = mas_pop_node(mas);
} else { } else {
memset(&reuse, 0, sizeof(struct maple_node)); memset(&reuse, 0, sizeof(struct maple_node));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment