]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
Revert "maple_tree: Rework node split calculation for better non-leaf node split"
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 25 Feb 2020 16:45:28 +0000 (11:45 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 19:01:17 +0000 (15:01 -0400)
Efficient splitting is causing issues in certain scenarios with regards
to allocation trees.  Revisit later.

This reverts commit 4a0a2dd623fae22f2823a0711193aafef3479e71.

lib/maple_tree.c

index 12838071355a63f503128c1efdc2ce721ed448a1..3c68ad94d0acb0e8bcf6d1fa1acddce233eb5db4 100644 (file)
@@ -1364,21 +1364,10 @@ static inline unsigned char mas_append_calc_split(struct ma_state *mas,
        unsigned long range = mas->max - mas->min;
        unsigned long half;
        unsigned long piv = 0;
-       unsigned long min_range = 8;
        enum maple_type mas_type = mte_node_type(mas->node);
 
-       if (mas_type == maple_arange_64) {
+       if (mas_type == maple_arange_64)
                max = 5;
-               ret = 5;
-       }
-
-       if (!ma_is_leaf(mas_type)) {
-               min_range *= max;
-               if (mas->max == ULONG_MAX) {
-                       max--;
-                       ret--;
-               }
-       }
 
        if (!active) {
                if (ma_is_leaf(mas_type))
@@ -1386,27 +1375,34 @@ static inline unsigned char mas_append_calc_split(struct ma_state *mas,
                return max - 2;
        }
 
+       //if (mas->min == 0)
+       //      max = 7;
+
        half = max / 2;
-       if (range <= min_range)
-               return ret;
+       if (ma_is_leaf(mas_type)) {
+               if (range <= 8UL)
+                       return ret;
 
-       for (slot = 0; slot <= mt_pivots[mas_type]; slot++) {
-               piv = mas_get_safe_pivot(mas, slot);
+               for (slot = 0; slot <= mt_pivots[mas_type]; slot++) {
+                       piv = mas_get_safe_pivot(mas, slot);
 
-               if (!piv && slot)
-                       return ret;
+                       if (!piv && slot)
+                               return ret;
 
-               range = piv - mas->min;
-               if (range >= min_range) {
-                       if (slot > half)
-                               ret = (max > slot ? slot : max);
-                       else
-                               ret = half;
-                       goto done;
-               }
+                       range = piv - mas->min;
+                       if (range >= 8) {
+                               if (slot > half)
+                                       ret = slot;
+                               else
+                                       ret = half;
+                               goto done;
+                       }
 
+               }
        }
 
+       return half;
+
 done:
        if (ret < max && (piv == ULONG_MAX))
                ret++;