diff options
Diffstat (limited to 'tools/perf/builtin-kmem.c')
-rw-r--r-- | tools/perf/builtin-kmem.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 5f209514f657..2071d2485913 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include "util/symbol.h" | 6 | #include "util/symbol.h" |
7 | #include "util/thread.h" | 7 | #include "util/thread.h" |
8 | #include "util/header.h" | 8 | #include "util/header.h" |
9 | #include "util/session.h" | ||
9 | 10 | ||
10 | #include "util/parse-options.h" | 11 | #include "util/parse-options.h" |
11 | #include "util/trace-event.h" | 12 | #include "util/trace-event.h" |
@@ -20,7 +21,6 @@ typedef int (*sort_fn_t)(struct alloc_stat *, struct alloc_stat *); | |||
20 | 21 | ||
21 | static char const *input_name = "perf.data"; | 22 | static char const *input_name = "perf.data"; |
22 | 23 | ||
23 | static struct perf_header *header; | ||
24 | static u64 sample_type; | 24 | static u64 sample_type; |
25 | 25 | ||
26 | static int alloc_flag; | 26 | static int alloc_flag; |
@@ -367,11 +367,18 @@ static struct perf_file_handler file_handler = { | |||
367 | 367 | ||
368 | static int read_events(void) | 368 | static int read_events(void) |
369 | { | 369 | { |
370 | int err; | ||
371 | struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0); | ||
372 | |||
373 | if (session == NULL) | ||
374 | return -ENOMEM; | ||
375 | |||
370 | register_idle_thread(); | 376 | register_idle_thread(); |
371 | register_perf_file_handler(&file_handler); | 377 | register_perf_file_handler(&file_handler); |
372 | 378 | ||
373 | return mmap_dispatch_perf_file(&header, input_name, 0, 0, | 379 | err = perf_session__process_events(session, 0, &event__cwdlen, &event__cwd); |
374 | &event__cwdlen, &event__cwd); | 380 | perf_session__delete(session); |
381 | return err; | ||
375 | } | 382 | } |
376 | 383 | ||
377 | static double fragmentation(unsigned long n_req, unsigned long n_alloc) | 384 | static double fragmentation(unsigned long n_req, unsigned long n_alloc) |
@@ -403,7 +410,7 @@ static void __print_result(struct rb_root *root, int n_lines, int is_caller) | |||
403 | if (is_caller) { | 410 | if (is_caller) { |
404 | addr = data->call_site; | 411 | addr = data->call_site; |
405 | if (!raw_ip) | 412 | if (!raw_ip) |
406 | sym = thread__find_function(kthread, addr, NULL); | 413 | sym = map_groups__find_function(kmaps, addr, NULL); |
407 | } else | 414 | } else |
408 | addr = data->ptr; | 415 | addr = data->ptr; |
409 | 416 | ||