perf kmem: Add new option to show raw ip
authorLi Zefan <lizf@cn.fujitsu.com>
Tue, 24 Nov 2009 05:25:48 +0000 (13:25 +0800)
committerIngo Molnar <mingo@elte.hu>
Tue, 24 Nov 2009 07:49:49 +0000 (08:49 +0100)
Add option "--raw-ip" to show raw ip instead of symbols:

 # ./perf kmem --stat caller --raw-ip
 ------------------------------------------------------------------------------
 Callsite                    |Total_alloc/Per | Total_req/Per | Hit  | Frag
 ------------------------------------------------------------------------------
 0xc05301aa                  |  733184/4096   |  733184/4096  |   179|   0.000%
 0xc0542ba0                  |  483328/4096   |  483328/4096  |   118|   0.000%
 ...

Also show symbols with format sym+offset instead of sym/offset.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: linux-mm@kvack.org <linux-mm@kvack.org>
LKML-Reference: <4B0B6E5C.4080900@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
tools/perf/builtin-kmem.c

index 256d18fa0471235533021595df0330ca9df29234..1ef43c212d9a590e87aa074a0ce9e7ccc4aae973 100644 (file)
@@ -32,15 +32,14 @@ sort_fn_t                   caller_sort_fn;
 static int                     alloc_lines = -1;
 static int                     caller_lines = -1;
 
+static bool                    raw_ip;
+
 static char                    *cwd;
 static int                     cwdlen;
 
 struct alloc_stat {
        union {
-               struct {
-                       char    *name;
-                       u64     call_site;
-               };
+               u64     call_site;
                u64     ptr;
        };
        u64     bytes_req;
@@ -323,12 +322,14 @@ static void __print_result(struct rb_root *root, int n_lines, int is_caller)
 
                if (is_caller) {
                        addr = data->call_site;
-                       sym = kernel_maps__find_symbol(addr, NULL, NULL);
+                       if (!raw_ip)
+                               sym = kernel_maps__find_symbol(addr,
+                                                              NULL, NULL);
                } else
                        addr = data->ptr;
 
                if (sym != NULL)
-                       snprintf(bf, sizeof(bf), "%s/%Lx", sym->name,
+                       snprintf(bf, sizeof(bf), "%s+%Lx", sym->name,
                                 addr - sym->start);
                else
                        snprintf(bf, sizeof(bf), "%#Lx", addr);
@@ -345,9 +346,9 @@ static void __print_result(struct rb_root *root, int n_lines, int is_caller)
        }
 
        if (n_lines == -1)
-               printf(" ...               | ...             | ...             | ...    | ...   \n");
+               printf(" ...                        | ...            | ...           | ...    | ...   \n");
 
-       printf(" ------------------------------------------------------------------------------\n");
+       printf("%.78s\n", graph_dotted_line);
 }
 
 static void print_summary(void)
@@ -558,6 +559,7 @@ static const struct option kmem_options[] = {
        OPT_CALLBACK('l', "line", NULL, "num",
                     "show n lins",
                     parse_line_opt),
+       OPT_BOOLEAN(0, "raw-ip", &raw_ip, "show raw ip instead of symbol"),
        OPT_END()
 };