]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Move all searching to common debug area
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 7 Dec 2020 01:29:32 +0000 (20:29 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 5 Jan 2021 17:33:34 +0000 (12:33 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index 1b8ea0f2d43bf0ebff281fd9d12caedf78c1ae50..80a29355bcd32faf8cde66fc696c1d70142994ce 100644 (file)
@@ -4711,66 +4711,6 @@ retry:
        return entry;
 }
 
-static inline void mas_bfs_preorder(struct ma_state *mas)
-{
-
-       if (mas_is_start(mas)) {
-               mas_start(mas);
-               return;
-       }
-
-       if (mte_is_leaf(mas->node) && mte_is_root(mas->node)) {
-               mas->node = MAS_NONE;
-               return;
-       }
-
-}
-
-/* mas limits not adjusted */
-static inline void mas_dfs_preorder(struct ma_state *mas)
-{
-
-       struct maple_enode *prev;
-       unsigned char slot = 0;
-
-       if (mas_is_start(mas)) {
-               mas_start(mas);
-               return;
-       }
-
-       if (mte_is_leaf(mas->node) && mte_is_root(mas->node))
-               goto done;
-
-walk_up:
-       if (mte_is_leaf(mas->node) ||
-           (slot >= mt_slot_count(mas->node))) {
-               if (mte_is_root(mas->node))
-                       goto done;
-
-               slot = mte_parent_slot(mas->node) + 1;
-               mas->node = mt_mk_node(mte_parent(mas->node),
-                                      mas_parent_enum(mas, mas->node));
-               goto walk_up;
-       }
-
-       prev = mas->node;
-       mas->node = mas_get_slot(mas, slot);
-       if (!mas->node) {
-               if (mte_is_root(prev))
-                       goto done;
-
-               mas->node = prev;
-               slot = mte_parent_slot(mas->node) + 1;
-               mas->node = mt_mk_node(mte_parent(mas->node),
-                                      mas_parent_enum(mas, mas->node));
-               goto walk_up;
-       }
-
-       return;
-done:
-       mas->node = MAS_NONE;
-}
-
 static inline unsigned char mas_dead_leaves(struct ma_state *mas, void **slots)
 {
        struct maple_node *node;
@@ -5247,6 +5187,98 @@ unsigned long mt_get_alloc_size(void)
 #else // __KERNEL__ is defined.
 #define MA_PTR "%px"
 #endif
+/* mas limits not adjusted */
+static inline void mas_dfs_preorder(struct ma_state *mas)
+{
+
+       struct maple_enode *prev;
+       unsigned char slot = 0;
+
+       if (mas_is_start(mas)) {
+               mas_start(mas);
+               return;
+       }
+
+       if (mte_is_leaf(mas->node) && mte_is_root(mas->node))
+               goto done;
+
+walk_up:
+       if (mte_is_leaf(mas->node) ||
+           (slot >= mt_slot_count(mas->node))) {
+               if (mte_is_root(mas->node))
+                       goto done;
+
+               slot = mte_parent_slot(mas->node) + 1;
+               mas->node = mt_mk_node(mte_parent(mas->node),
+                                      mas_parent_enum(mas, mas->node));
+               goto walk_up;
+       }
+
+       prev = mas->node;
+       mas->node = mas_get_slot(mas, slot);
+       if (!mas->node) {
+               if (mte_is_root(prev))
+                       goto done;
+
+               mas->node = prev;
+               slot = mte_parent_slot(mas->node) + 1;
+               mas->node = mt_mk_node(mte_parent(mas->node),
+                                      mas_parent_enum(mas, mas->node));
+               goto walk_up;
+       }
+
+       return;
+done:
+       mas->node = MAS_NONE;
+}
+
+
+static inline void mas_bfs_preorder(struct ma_state *mas)
+{
+
+       if (mas_is_start(mas)) {
+               mas_start(mas);
+               return;
+       }
+
+       if (mte_is_leaf(mas->node) && mte_is_root(mas->node)) {
+               mas->node = MAS_NONE;
+               return;
+       }
+
+}
+
+/* Depth first search, post-order */
+static inline void mas_dfs_postorder(struct ma_state *mas, unsigned long max)
+{
+
+       struct maple_enode *p = MAS_NONE, *mn = mas->node;
+       unsigned long p_min, p_max;
+
+       mas_next_node(mas, max);
+       if (!mas_is_none(mas))
+               return;
+
+       if (mte_is_root(mn))
+               return;
+
+       mas->node = mn;
+       mas_ascend(mas);
+       while (mas->node != MAS_NONE) {
+               p = mas->node;
+               p_min = mas->min;
+               p_max = mas->max;
+               mas_prev_node(mas, 0);
+       }
+
+       if (p == MAS_NONE)
+               return;
+
+       mas->node = p;
+       mas->max = p_max;
+       mas->min = p_min;
+}
+
 // Tree validations
 void mt_dump_node(void *entry, unsigned long min, unsigned long max,
                unsigned int depth);
@@ -5609,37 +5641,6 @@ void mas_validate_limits(struct ma_state *mas)
        }
 }
 
-/* Depth first search, post-order */
-static inline void mas_dfs_postorder(struct ma_state *mas, unsigned long max)
-{
-
-       struct maple_enode *p = MAS_NONE, *mn = mas->node;
-       unsigned long p_min, p_max;
-
-       mas_next_node(mas, max);
-       if (!mas_is_none(mas))
-               return;
-
-       if (mte_is_root(mn))
-               return;
-
-       mas->node = mn;
-       mas_ascend(mas);
-       while (mas->node != MAS_NONE) {
-               p = mas->node;
-               p_min = mas->min;
-               p_max = mas->max;
-               mas_prev_node(mas, 0);
-       }
-
-       if (p == MAS_NONE)
-               return;
-
-       mas->node = p;
-       mas->max = p_max;
-       mas->min = p_min;
-}
-
 void mt_validate_nulls(struct maple_tree *mt)
 {
        void *entry, *last = (void *)1;