From: Wei Yang <richard.weiyang@gmail.com>
To: willy@infradead.org, richard.weiyang@gmail.com
Cc: linux-kernel@vger.kernel.org
Subject: [Patch v2 1/2] XArray: make xa_dump output more friendly to read
Date: Thu, 15 Sep 2022 01:09:56 +0000 [thread overview]
Message-ID: <20220915010957.25506-1-richard.weiyang@gmail.com> (raw)
In-Reply-To: <20220912124647.17164-1-richard.weiyang@gmail.com>
This patch helps to adjust xa_dump output by:
* add an index to each entry
* add indent to each entry
Then the output would look like:
[ 0]0-4095: node ffff938e16539b60 max 19 parent 0000000000000000 shift 6 count 48 values 48 array ffffffffc05e1280 list ffff938e16539b78 ffff938e16539b78 marks 0 0 0
[ 0]0-63: value 0 (0x0) [0000000000000001]
[ 1]64-127: sibling (slot 0)
[ 2]128-191: sibling (slot 0)
[ 3]192-255: sibling (slot 0)
[ 4]256-319: sibling (slot 0)
[ 5]320-383: sibling (slot 0)
[ 6]384-447: sibling (slot 0)
[ 7]448-511: sibling (slot 0)
[ 8]512-575: sibling (slot 0)
[ 9]576-639: sibling (slot 0)
[10]640-703: sibling (slot 0)
[11]704-767: sibling (slot 0)
[12]768-831: sibling (slot 0)
[13]832-895: sibling (slot 0)
[14]896-959: sibling (slot 0)
[15]960-1023: sibling (slot 0)
[32]2048-2111: value 2048 (0x800) [0000000000001001]
[33]2112-2175: sibling (slot 32)
[34]2176-2239: sibling (slot 32)
[35]2240-2303: sibling (slot 32)
[36]2304-2367: sibling (slot 32)
[37]2368-2431: sibling (slot 32)
[38]2432-2495: sibling (slot 32)
[39]2496-2559: sibling (slot 32)
[40]2560-2623: sibling (slot 32)
[41]2624-2687: sibling (slot 32)
[42]2688-2751: sibling (slot 32)
[43]2752-2815: sibling (slot 32)
[44]2816-2879: sibling (slot 32)
[45]2880-2943: sibling (slot 32)
[46]2944-3007: sibling (slot 32)
[47]3008-3071: sibling (slot 32)
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
lib/xarray.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/lib/xarray.c b/lib/xarray.c
index 1ddcfa8c86ac..ed50a26d97a3 100644
--- a/lib/xarray.c
+++ b/lib/xarray.c
@@ -2235,19 +2235,22 @@ void xa_dump_node(const struct xa_node *node)
void xa_dump_index(unsigned long index, unsigned int shift)
{
+ pr_cont("[%2lu]", (index >> shift) & XA_CHUNK_MASK);
if (!shift)
- pr_info("%lu: ", index);
+ pr_cont("%lu: ", index);
else if (shift >= BITS_PER_LONG)
- pr_info("0-%lu: ", ~0UL);
+ pr_cont("0-%lu: ", ~0UL);
else
- pr_info("%lu-%lu: ", index, index | ((1UL << shift) - 1));
+ pr_cont("%lu-%lu: ", index, index | ((1UL << shift) - 1));
}
-void xa_dump_entry(const void *entry, unsigned long index, unsigned long shift)
+void xa_dump_entry(const void *entry, unsigned long index, unsigned long shift,
+ int level)
{
if (!entry)
return;
+ pr_info("%*s", level * 2, level ? " " : "");
xa_dump_index(index, shift);
if (xa_is_node(entry)) {
@@ -2259,7 +2262,8 @@ void xa_dump_entry(const void *entry, unsigned long index, unsigned long shift)
xa_dump_node(node);
for (i = 0; i < XA_CHUNK_SIZE; i++)
xa_dump_entry(node->slots[i],
- index + (i << node->shift), node->shift);
+ index + (i << node->shift), node->shift,
+ level + 1);
}
} else if (xa_is_value(entry))
pr_cont("value %ld (0x%lx) [%px]\n", xa_to_value(entry),
@@ -2286,6 +2290,6 @@ void xa_dump(const struct xarray *xa)
xa_marked(xa, XA_MARK_1), xa_marked(xa, XA_MARK_2));
if (xa_is_node(entry))
shift = xa_to_node(entry)->shift + XA_CHUNK_SHIFT;
- xa_dump_entry(entry, 0, shift);
+ xa_dump_entry(entry, 0, shift, 0);
}
#endif
--
2.33.1
next prev parent reply other threads:[~2022-09-15 1:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-12 12:46 [PATCH " Wei Yang
2022-09-12 12:46 ` [PATCH 2/2] XArray: Fix xas_create_range() when lower multi-order entry present Wei Yang
2022-09-12 17:43 ` [PATCH 1/2] XArray: make xa_dump output more friendly to read Matthew Wilcox
2022-10-13 12:40 ` Wei Yang
2022-11-03 8:18 ` Wei Yang
2022-09-15 1:09 ` Wei Yang [this message]
2022-09-15 1:09 ` [Patch v2 2/2] XArray: Fix xas_create_range() when lower multi-order entry present Wei Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220915010957.25506-1-richard.weiyang@gmail.com \
--to=richard.weiyang@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®