Messages in this thread Patch in this message | | | Date | Mon, 6 Aug 2012 19:00:00 -0300 | From | Arnaldo Carvalho de Melo <> | Subject | Re: [PATCH 2/3] perf: teach perf inject to merge sched_stat_* and sched_switch events |
| |
Em Mon, Aug 06, 2012 at 11:43:04PM +0400, Andrey Wagin escreveu: > 2012/8/6 Arnaldo Carvalho de Melo <acme@ghostprotocols.net>: > >> +struct perf_session *session; > > perf_event__sched_stat (perf_inject.sample) uses "session" for getting > an event name. I don't know how to get it by another way
Can you try with the attached patch? We already lookup the event_format entries when we read the perf.data header so that we can cache evsel->name, we might as well cache the event_format in evsel->tp_format, so that tools don't have to relookup this for each sample.
It would look like:
static int perf_event__sched_stat(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct perf_evsel *evsel, struct machine *machine) { int type; struct event_format *e = evsel->tp_format; const char *evname = e->name;
- Arnaldo diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index b559929..a56c457 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -56,6 +56,7 @@ struct perf_evsel { int ids; struct hists hists; char *name; + struct event_format *tp_format; union { void *priv; off_t id_offset; diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 24c489b..5b328a4 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -2126,6 +2126,7 @@ static int perf_evsel__set_tracepoint_name(struct perf_evsel *evsel, if (event->name == NULL) return -1; + evsel->tp_format = event; return 0; } | |