summaryrefslogtreecommitdiff
path: root/tools/perf/builtin-inject.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-11-28 07:56:39 -0200
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-11-28 10:39:12 -0200
commit743eb868657bdb1b26c7b24077ca21c67c82c777 (patch)
tree4803b557725213043ccd5d3f83d2eec796a49f69 /tools/perf/builtin-inject.c
parentd20deb64e0490ee9442b5181bc08a62d2cadcb90 (diff)
perf tools: Resolve machine earlier and pass it to perf_event_ops
Reducing the exposure of perf_session further, so that we can use the classes in cases where no perf.data file is created. 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-stua66dcscsezzrcdugvbmvd@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.c70
1 files changed, 38 insertions, 32 deletions
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 6ce6d80b59db..a5bcf81776fc 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -18,7 +18,7 @@ static bool inject_build_ids;
static int perf_event__repipe_synth(struct perf_event_ops *ops __used,
union perf_event *event,
- struct perf_session *session __used)
+ struct machine *machine __used)
{
uint32_t size;
void *buf = event;
@@ -37,10 +37,23 @@ static int perf_event__repipe_synth(struct perf_event_ops *ops __used,
return 0;
}
+static int perf_event__repipe_op2_synth(struct perf_event_ops *ops,
+ union perf_event *event,
+ struct perf_session *session __used)
+{
+ return perf_event__repipe_synth(ops, event, NULL);
+}
+
+static int perf_event__repipe_event_type_synth(struct perf_event_ops *ops,
+ union perf_event *event)
+{
+ return perf_event__repipe_synth(ops, event, NULL);
+}
+
static int perf_event__repipe_tracing_data_synth(union perf_event *event,
- struct perf_session *session)
+ struct perf_session *session __used)
{
- return perf_event__repipe_synth(NULL, event, session);
+ return perf_event__repipe_synth(NULL, event, NULL);
}
static int perf_event__repipe_attr(union perf_event *event,
@@ -52,29 +65,29 @@ static int perf_event__repipe_attr(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)
+ struct machine *machine)
{
- return perf_event__repipe_synth(ops, event, session);
+ return perf_event__repipe_synth(ops, event, machine);
}
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)
+ struct machine *machine)
{
- return perf_event__repipe_synth(ops, event, session);
+ return perf_event__repipe_synth(ops, event, machine);
}
static int perf_event__repipe_mmap(struct perf_event_ops *ops,
union perf_event *event,
struct perf_sample *sample,
- struct perf_session *session)
+ struct machine *machine)
{
int err;
- err = perf_event__process_mmap(ops, event, sample, session);
- perf_event__repipe(ops, event, sample, session);
+ err = perf_event__process_mmap(ops, event, sample, machine);
+ perf_event__repipe(ops, event, sample, machine);
return err;
}
@@ -82,12 +95,12 @@ static int perf_event__repipe_mmap(struct perf_event_ops *ops,
static int perf_event__repipe_task(struct perf_event_ops *ops,
union perf_event *event,
struct perf_sample *sample,
- struct perf_session *session)
+ struct machine *machine)
{
int err;
- err = perf_event__process_task(ops, event, sample, session);
- perf_event__repipe(ops, event, sample, session);
+ err = perf_event__process_task(ops, event, sample, machine);
+ perf_event__repipe(ops, event, sample, machine);
return err;
}
@@ -97,7 +110,7 @@ static int perf_event__repipe_tracing_data(union perf_event *event,
{
int err;
- perf_event__repipe_synth(NULL, event, session);
+ perf_event__repipe_synth(NULL, event, NULL);
err = perf_event__process_tracing_data(event, session);
return err;
@@ -118,10 +131,9 @@ static int dso__read_build_id(struct dso *self)
}
static int dso__inject_build_id(struct dso *self, struct perf_event_ops *ops,
- struct perf_session *session)
+ struct machine *machine)
{
u16 misc = PERF_RECORD_MISC_USER;
- struct machine *machine;
int err;
if (dso__read_build_id(self) < 0) {
@@ -129,17 +141,11 @@ static int dso__inject_build_id(struct dso *self, struct perf_event_ops *ops,
return -1;
}
- machine = perf_session__find_host_machine(session);
- if (machine == NULL) {
- pr_err("Can't find machine for session\n");
- return -1;
- }
-
if (self->kernel)
misc = PERF_RECORD_MISC_KERNEL;
err = perf_event__synthesize_build_id(ops, self, misc, perf_event__repipe,
- machine, session);
+ machine);
if (err) {
pr_err("Can't synthesize build_id event for %s\n", self->long_name);
return -1;
@@ -152,7 +158,7 @@ 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)
+ struct machine *machine)
{
struct addr_location al;
struct thread *thread;
@@ -160,21 +166,21 @@ static int perf_event__inject_buildid(struct perf_event_ops *ops,
cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
- thread = perf_session__findnew(session, event->ip.pid);
+ thread = machine__findnew_thread(machine, event->ip.pid);
if (thread == NULL) {
pr_err("problem processing %d event, skipping it.\n",
event->header.type);
goto repipe;
}
- thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION,
- event->ip.pid, event->ip.ip, &al);
+ thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION,
+ event->ip.ip, &al);
if (al.map != NULL) {
if (!al.map->dso->hit) {
al.map->dso->hit = 1;
if (map__load(al.map, NULL) >= 0) {
- dso__inject_build_id(al.map->dso, ops, session);
+ dso__inject_build_id(al.map->dso, ops, machine);
/*
* If this fails, too bad, let the other side
* account this as unresolved.
@@ -187,7 +193,7 @@ static int perf_event__inject_buildid(struct perf_event_ops *ops,
}
repipe:
- perf_event__repipe(ops, event, sample, session);
+ perf_event__repipe(ops, event, sample, machine);
return 0;
}
@@ -198,13 +204,13 @@ struct perf_event_ops inject_ops = {
.fork = perf_event__repipe,
.exit = perf_event__repipe,
.lost = perf_event__repipe,
- .read = perf_event__repipe,
+ .read = perf_event__repipe_sample,
.throttle = perf_event__repipe,
.unthrottle = perf_event__repipe,
.attr = perf_event__repipe_attr,
- .event_type = perf_event__repipe_synth,
+ .event_type = perf_event__repipe_event_type_synth,
.tracing_data = perf_event__repipe_tracing_data_synth,
- .build_id = perf_event__repipe_synth,
+ .build_id = perf_event__repipe_op2_synth,
};
extern volatile int session_done;