From: Liam R. Howlett Date: Thu, 17 Feb 2022 22:32:14 +0000 (-0500) Subject: maple_tree: big node weight reduction X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=38d7f582872d8e13583bb2bf7f1215b253e9fc13;p=users%2Fjedix%2Flinux-maple.git maple_tree: big node weight reduction Signed-off-by: Liam R. Howlett --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index c8cf9490e940..9588c6d1d0c8 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -109,9 +109,14 @@ static const unsigned char mt_min_slots[] = { struct maple_big_node { struct maple_pnode *parent; - struct maple_enode *slot[MAPLE_BIG_NODE_SLOTS]; unsigned long pivot[MAPLE_BIG_NODE_SLOTS - 1]; - unsigned long gap[MAPLE_BIG_NODE_SLOTS]; + union { + struct maple_enode *slot[MAPLE_BIG_NODE_SLOTS]; + struct { + unsigned long padding[MAPLE_BIG_NODE_SLOTS/2 + 2]; + unsigned long gap[MAPLE_BIG_NODE_SLOTS/2 + 2]; + }; + }; unsigned long min; unsigned char b_end; enum maple_type type; @@ -1742,7 +1747,8 @@ static inline void mab_shift_right(struct maple_big_node *b_node, memmove(b_node->pivot + shift, b_node->pivot, size); memmove(b_node->slot + shift, b_node->slot, size); - memmove(b_node->gap + shift, b_node->gap, size); + if (b_node->type == maple_arange_64) + memmove(b_node->gap + shift, b_node->gap, size); } /* @@ -2353,6 +2359,7 @@ bool mast_sibling_rebalance_right(struct maple_subtree_state *mast, bool free) old_l = mast->orig_l->node; if (mas_prev_sibling(mast->orig_l)) { + mast->bn->type = mte_node_type(mast->orig_l->node); mast_rebalance_prev(mast, old_l); return true; } @@ -3208,9 +3215,13 @@ static inline void mast_fill_bnode(struct maple_subtree_state *mast, { bool cp = true; struct maple_enode *old = mas->node; - unsigned char split, zero; + unsigned char split; + memset(mast->bn->gap, 0, sizeof(unsigned long) * ARRAY_SIZE(mast->bn->gap)); + memset(mast->bn->slot, 0, sizeof(unsigned long) * ARRAY_SIZE(mast->bn->slot)); + memset(mast->bn->pivot, 0, sizeof(unsigned long) * ARRAY_SIZE(mast->bn->pivot)); mast->bn->b_end = 0; + if (mte_is_root(mas->node)) { cp = false; } else { @@ -3236,13 +3247,6 @@ static inline void mast_fill_bnode(struct maple_subtree_state *mast, mast->bn->b_end--; mast->bn->type = mte_node_type(mas->node); - - zero = MAPLE_BIG_NODE_SLOTS - mast->bn->b_end - 2; - memset(mast->bn->gap + mast->bn->b_end + 1, 0, - sizeof(unsigned long) * zero); - memset(mast->bn->slot + mast->bn->b_end + 1, 0, sizeof(void*) * zero--); - memset(mast->bn->pivot + mast->bn->b_end + 1, 0, - sizeof(unsigned long) * zero); } /*