diff options
| author | Liam R. Howlett <Liam.Howlett@oracle.com> | 2026-01-30 15:59:33 -0500 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-04-05 13:52:57 -0700 |
| commit | 2969241fa22e39f0c751e96d2f53b1d9dfac19ba (patch) | |
| tree | 087aec9ec29474b78921aad8e5824953b0c5a848 /lib | |
| parent | b8852ef30c67318d40e69d295e28f6cab5174862 (diff) | |
| download | lwn-2969241fa22e39f0c751e96d2f53b1d9dfac19ba.tar.gz lwn-2969241fa22e39f0c751e96d2f53b1d9dfac19ba.zip | |
maple_tree: pass maple copy node to mas_wmb_replace()
mas_wmb_replace() is called in three places with the same setup, move the
setup into the function itself. The function needs to be relocated as it
calls mtree_range_walk().
Link: https://lkml.kernel.org/r/20260130205935.2559335-29-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Alice Ryhl <aliceryhl@google.com>
Cc: Andrew Ballance <andrewjballance@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Christian Kujau <lists@nerdbynature.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: SeongJae Park <sj@kernel.org>
Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/maple_tree.c | 60 |
1 files changed, 25 insertions, 35 deletions
diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 51ff311ff5b6..fe8424f4657d 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1901,26 +1901,6 @@ static inline void mas_topiary_replace(struct ma_state *mas, } /* - * mas_wmb_replace() - Write memory barrier and replace - * @mas: The maple state - * @old_enode: The old maple encoded node that is being replaced. - * @new_height: The new height of the tree as a result of the operation - * - * Updates gap as necessary. - */ -static inline void mas_wmb_replace(struct ma_state *mas, - struct maple_enode *old_enode, unsigned char new_height) -{ - /* Insert the new data in the tree */ - mas_topiary_replace(mas, old_enode, new_height); - - if (mte_is_leaf(mas->node)) - return; - - mas_update_gap(mas); -} - -/* * node_copy() - Copy from one node to another. * * @mas: The maple state @@ -2087,6 +2067,28 @@ dead_node: } /* + * mas_wmb_replace() - Write memory barrier and replace + * @mas: The maple state + * @cp: The maple copy node + * + * Updates gap as necessary. + */ +static inline void mas_wmb_replace(struct ma_state *mas, struct maple_copy *cp) +{ + struct maple_enode *old_enode; + + old_enode = mas->node; + mas->node = mt_slot_locked(mas->tree, cp->slot, 0); + /* Insert the new data in the tree */ + mas_topiary_replace(mas, old_enode, cp->height); + if (!mte_is_leaf(mas->node)) + mas_update_gap(mas); + + mtree_range_walk(mas); +} + + +/* * cp_leaf_init() - Initialize a maple_copy node for the leaf level of a * spanning store * @cp: The maple copy node @@ -3044,7 +3046,6 @@ done: */ static void mas_wr_spanning_store(struct ma_wr_state *wr_mas) { - struct maple_enode *old_enode; struct maple_copy cp; struct ma_state *mas; struct ma_state sib; @@ -3112,10 +3113,7 @@ static void mas_wr_spanning_store(struct ma_wr_state *wr_mas) cp_data_write(&cp, mas); } while (spanning_ascend(&cp, mas, wr_mas, &r_wr_mas, &sib)); - old_enode = mas->node; - mas->node = mt_slot_locked(mas->tree, cp.slot, 0); - mas_wmb_replace(mas, old_enode, cp.height); - mtree_range_walk(mas); + mas_wmb_replace(mas, &cp); } /* @@ -3433,7 +3431,6 @@ static inline void split_data(struct maple_copy *cp, */ static void mas_wr_split(struct ma_wr_state *wr_mas) { - struct maple_enode *old_enode; struct ma_state parent; struct ma_state *mas; struct maple_copy cp; @@ -3454,10 +3451,7 @@ static void mas_wr_split(struct ma_wr_state *wr_mas) cp_data_write(&cp, mas); } while (split_ascend(&cp, wr_mas, &sib, &parent)); - old_enode = mas->node; - mas->node = mt_slot_locked(mas->tree, cp.slot, 0); - mas_wmb_replace(mas, old_enode, cp.height); - mtree_range_walk(mas); + mas_wmb_replace(mas, &cp); } /* @@ -3470,7 +3464,6 @@ static void mas_wr_split(struct ma_wr_state *wr_mas) */ static void mas_wr_rebalance(struct ma_wr_state *wr_mas) { - struct maple_enode *old_enode; struct ma_state parent; struct ma_state *mas; struct maple_copy cp; @@ -3501,10 +3494,7 @@ static void mas_wr_rebalance(struct ma_wr_state *wr_mas) cp_data_write(&cp, mas); } while (rebalance_ascend(&cp, wr_mas, &sib, &parent)); - old_enode = mas->node; - mas->node = mt_slot_locked(mas->tree, cp.slot, 0); - mas_wmb_replace(mas, old_enode, cp.height); - mtree_range_walk(mas); + mas_wmb_replace(mas, &cp); } /* |
