aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-kmem.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-kmem.c')
-rw-r--r--tools/perf/builtin-kmem.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 924a9518931a..db474bbf3322 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -351,6 +351,7 @@ static void __print_result(struct rb_root *root, struct perf_session *session,
351 int n_lines, int is_caller) 351 int n_lines, int is_caller)
352{ 352{
353 struct rb_node *next; 353 struct rb_node *next;
354 struct kernel_info *kerninfo;
354 355
355 printf("%.102s\n", graph_dotted_line); 356 printf("%.102s\n", graph_dotted_line);
356 printf(" %-34s |", is_caller ? "Callsite": "Alloc Ptr"); 357 printf(" %-34s |", is_caller ? "Callsite": "Alloc Ptr");
@@ -359,23 +360,31 @@ static void __print_result(struct rb_root *root, struct perf_session *session,
359 360
360 next = rb_first(root); 361 next = rb_first(root);
361 362
363 kerninfo = kerninfo__findhost(&session->kerninfo_root);
364 if (!kerninfo) {
365 pr_err("__print_result: couldn't find kernel information\n");
366 return;
367 }
362 while (next && n_lines--) { 368 while (next && n_lines--) {
363 struct alloc_stat *data = rb_entry(next, struct alloc_stat, 369 struct alloc_stat *data = rb_entry(next, struct alloc_stat,
364 node); 370 node);
365 struct symbol *sym = NULL; 371 struct symbol *sym = NULL;
372 struct map_groups *kmaps = &kerninfo->kmaps;
373 struct map *map;
366 char buf[BUFSIZ]; 374 char buf[BUFSIZ];
367 u64 addr; 375 u64 addr;
368 376
369 if (is_caller) { 377 if (is_caller) {
370 addr = data->call_site; 378 addr = data->call_site;
371 if (!raw_ip) 379 if (!raw_ip)
372 sym = map_groups__find_function(&session->kmaps, addr, NULL); 380 sym = map_groups__find_function(kmaps, addr,
381 &map, NULL);
373 } else 382 } else
374 addr = data->ptr; 383 addr = data->ptr;
375 384
376 if (sym != NULL) 385 if (sym != NULL)
377 snprintf(buf, sizeof(buf), "%s+%Lx", sym->name, 386 snprintf(buf, sizeof(buf), "%s+%Lx", sym->name,
378 addr - sym->start); 387 addr - map->unmap_ip(map, sym->start));
379 else 388 else
380 snprintf(buf, sizeof(buf), "%#Lx", addr); 389 snprintf(buf, sizeof(buf), "%#Lx", addr);
381 printf(" %-34s |", buf); 390 printf(" %-34s |", buf);
@@ -488,6 +497,9 @@ static int __cmd_kmem(void)
488 if (session == NULL) 497 if (session == NULL)
489 return -ENOMEM; 498 return -ENOMEM;
490 499
500 if (perf_session__create_kernel_maps(session) < 0)
501 goto out_delete;
502
491 if (!perf_session__has_traces(session, "kmem record")) 503 if (!perf_session__has_traces(session, "kmem record"))
492 goto out_delete; 504 goto out_delete;
493 505