[PATCH 1/3] lib/hexdump: Add a raw pointer printing format for slub debugging
From: Stephen Boyd
Date: Wed May 19 2021 - 21:36:03 EST
We want to get actual pointer addresses when we're looking at slub
debugging reports. Add another prefix format specifier that says we want
raw pointer addresses, i.e. %px, in the printk format.
Signed-off-by: Stephen Boyd <swboyd@xxxxxxxxxxxx>
---
include/linux/printk.h | 1 +
lib/hexdump.c | 12 ++++++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/include/linux/printk.h b/include/linux/printk.h
index fe7eb2351610..a7b0b620982d 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -567,6 +567,7 @@ extern const struct file_operations kmsg_fops;
enum {
DUMP_PREFIX_NONE,
DUMP_PREFIX_ADDRESS,
+ DUMP_PREFIX_RAW_ADDRESS,
DUMP_PREFIX_OFFSET
};
extern int hex_dump_to_buffer(const void *buf, size_t len, int rowsize,
diff --git a/lib/hexdump.c b/lib/hexdump.c
index 9301578f98e8..87af5755563f 100644
--- a/lib/hexdump.c
+++ b/lib/hexdump.c
@@ -211,8 +211,12 @@ EXPORT_SYMBOL(hex_dump_to_buffer);
* @level: kernel log level (e.g. KERN_DEBUG)
* @prefix_str: string to prefix each line with;
* caller supplies trailing spaces for alignment if desired
- * @prefix_type: controls whether prefix of an offset, address, or none
- * is printed (%DUMP_PREFIX_OFFSET, %DUMP_PREFIX_ADDRESS, %DUMP_PREFIX_NONE)
+ * @prefix_type: controls how prefix is printed
+ * %DUMP_PREFIX_OFFSET - offset prefix
+ * %DUMP_PREFIX_ADDRESS - hashed address prefix
+ * %DUMP_PREFIX_RAW_ADDRESS - non-hashed address prefix
+ * %DUMP_PREFIX_NONE - no prefix
+ *
* @rowsize: number of bytes to print per line; must be 16 or 32
* @groupsize: number of bytes to print at a time (1, 2, 4, 8; default = 1)
* @buf: data blob to dump
@@ -260,6 +264,10 @@ void print_hex_dump(const char *level, const char *prefix_str, int prefix_type,
printk("%s%s%p: %s\n",
level, prefix_str, ptr + i, linebuf);
break;
+ case DUMP_PREFIX_RAW_ADDRESS:
+ printk("%s%s%px: %s\n",
+ level, prefix_str, ptr + i, linebuf);
+ break;
case DUMP_PREFIX_OFFSET:
printk("%s%s%.8x: %s\n", level, prefix_str, i, linebuf);
break;
--
https://chromeos.dev