]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_dump: Pad to indicate depth
authorMatthew Wilcox <willy@infradead.org>
Tue, 23 Apr 2019 19:44:48 +0000 (15:44 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Wed, 31 Jul 2019 14:52:43 +0000 (10:52 -0400)
Not entirely sure if this is the best way to indicate depth; let's
try it for a bit and see how confused we get.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
lib/maple_tree.c

index 6ee28847fa1c3da97ec07ca22b67ba2ef877946b..e20fd6cd471e1f2e0a2a5d8bfc12c8968a8a3888 100644 (file)
@@ -2187,17 +2187,18 @@ EXPORT_SYMBOL(mtree_destroy);
 #ifdef MT_DEBUG
 void mt_dump_node(void *entry, unsigned long min, unsigned long max,
                unsigned int depth);
-void mt_dump_range(unsigned long min, unsigned long max)
+void mt_dump_range(unsigned long min, unsigned long max, unsigned int depth)
 {
        if (min == max)
-               pr_info("%lu: ", min);
+               pr_info("%*lu: ", depth * 2 + 16, min);
        else
-               pr_info("%lu-%lu: ", min, max);
+               pr_info("%*lu-%lu: ", depth * 2 + 16, min, max);
 }
 
-void mt_dump_entry(void *entry, unsigned long min, unsigned long max)
+void mt_dump_entry(void *entry, unsigned long min, unsigned long max,
+               unsigned int depth)
 {
-       mt_dump_range(min, max);
+       mt_dump_range(min, max, depth);
 
        if (xa_is_value(entry))
                pr_cont("value %ld (0x%lx) [%p]\n", xa_to_value(entry),
@@ -2233,7 +2234,7 @@ void mt_dump_range64(void *entry, unsigned long min, unsigned long max,
                if (last == 0 && i > 0)
                        break;
                if (leaf)
-                       mt_dump_entry(node->slot[i], first, last);
+                       mt_dump_entry(node->slot[i], first, last, depth + 1);
                else if (node->slot[i])
                        mt_dump_node(node->slot[i], first, last, depth + 1);
 
@@ -2271,7 +2272,7 @@ void mt_dump_arange64(void *entry, unsigned long min, unsigned long max,
                if (last == 0 && i > 0)
                        break;
                if (leaf)
-                       mt_dump_entry(node->slot[i], first, last);
+                       mt_dump_entry(node->slot[i], first, last, depth + 1);
                else if (node->slot[i])
                        mt_dump_node(node->slot[i], first, last, depth + 1);
 
@@ -2292,7 +2293,7 @@ void mt_dump_node(void *entry, unsigned long min, unsigned long max,
        unsigned int type = mt_node_type(entry);
        unsigned int i;
 
-       mt_dump_range(min, max);
+       mt_dump_range(min, max, depth);
 
        pr_cont("node %p depth %d type %d parent %p", node, depth, type,
                        node ? node->parent : NULL);
@@ -2302,7 +2303,7 @@ void mt_dump_node(void *entry, unsigned long min, unsigned long max,
                for (i = 0; i < MAPLE_NODE_SLOTS; i++) {
                        if (min + i > max)
                                pr_cont("OUT OF RANGE: ");
-                       mt_dump_entry(node->slot[i], min + i, min + i);
+                       mt_dump_entry(node->slot[i], min + i, min + i, depth);
                }
                break;
        case maple_leaf_64:
@@ -2326,7 +2327,7 @@ void mt_dump(const struct maple_tree *mt)
        pr_info("maple_tree(%p) flags %X, root %p\n",
                 mt, mt->ma_flags, entry);
        if (!xa_is_node(entry))
-               mt_dump_entry(entry, 0, 0);
+               mt_dump_entry(entry, 0, 0, 0);
        else if (entry)
                mt_dump_node(entry, 0, mt_max[mt_node_type(entry)], 0);
 }