From ca0f9ca51bc3e0600f8cbc28c0134bbad19c30ec Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Tue, 12 Oct 2021 10:49:20 -0400 Subject: [PATCH] maple_tree: mas_node_walk() and mas_node_store() node_walk: Just set *ranges in leaf case, otherwise set mas->max/min node_store: Just reverse order of if/else Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 0e65002fa26c..cc11db1104fd 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3669,7 +3669,6 @@ static inline void mas_node_walk(struct ma_state *mas, struct maple_node *node, unsigned char offset; unsigned long index; - pivots = ma_pivots(node, type); if (unlikely(ma_is_dense(type))) { (*range_max) = (*range_min) = mas->index; if (unlikely(ma_dead_node(node))) @@ -3681,6 +3680,7 @@ static inline void mas_node_walk(struct ma_state *mas, struct maple_node *node, offset = 0; min = mas->min; + pivots = ma_pivots(node, type); max = pivots[offset]; if (unlikely(ma_dead_node(node))) return; @@ -3709,9 +3709,14 @@ static inline void mas_node_walk(struct ma_state *mas, struct maple_node *node, max = mas->max; done: - *range_max = max; - *range_min = min; mas->offset = offset; + if (ma_is_leaf(type)) { + *range_max = max; + *range_min = min; + } else { + mas->max = max; + mas->min = min; + } } /* * __mas_walk(): Locates a value and sets the mas->node and slot accordingly. @@ -3746,9 +3751,6 @@ static inline bool __mas_walk(struct ma_state *mas, unsigned long *range_min, /* Descend. */ mas->node = next; - mas->max = *range_max; - mas->min = *range_min; - mas->offset = 0; } return false; } @@ -4001,11 +4003,11 @@ done: ma_set_meta(newnode, maple_leaf_64, 0, new_end); } - if (!mt_in_rcu(mas->tree)) { - memcpy(mas_mn(mas), newnode, sizeof(struct maple_node)); - } else { + if (likely(mt_in_rcu(mas->tree))) { mas->node = mt_mk_node(newnode, mt); mas_replace(mas, false); + } else { + memcpy(mas_mn(mas), newnode, sizeof(struct maple_node)); } trace_ma_write(__func__, mas, 0, entry); mas_update_gap(mas); -- 2.50.1