From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Geert.Uytterhoeven@sonycom.com, hpa@zytor.com,
linux-kernel@vger.kernel.org, mingo@elte.hu,
yhlu.kernel@gmail.com, David Miller <davem@davemloft.net>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] Fix broken debug output reserve_region_with_split()
Date: Fri, 17 Oct 2008 14:06:31 +1100 [thread overview]
Message-ID: <1224212791.7654.63.camel@pasglop> (raw)
In-Reply-To: <1224212533.7654.60.camel@pasglop>
From: Linus Torvalds <torvalds@linux-foundation.org>
Implement %pR to print struct resource content
Add a %pR option to the kernel vsnprintf that prints the range of
addresses inside a struct resource passed by pointer.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
And this one has updated comments.
Index: linux-work/lib/vsprintf.c
===================================================================
--- linux-work.orig/lib/vsprintf.c 2008-10-17 13:30:18.000000000 +1100
+++ linux-work/lib/vsprintf.c 2008-10-17 14:04:58.000000000 +1100
@@ -24,6 +24,7 @@
#include <linux/kernel.h>
#include <linux/kallsyms.h>
#include <linux/uaccess.h>
+#include <linux/ioport.h>
#include <asm/page.h> /* for PAGE_SIZE */
#include <asm/div64.h>
@@ -550,18 +551,38 @@ static char *symbol_string(char *buf, ch
#endif
}
+static char *resource_string(char *buf, char *end, struct resource *res, int field_width, int precision, int flags)
+{
+ /* room for the actual numbers, the two "0x", -, [, ] and the final zero */
+ char sym[4*sizeof(resource_size_t) + 8];
+ char *p = sym, *pend = sym + sizeof(sym);
+
+ *p++ = '[';
+ p = number(p, pend, res->start, 16, -1, -1, SPECIAL | SMALL);
+ *p++ = '-';
+ p = number(p, pend, res->end, 16, -1, -1, SPECIAL | SMALL);
+ *p++ = ']';
+ *p = 0;
+
+ return string(buf, end, sym, field_width, precision, flags);
+}
+
/*
* Show a '%p' thing. A kernel extension is that the '%p' is followed
* by an extra set of alphanumeric characters that are extended format
* specifiers.
*
- * Right now we just handle 'F' (for symbolic Function descriptor pointers)
- * and 'S' (for Symbolic direct pointers), but this can easily be
- * extended in the future (network address types etc).
- *
- * The difference between 'S' and 'F' is that on ia64 and ppc64 function
- * pointers are really function descriptors, which contain a pointer the
- * real address.
+ * Right now we handle:
+ *
+ * - 'F' For symbolic Function descriptor pointers
+ * - 'S' For Symbolic direct pointers), but this can easily be
+ * extended in the future (network address types etc).
+ * - 'R' For a struct resouce pointer, it prints the range of
+ * addresses (not the name nor the flags)
+ *
+ * Note: The difference between 'S' and 'F' is that on ia64 and ppc64
+ * function pointers are really function descriptors, which contain a
+ * pointer the real address.
*/
static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field_width, int precision, int flags)
{
@@ -571,6 +592,8 @@ static char *pointer(const char *fmt, ch
/* Fallthrough */
case 'S':
return symbol_string(buf, end, ptr, field_width, precision, flags);
+ case 'R':
+ return resource_string(buf, end, ptr, field_width, precision, flags);
}
flags |= SMALL;
if (field_width == -1) {
@@ -590,6 +613,7 @@ static char *pointer(const char *fmt, ch
* This function follows C99 vsnprintf, but has some extensions:
* %pS output the name of a text symbol
* %pF output the name of a function pointer
+ * %pR output the address range in a struct resource
*
* The return value is the number of characters which would
* be generated for the given input, excluding the trailing
next prev parent reply other threads:[~2008-10-17 3:06 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-14 0:53 [PATCH] Fix broken debug output reserve_region_with_split() Benjamin Herrenschmidt
2008-10-14 1:04 ` H. Peter Anvin
2008-10-14 1:14 ` Yinghai Lu
2008-10-14 1:16 ` H. Peter Anvin
2008-10-14 1:34 ` David Miller
2008-10-14 1:41 ` Benjamin Herrenschmidt
2008-10-14 1:41 ` Benjamin Herrenschmidt
2008-10-14 1:45 ` David Miller
2008-10-14 2:15 ` Benjamin Herrenschmidt
2008-10-14 2:54 ` H. Peter Anvin
2008-10-14 3:47 ` Benjamin Herrenschmidt
2008-10-14 5:38 ` David Miller
2008-10-16 8:30 ` Geert Uytterhoeven
2008-10-16 8:38 ` David Miller
2008-10-16 9:02 ` H. Peter Anvin
2008-10-17 3:02 ` Benjamin Herrenschmidt
2008-10-17 3:06 ` Benjamin Herrenschmidt [this message]
2008-10-17 3:13 ` Roland Dreier
2008-10-17 3:31 ` Benjamin Herrenschmidt
2008-10-17 3:49 ` Linus Torvalds
2008-10-17 4:04 ` David Miller
2008-10-17 4:18 ` Linus Torvalds
2008-10-17 5:00 ` Benjamin Herrenschmidt
2008-10-17 5:24 ` David Miller
2008-10-17 5:12 ` Benjamin Herrenschmidt
2008-10-17 5:21 ` Benjamin Herrenschmidt
2008-10-17 10:13 ` Olivier Galibert
2008-10-17 15:54 ` Linus Torvalds
2008-10-17 20:30 ` H. Peter Anvin
2008-10-17 20:54 ` Linus Torvalds
2008-10-17 21:03 ` Benjamin Herrenschmidt
2008-10-17 21:11 ` Linus Torvalds
2008-10-17 21:45 ` Benjamin Herrenschmidt
2008-10-20 3:37 ` Benjamin Herrenschmidt
2008-10-17 5:21 ` David Miller
2008-10-17 6:36 ` Benjamin Herrenschmidt
2008-10-17 6:39 ` H. Peter Anvin
2008-10-17 6:47 ` David Miller
2008-10-17 6:51 ` H. Peter Anvin
2008-10-17 15:51 ` Linus Torvalds
2008-10-17 20:06 ` David Miller
2008-10-17 4:05 ` Benjamin Herrenschmidt
2008-10-17 6:36 ` H. Peter Anvin
2008-10-17 3:39 ` Yinghai Lu
2008-10-17 3:46 ` Benjamin Herrenschmidt
2008-10-17 6:38 ` H. Peter Anvin
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=1224212791.7654.63.camel@pasglop \
--to=benh@kernel.crashing.org \
--cc=Geert.Uytterhoeven@sonycom.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=torvalds@linux-foundation.org \
--cc=yhlu.kernel@gmail.com \
/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