From: Dmitry Antipov <dmitry.antipov@linaro.org>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: linux-kernel@vger.kernel.org, linaro-dev@lists.linaro.org,
patches@linaro.org
Subject: perf sched replay again
Date: Wed, 04 Jul 2012 13:23:10 +0400 [thread overview]
Message-ID: <4FF40B7E.20202@linaro.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 139 bytes --]
I remember that this was rejected some time ago. Nevertheless,
is it possible to accept this until we will have a better solution?
Dmitry
[-- Attachment #2: 0001-perf-sched-replay-fix-event-lookup.patch --]
[-- Type: text/plain, Size: 2849 bytes --]
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(-)
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);
--
1.7.7.6
next reply other threads:[~2012-07-04 9:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-04 9:23 Dmitry Antipov [this message]
2012-07-06 6:30 ` perf sched replay again Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FF40B7E.20202@linaro.org \
--to=dmitry.antipov@linaro.org \
--cc=acme@ghostprotocols.net \
--cc=linaro-dev@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.