diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-11-25 08:19:45 -0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-11-28 10:38:56 -0200 |
commit | d20deb64e0490ee9442b5181bc08a62d2cadcb90 (patch) | |
tree | afdb3f6fc9abbce9d0a96b7049d1f8121178a356 /tools/perf/builtin-inject.c | |
parent | 7009cc34b964939815160d7de64cf0215cdbf8bb (diff) | |
download | kernel_goldelico_gta04-d20deb64e0490ee9442b5181bc08a62d2cadcb90.zip kernel_goldelico_gta04-d20deb64e0490ee9442b5181bc08a62d2cadcb90.tar.gz kernel_goldelico_gta04-d20deb64e0490ee9442b5181bc08a62d2cadcb90.tar.bz2 |
perf tools: Pass tool context in the the perf_event_ops functions
So that we don't need to have that many globals.
Next steps will remove the 'session' pointer, that in most cases is
not needed.
Then we can rename perf_event_ops to 'perf_tool' that better describes
this class hierarchy.
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-wp4djox7x6w1i2bab1pt4xxp@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-inject.c')
-rw-r--r-- | tools/perf/builtin-inject.c | 55 |
1 files changed, 34 insertions, 21 deletions
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 978751e..6ce6d80 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -16,7 +16,8 @@ static char const *input_name = "-"; static bool inject_build_ids; -static int perf_event__repipe_synth(union perf_event *event, +static int perf_event__repipe_synth(struct perf_event_ops *ops __used, + union perf_event *event, struct perf_session *session __used) { uint32_t size; @@ -36,47 +37,57 @@ static int perf_event__repipe_synth(union perf_event *event, return 0; } +static int perf_event__repipe_tracing_data_synth(union perf_event *event, + struct perf_session *session) +{ + return perf_event__repipe_synth(NULL, event, session); +} + static int perf_event__repipe_attr(union perf_event *event, struct perf_evlist **pevlist __used) { - return perf_event__repipe_synth(event, NULL); + return perf_event__repipe_synth(NULL, event, NULL); } -static int perf_event__repipe(union perf_event *event, +static int perf_event__repipe(struct perf_event_ops *ops, + union perf_event *event, struct perf_sample *sample __used, struct perf_session *session) { - return perf_event__repipe_synth(event, session); + return perf_event__repipe_synth(ops, event, session); } -static int perf_event__repipe_sample(union perf_event *event, +static int perf_event__repipe_sample(struct perf_event_ops *ops, + union perf_event *event, struct perf_sample *sample __used, struct perf_evsel *evsel __used, struct perf_session *session) { - return perf_event__repipe_synth(event, session); + return perf_event__repipe_synth(ops, event, session); } -static int perf_event__repipe_mmap(union perf_event *event, +static int perf_event__repipe_mmap(struct perf_event_ops *ops, + union perf_event *event, struct perf_sample *sample, struct perf_session *session) { int err; - err = perf_event__process_mmap(event, sample, session); - perf_event__repipe(event, sample, session); + err = perf_event__process_mmap(ops, event, sample, session); + perf_event__repipe(ops, event, sample, session); return err; } -static int perf_event__repipe_task(union perf_event *event, +static int perf_event__repipe_task(struct perf_event_ops *ops, + union perf_event *event, struct perf_sample *sample, struct perf_session *session) { int err; - err = perf_event__process_task(event, sample, session); - perf_event__repipe(event, sample, session); + err = perf_event__process_task(ops, event, sample, session); + perf_event__repipe(ops, event, sample, session); return err; } @@ -86,7 +97,7 @@ static int perf_event__repipe_tracing_data(union perf_event *event, { int err; - perf_event__repipe_synth(event, session); + perf_event__repipe_synth(NULL, event, session); err = perf_event__process_tracing_data(event, session); return err; @@ -106,7 +117,8 @@ static int dso__read_build_id(struct dso *self) return -1; } -static int dso__inject_build_id(struct dso *self, struct perf_session *session) +static int dso__inject_build_id(struct dso *self, struct perf_event_ops *ops, + struct perf_session *session) { u16 misc = PERF_RECORD_MISC_USER; struct machine *machine; @@ -126,7 +138,7 @@ static int dso__inject_build_id(struct dso *self, struct perf_session *session) if (self->kernel) misc = PERF_RECORD_MISC_KERNEL; - err = perf_event__synthesize_build_id(self, misc, perf_event__repipe, + err = perf_event__synthesize_build_id(ops, self, misc, perf_event__repipe, machine, session); if (err) { pr_err("Can't synthesize build_id event for %s\n", self->long_name); @@ -136,7 +148,8 @@ static int dso__inject_build_id(struct dso *self, struct perf_session *session) return 0; } -static int perf_event__inject_buildid(union perf_event *event, +static int perf_event__inject_buildid(struct perf_event_ops *ops, + union perf_event *event, struct perf_sample *sample, struct perf_evsel *evsel __used, struct perf_session *session) @@ -161,7 +174,7 @@ static int perf_event__inject_buildid(union perf_event *event, if (!al.map->dso->hit) { al.map->dso->hit = 1; if (map__load(al.map, NULL) >= 0) { - dso__inject_build_id(al.map->dso, session); + dso__inject_build_id(al.map->dso, ops, session); /* * If this fails, too bad, let the other side * account this as unresolved. @@ -174,7 +187,7 @@ static int perf_event__inject_buildid(union perf_event *event, } repipe: - perf_event__repipe(event, sample, session); + perf_event__repipe(ops, event, sample, session); return 0; } @@ -189,9 +202,9 @@ struct perf_event_ops inject_ops = { .throttle = perf_event__repipe, .unthrottle = perf_event__repipe, .attr = perf_event__repipe_attr, - .event_type = perf_event__repipe_synth, - .tracing_data = perf_event__repipe_synth, - .build_id = perf_event__repipe_synth, + .event_type = perf_event__repipe_synth, + .tracing_data = perf_event__repipe_tracing_data_synth, + .build_id = perf_event__repipe_synth, }; extern volatile int session_done; |