From 23c7c58d994f811daf6c198d2fff7851e5b1f681 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Tue, 23 Apr 2019 15:44:48 -0400 Subject: [PATCH] maple_dump: Pad to indicate depth 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 --- lib/maple_tree.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 6ee28847fa1c..e20fd6cd471e 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -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); } -- 2.50.1