From: Liam R. Howlett Date: Tue, 25 Feb 2020 16:45:28 +0000 (-0500) Subject: Revert "maple_tree: Rework node split calculation for better non-leaf node split" X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=bd7dbfdb4af61da39a1d275b460a6378c8e04d48;p=users%2Fjedix%2Flinux-maple.git Revert "maple_tree: Rework node split calculation for better non-leaf node split" Efficient splitting is causing issues in certain scenarios with regards to allocation trees. Revisit later. This reverts commit 4a0a2dd623fae22f2823a0711193aafef3479e71. --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 12838071355a6..3c68ad94d0acb 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -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++;