]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: big node weight reduction
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 17 Feb 2022 22:32:14 +0000 (17:32 -0500)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 8 Mar 2022 18:19:14 +0000 (13:19 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c

index c8cf9490e940b1b785d3692357a37df99d046513..9588c6d1d0c8d00808984023d9f920e90841ddeb 100644 (file)
@@ -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);
 }
 
 /*