diff mbox

perf sched replay again

Message ID 4FF40B7E.20202@linaro.org
State New
Headers show

Commit Message

Dmitry Antipov July 4, 2012, 9:23 a.m. UTC
I remember that this was rejected some time ago. Nevertheless,
is it possible to accept this until we will have a better solution?

Dmitry
From 7b394670bee55ca694f921bd96f210b0d4c7dfe0 Mon Sep 17 00:00:00 2001
From: Dmitry Antipov <dmitry.antipov@linaro.org>
Date: Wed, 4 Jul 2012 13:20:59 +0400
Subject: [PATCH] perf sched replay: fix event lookup

Use new function trace_find_event_by_name to lookup events before
looking through /sys files. This helps 'perf sched replay' to map
event names to IDs correctly when processing perf.data recorded
on another machine.

Signed-off-by: Dmitry Antipov <dmitry.antipov@linaro.org>
---
 tools/perf/util/evlist.c            |   22 ++++++++++++++++++++--
 tools/perf/util/trace-event-parse.c |    4 ++++
 tools/perf/util/trace-event.h       |    1 +
 3 files changed, 25 insertions(+), 2 deletions(-)

Comments

Namhyung Kim July 6, 2012, 6:30 a.m. UTC | #1
Hi, Dmitry

On Wed, 04 Jul 2012 13:23:10 +0400, Dmitry Antipov wrote:
> I remember that this was rejected some time ago. Nevertheless,
> is it possible to accept this until we will have a better solution?
>

Why??? 

Ingo already merged da3789628f88 ("perf tools: Stop using a global
trace events description list"). Didn't it solve your problem?

On my tesing, it works well for cross-replay:

  $ ./perf sched -i ~/arm/perf.data replay
  run measurement overhead: 253 nsecs
  sleep measurement overhead: 55136 nsecs
  the run test took 1000013 nsecs
  the sleep test took 1057532 nsecs
  nr_run_events:        53
  nr_sleep_events:      62
  nr_wakeup_events:     31
  target-less wakeups:  1
  task      0 (           <unknown>:      1496), nr_events: 18
  task      1 (                perf:      1497), nr_events: 10
  task      2 (         ksoftirqd/0:         3), nr_events: 9
  task      3 (         kworker/0:1:       280), nr_events: 36
  task      4 (             swapper:         0), nr_events: 62
  task      5 (         sync_supers:       103), nr_events: 3
  task      6 (                init:         1), nr_events: 3
  task      7 (           flush-8:0:       560), nr_events: 3
  task      8 (            rsyslogd:      1135), nr_events: 3
  ------------------------------------------------------------
  #1  : 2664.545, ravg: 2664.54, cpu: 3125.45 / 3125.45
  #2  : 2664.978, ravg: 2664.59, cpu: 3124.99 / 3125.40
  #3  : 2664.736, ravg: 2664.60, cpu: 3125.68 / 3125.43
  #4  : 2664.620, ravg: 2664.60, cpu: 3125.96 / 3125.48
  #5  : 2665.132, ravg: 2664.66, cpu: 3126.02 / 3125.54
  #6  : 2665.096, ravg: 2664.70, cpu: 3083.47 / 3121.33
  #7  : 2665.585, ravg: 2664.79, cpu: 3125.66 / 3121.76
  #8  : 2664.839, ravg: 2664.79, cpu: 3126.01 / 3122.19
  #9  : 2664.750, ravg: 2664.79, cpu: 3125.38 / 3122.51
  #10 : 2668.297, ravg: 2665.14, cpu: 3116.82 / 3121.94
  
Of course, host and arm machine have different id's.

Thanks,
Namhyung
diff mbox

Patch

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 7400fb3..58a5433 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -17,6 +17,7 @@ 
 #include <unistd.h>
 
 #include "parse-events.h"
+#include "trace-event.h"
 
 #include <sys/mman.h>
 
@@ -242,12 +243,29 @@  int perf_evlist__set_tracepoints_handlers(struct perf_evlist *evlist,
 					  const struct perf_evsel_str_handler *assocs,
 					  size_t nr_assocs)
 {
+	struct event_format *event;
 	struct perf_evsel *evsel;
+	char *p, *sys, *name;
 	int err;
-	size_t i;
+	size_t i, off;
 
 	for (i = 0; i < nr_assocs; i++) {
-		err = trace_event__id(assocs[i].name);
+		err = -ENOENT;
+		p = strchr(assocs[i].name, ':');
+		if (!p)
+			goto out;
+		off = p - assocs[i].name;
+		sys = malloc(off + 1);
+		if (!sys)
+			err = -ENOMEM;
+		else {
+			memcpy(sys, assocs[i].name, off);
+			sys[off] = '\0';
+			name = p + 1;
+			event = trace_find_event_by_name(sys, name);
+			err = event ? event->id : trace_event__id(assocs[i].name);
+			free(sys);
+		}
 		if (err < 0)
 			goto out;
 
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index df2fddb..44cbb40 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -176,6 +176,10 @@  struct event_format *trace_find_event(int type)
 	return pevent_find_event(pevent, type);
 }
 
+struct event_format *trace_find_event_by_name(const char *sys, const char *name)
+{
+	return pevent_find_event_by_name(pevent, sys, name);
+}
 
 void print_trace_event(int cpu, void *data, int size)
 {
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
index 639852a..66f83a0 100644
--- a/tools/perf/util/trace-event.h
+++ b/tools/perf/util/trace-event.h
@@ -40,6 +40,7 @@  int parse_event_file(char *buf, unsigned long size, char *sys);
 
 struct pevent_record *trace_peek_data(int cpu);
 struct event_format *trace_find_event(int type);
+struct event_format *trace_find_event_by_name(const char *sys, const char *name);
 
 unsigned long long
 raw_field_value(struct event_format *event, const char *name, void *data);