Ming Zhang wrote:
On Mon, 2008-03-03 at 09:19 -0500, Dave Anderson wrote:
I'm not sure whether cluttering the bt -f command output would
be all that worthwhile, but I'm thinking that this request may have
some merit with respect to the "rd" command. Currently the
"rd -s" option recognizes and translates kernel symbols that it
finds in the raw memory output. Maybe something like a "-S"
option could do that -- plus also recognize kernel virtual memory
addresses that come from the slab cache, and alternatively display
the slab cache namestring in some recognizable manner, i.e. bracketed,
or something like to that effect.
Then since "bt -f" displays the block of memory associated with
each stack frame, you could easily transfer the stack address
to a "rd -S [stack-address] [count]" command.
yes. it will be great if we can have a rd -S!
Apply the attached patch and see what you think. The "rd -S"
option supplements "-s" by also recognizing memory from slab
caches -- and alternatively displaying the slab cache name
in brackets.
Thanks,
Dave
Index: memory.c
===================================================================
RCS file: /nfs/projects/cvs/crash/memory.c,v
retrieving revision 1.167
diff -u -r1.167 memory.c
--- memory.c 11 Jan 2008 16:59:46 -0000 1.167
+++ memory.c 3 Mar 2008 15:40:09 -0000
@@ -97,7 +97,7 @@
static void dump_kmem_cache_info_v2(struct meminfo *);
static void kmem_cache_list_slub(void);
static ulong get_cpu_slab_ptr(struct meminfo *, int);
-static char *vaddr_to_kmem_cache(ulong, char *);
+static char *vaddr_to_kmem_cache(ulong, char *, int);
static ulong vaddr_to_slab(ulong);
static void do_slab_chain(int, struct meminfo *);
static void do_slab_chain_percpu_v1(long, struct meminfo *);
@@ -195,6 +195,7 @@
#define UDECIMAL (0x200)
#define ASCII_ENDLINE (0x400)
#define NO_ASCII (0x800)
+#define SLAB_CACHE (0x1000)
static ulong DISPLAY_DEFAULT;
@@ -869,7 +870,7 @@
memtype = KVADDR;
count = -1;
- while ((c = getopt(argcnt, args, "xme:pfudDuso:81:3:6:")) != EOF) {
+ while ((c = getopt(argcnt, args, "xme:pfudDusSo:81:3:6:")) != EOF) {
switch(c)
{
case '8':
@@ -915,9 +916,12 @@
break;
case 's':
- if (flag & DISPLAY_DEFAULT)
+ case 'S':
+ if (flag & DISPLAY_DEFAULT) {
flag |= SYMBOLIC;
- else {
+ if (c == 'S')
+ flag |= SLAB_CACHE;
+ } else {
error(INFO,
"-s only allowed with %d-bit display\n",
DISPLAY_DEFAULT == DISPLAY_64 ?
@@ -1086,6 +1090,7 @@
char ch;
int linelen;
char buf[BUFSIZE];
+ char slab[BUFSIZE];
int ascii_start;
char *hex_64_fmt = BITS32() ? "%.*llx " : "%.*lx ";
char *dec_64_fmt = BITS32() ? "%12lld " : "%15ld ";
@@ -1185,6 +1190,14 @@
linelen += strlen(buf)+1;
break;
}
+ if ((flag & SLAB_CACHE) &&
+ vaddr_to_kmem_cache(mem.u64, slab,
+ !VERBOSE)) {
+ sprintf(buf, "[%s]", slab);
+ fprintf(fp, "%-16s ", buf);
+ linelen += strlen(buf)+1;
+ break;
+ }
}
if (flag & HEXADECIMAL) {
fprintf(fp, hex_64_fmt, LONG_LONG_PRLEN,
@@ -1211,6 +1224,15 @@
linelen += strlen(buf)+1;
break;
}
+ if ((flag & SLAB_CACHE) &&
+ vaddr_to_kmem_cache(mem.u32, slab,
+ !VERBOSE)) {
+ sprintf(buf, "[%s]", slab);
+ fprintf(fp, INT_PRLEN == 16 ?
+ "%-16s " : "%-8s ", buf);
+ linelen += strlen(buf)+1;
+ break;
+ }
}
if (flag & HEXADECIMAL) {
fprintf(fp, "%.*x ", INT_PRLEN, mem.u32 );
@@ -7141,22 +7163,25 @@
* name of the cache to which it belongs.
*/
static char *
-vaddr_to_kmem_cache(ulong vaddr, char *buf)
+vaddr_to_kmem_cache(ulong vaddr, char *buf, int verbose)
{
physaddr_t paddr;
ulong page;
ulong cache;
if (!kvtop(NULL, vaddr, &paddr, 0)) {
- error(WARNING,
- "cannot make virtual-to-physical translation: %lx\n",
- vaddr);
+ if (verbose)
+ error(WARNING,
+ "cannot make virtual-to-physical translation: %lx\n",
+ vaddr);
return NULL;
}
if (!phys_to_page(paddr, &page)) {
- error(WARNING, "cannot find mem_map page for address: %lx\n",
- vaddr);
+ if (verbose)
+ error(WARNING,
+ "cannot find mem_map page for address: %lx\n",
+ vaddr);
return NULL;
}
@@ -7665,7 +7690,7 @@
si->cache = cache_cache = symbol_value("cache_cache");
if (si->flags & ADDRESS_SPECIFIED) {
- if (!(p1 = vaddr_to_kmem_cache(si->spec_addr, kbuf))) {
+ if (!(p1 = vaddr_to_kmem_cache(si->spec_addr, kbuf, VERBOSE))) {
error(INFO,
"address is not allocated in slab subsystem: %lx\n",
si->spec_addr);
@@ -7869,7 +7894,7 @@
si->cache = cache_cache = symbol_value("cache_cache");
if (si->flags & ADDRESS_SPECIFIED) {
- if (!(p1 = vaddr_to_kmem_cache(si->spec_addr, kbuf))) {
+ if (!(p1 = vaddr_to_kmem_cache(si->spec_addr, kbuf, VERBOSE))) {
error(INFO,
"address is not allocated in slab subsystem: %lx\n",
si->spec_addr);
@@ -8091,7 +8116,7 @@
cache_end = symbol_value("cache_chain");
if (si->flags & ADDRESS_SPECIFIED) {
- if (!(p1 = vaddr_to_kmem_cache(si->spec_addr, kbuf))) {
+ if (!(p1 = vaddr_to_kmem_cache(si->spec_addr, kbuf, VERBOSE))) {
error(INFO,
"address is not allocated in slab subsystem: %lx\n",
si->spec_addr);
@@ -10270,7 +10295,7 @@
*/
mi->flags = orig_flags;
mi->retval = 0;
- if ((vaddr != BADADDR) && vaddr_to_kmem_cache(vaddr, buf)) {
+ if ((vaddr != BADADDR) && vaddr_to_kmem_cache(vaddr, buf, VERBOSE)) {
BZERO(&tmp_meminfo, sizeof(struct meminfo));
tmp_meminfo.spec_addr = vaddr;
tmp_meminfo.memtype = KVADDR;
@@ -13353,7 +13378,8 @@
if ((p1 = is_slab_page(si, kbuf))) {
si->flags |= VERBOSE;
si->slab = (ulong)si->spec_addr;
- } else if (!(p1 = vaddr_to_kmem_cache(si->spec_addr, kbuf))) {
+ } else if (!(p1 = vaddr_to_kmem_cache(si->spec_addr, kbuf,
+ VERBOSE))) {
error(INFO,
"address is not allocated in slab subsystem: %lx\n",
si->spec_addr);
--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility