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.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 31f60a2535e0..225e963df105 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -275,9 +275,8 @@ static void process_free_event(void *data,
275 s_alloc->alloc_cpu = -1; 275 s_alloc->alloc_cpu = -1;
276} 276}
277 277
278static void 278static void process_raw_event(union perf_event *raw_event __used, void *data,
279process_raw_event(event_t *raw_event __used, void *data, 279 int cpu, u64 timestamp, struct thread *thread)
280 int cpu, u64 timestamp, struct thread *thread)
281{ 280{
282 struct event *event; 281 struct event *event;
283 int type; 282 int type;
@@ -304,22 +303,13 @@ process_raw_event(event_t *raw_event __used, void *data,
304 } 303 }
305} 304}
306 305
307static int process_sample_event(event_t *event, struct perf_session *session) 306static int process_sample_event(union perf_event *event,
307 struct perf_sample *sample,
308 struct perf_evsel *evsel __used,
309 struct perf_session *session)
308{ 310{
309 struct sample_data data; 311 struct thread *thread = perf_session__findnew(session, event->ip.pid);
310 struct thread *thread;
311 312
312 memset(&data, 0, sizeof(data));
313 data.time = -1;
314 data.cpu = -1;
315 data.period = 1;
316
317 event__parse_sample(event, session->sample_type, &data);
318
319 dump_printf("(IP, %d): %d/%d: %#Lx period: %Ld\n", event->header.misc,
320 data.pid, data.tid, data.ip, data.period);
321
322 thread = perf_session__findnew(session, event->ip.pid);
323 if (thread == NULL) { 313 if (thread == NULL) {
324 pr_debug("problem processing %d event, skipping it.\n", 314 pr_debug("problem processing %d event, skipping it.\n",
325 event->header.type); 315 event->header.type);
@@ -328,15 +318,15 @@ static int process_sample_event(event_t *event, struct perf_session *session)
328 318
329 dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid); 319 dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
330 320
331 process_raw_event(event, data.raw_data, data.cpu, 321 process_raw_event(event, sample->raw_data, sample->cpu,
332 data.time, thread); 322 sample->time, thread);
333 323
334 return 0; 324 return 0;
335} 325}
336 326
337static struct perf_event_ops event_ops = { 327static struct perf_event_ops event_ops = {
338 .sample = process_sample_event, 328 .sample = process_sample_event,
339 .comm = event__process_comm, 329 .comm = perf_event__process_comm,
340 .ordered_samples = true, 330 .ordered_samples = true,
341}; 331};
342 332
@@ -382,10 +372,10 @@ static void __print_result(struct rb_root *root, struct perf_session *session,
382 addr = data->ptr; 372 addr = data->ptr;
383 373
384 if (sym != NULL) 374 if (sym != NULL)
385 snprintf(buf, sizeof(buf), "%s+%Lx", sym->name, 375 snprintf(buf, sizeof(buf), "%s+%" PRIx64 "", sym->name,
386 addr - map->unmap_ip(map, sym->start)); 376 addr - map->unmap_ip(map, sym->start));
387 else 377 else
388 snprintf(buf, sizeof(buf), "%#Lx", addr); 378 snprintf(buf, sizeof(buf), "%#" PRIx64 "", addr);
389 printf(" %-34s |", buf); 379 printf(" %-34s |", buf);
390 380
391 printf(" %9llu/%-5lu | %9llu/%-5lu | %8lu | %8lu | %6.3f%%\n", 381 printf(" %9llu/%-5lu | %9llu/%-5lu | %8lu | %8lu | %6.3f%%\n",
@@ -492,7 +482,8 @@ static void sort_result(void)
492static int __cmd_kmem(void) 482static int __cmd_kmem(void)
493{ 483{
494 int err = -EINVAL; 484 int err = -EINVAL;
495 struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0, false); 485 struct perf_session *session = perf_session__new(input_name, O_RDONLY,
486 0, false, &event_ops);
496 if (session == NULL) 487 if (session == NULL)
497 return -ENOMEM; 488 return -ENOMEM;
498 489
@@ -747,6 +738,9 @@ static int __cmd_record(int argc, const char **argv)
747 rec_argc = ARRAY_SIZE(record_args) + argc - 1; 738 rec_argc = ARRAY_SIZE(record_args) + argc - 1;
748 rec_argv = calloc(rec_argc + 1, sizeof(char *)); 739 rec_argv = calloc(rec_argc + 1, sizeof(char *));
749 740
741 if (rec_argv == NULL)
742 return -ENOMEM;
743
750 for (i = 0; i < ARRAY_SIZE(record_args); i++) 744 for (i = 0; i < ARRAY_SIZE(record_args); i++)
751 rec_argv[i] = strdup(record_args[i]); 745 rec_argv[i] = strdup(record_args[i]);
752 746