diff options
Diffstat (limited to 'tools/perf/builtin-kmem.c')
| -rw-r--r-- | tools/perf/builtin-kmem.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 924a9518931a..31f60a2535e0 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c | |||
| @@ -335,8 +335,9 @@ static int process_sample_event(event_t *event, struct perf_session *session) | |||
| 335 | } | 335 | } |
| 336 | 336 | ||
| 337 | static struct perf_event_ops event_ops = { | 337 | static struct perf_event_ops event_ops = { |
| 338 | .sample = process_sample_event, | 338 | .sample = process_sample_event, |
| 339 | .comm = event__process_comm, | 339 | .comm = event__process_comm, |
| 340 | .ordered_samples = true, | ||
| 340 | }; | 341 | }; |
| 341 | 342 | ||
| 342 | static double fragmentation(unsigned long n_req, unsigned long n_alloc) | 343 | static double fragmentation(unsigned long n_req, unsigned long n_alloc) |
| @@ -351,6 +352,7 @@ static void __print_result(struct rb_root *root, struct perf_session *session, | |||
| 351 | int n_lines, int is_caller) | 352 | int n_lines, int is_caller) |
| 352 | { | 353 | { |
| 353 | struct rb_node *next; | 354 | struct rb_node *next; |
| 355 | struct machine *machine; | ||
| 354 | 356 | ||
| 355 | printf("%.102s\n", graph_dotted_line); | 357 | printf("%.102s\n", graph_dotted_line); |
| 356 | printf(" %-34s |", is_caller ? "Callsite": "Alloc Ptr"); | 358 | printf(" %-34s |", is_caller ? "Callsite": "Alloc Ptr"); |
| @@ -359,23 +361,29 @@ static void __print_result(struct rb_root *root, struct perf_session *session, | |||
| 359 | 361 | ||
| 360 | next = rb_first(root); | 362 | next = rb_first(root); |
| 361 | 363 | ||
| 364 | machine = perf_session__find_host_machine(session); | ||
| 365 | if (!machine) { | ||
| 366 | pr_err("__print_result: couldn't find kernel information\n"); | ||
| 367 | return; | ||
| 368 | } | ||
| 362 | while (next && n_lines--) { | 369 | while (next && n_lines--) { |
| 363 | struct alloc_stat *data = rb_entry(next, struct alloc_stat, | 370 | struct alloc_stat *data = rb_entry(next, struct alloc_stat, |
| 364 | node); | 371 | node); |
| 365 | struct symbol *sym = NULL; | 372 | struct symbol *sym = NULL; |
| 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 = machine__find_kernel_function(machine, addr, &map, NULL); |
| 373 | } else | 381 | } else |
| 374 | addr = data->ptr; | 382 | addr = data->ptr; |
| 375 | 383 | ||
| 376 | if (sym != NULL) | 384 | if (sym != NULL) |
| 377 | snprintf(buf, sizeof(buf), "%s+%Lx", sym->name, | 385 | snprintf(buf, sizeof(buf), "%s+%Lx", sym->name, |
| 378 | addr - sym->start); | 386 | addr - map->unmap_ip(map, sym->start)); |
| 379 | else | 387 | else |
| 380 | snprintf(buf, sizeof(buf), "%#Lx", addr); | 388 | snprintf(buf, sizeof(buf), "%#Lx", addr); |
| 381 | printf(" %-34s |", buf); | 389 | printf(" %-34s |", buf); |
| @@ -484,10 +492,13 @@ static void sort_result(void) | |||
| 484 | static int __cmd_kmem(void) | 492 | static int __cmd_kmem(void) |
| 485 | { | 493 | { |
| 486 | int err = -EINVAL; | 494 | int err = -EINVAL; |
| 487 | struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0); | 495 | struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0, false); |
| 488 | if (session == NULL) | 496 | if (session == NULL) |
| 489 | return -ENOMEM; | 497 | return -ENOMEM; |
| 490 | 498 | ||
| 499 | if (perf_session__create_kernel_maps(session) < 0) | ||
| 500 | goto out_delete; | ||
| 501 | |||
| 491 | if (!perf_session__has_traces(session, "kmem record")) | 502 | if (!perf_session__has_traces(session, "kmem record")) |
| 492 | goto out_delete; | 503 | goto out_delete; |
| 493 | 504 | ||
| @@ -718,7 +729,6 @@ static const char *record_args[] = { | |||
| 718 | "record", | 729 | "record", |
| 719 | "-a", | 730 | "-a", |
| 720 | "-R", | 731 | "-R", |
| 721 | "-M", | ||
| 722 | "-f", | 732 | "-f", |
| 723 | "-c", "1", | 733 | "-c", "1", |
| 724 | "-e", "kmem:kmalloc", | 734 | "-e", "kmem:kmalloc", |
