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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent d20deb64
...@@ -83,12 +83,12 @@ static int process_sample_event(struct perf_event_ops *ops, ...@@ -83,12 +83,12 @@ static int process_sample_event(struct perf_event_ops *ops,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
struct perf_session *session) struct machine *machine)
{ {
struct perf_annotate *ann = container_of(ops, struct perf_annotate, ops); struct perf_annotate *ann = container_of(ops, struct perf_annotate, ops);
struct addr_location al; struct addr_location al;
if (perf_event__preprocess_sample(event, session, &al, sample, if (perf_event__preprocess_sample(event, machine, &al, sample,
symbol__annotate_init) < 0) { symbol__annotate_init) < 0) {
pr_warning("problem processing %d event, skipping it.\n", pr_warning("problem processing %d event, skipping it.\n",
event->header.type); event->header.type);
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "util/debug.h" #include "util/debug.h"
#include "util/event.h" #include "util/event.h"
#include "util/hist.h" #include "util/hist.h"
#include "util/evsel.h"
#include "util/session.h" #include "util/session.h"
#include "util/sort.h" #include "util/sort.h"
#include "util/symbol.h" #include "util/symbol.h"
...@@ -34,11 +35,11 @@ static int diff__process_sample_event(struct perf_event_ops *ops __used, ...@@ -34,11 +35,11 @@ static int diff__process_sample_event(struct perf_event_ops *ops __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel __used, struct perf_evsel *evsel __used,
struct perf_session *session) struct machine *machine)
{ {
struct addr_location al; struct addr_location al;
if (perf_event__preprocess_sample(event, session, &al, sample, NULL) < 0) { if (perf_event__preprocess_sample(event, machine, &al, sample, NULL) < 0) {
pr_warning("problem processing %d event, skipping it.\n", pr_warning("problem processing %d event, skipping it.\n",
event->header.type); event->header.type);
return -1; return -1;
...@@ -47,12 +48,12 @@ static int diff__process_sample_event(struct perf_event_ops *ops __used, ...@@ -47,12 +48,12 @@ static int diff__process_sample_event(struct perf_event_ops *ops __used,
if (al.filtered || al.sym == NULL) if (al.filtered || al.sym == NULL)
return 0; return 0;
if (hists__add_entry(&session->hists, &al, sample->period)) { if (hists__add_entry(&evsel->hists, &al, sample->period)) {
pr_warning("problem incrementing symbol period, skipping event\n"); pr_warning("problem incrementing symbol period, skipping event\n");
return -1; return -1;
} }
session->hists.stats.total_period += sample->period; evsel->hists.stats.total_period += sample->period;
return 0; return 0;
} }
......
...@@ -18,7 +18,7 @@ static bool inject_build_ids; ...@@ -18,7 +18,7 @@ static bool inject_build_ids;
static int perf_event__repipe_synth(struct perf_event_ops *ops __used, static int perf_event__repipe_synth(struct perf_event_ops *ops __used,
union perf_event *event, union perf_event *event,
struct perf_session *session __used) struct machine *machine __used)
{ {
uint32_t size; uint32_t size;
void *buf = event; void *buf = event;
...@@ -37,10 +37,23 @@ static int perf_event__repipe_synth(struct perf_event_ops *ops __used, ...@@ -37,10 +37,23 @@ static int perf_event__repipe_synth(struct perf_event_ops *ops __used,
return 0; 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, 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, static int perf_event__repipe_attr(union perf_event *event,
...@@ -52,29 +65,29 @@ 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, static int perf_event__repipe(struct perf_event_ops *ops,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, 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, static int perf_event__repipe_sample(struct perf_event_ops *ops,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct perf_evsel *evsel __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, static int perf_event__repipe_mmap(struct perf_event_ops *ops,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_session *session) struct machine *machine)
{ {
int err; int err;
err = perf_event__process_mmap(ops, event, sample, session); err = perf_event__process_mmap(ops, event, sample, machine);
perf_event__repipe(ops, event, sample, session); perf_event__repipe(ops, event, sample, machine);
return err; return err;
} }
...@@ -82,12 +95,12 @@ static int perf_event__repipe_mmap(struct perf_event_ops *ops, ...@@ -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, static int perf_event__repipe_task(struct perf_event_ops *ops,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_session *session) struct machine *machine)
{ {
int err; int err;
err = perf_event__process_task(ops, event, sample, session); err = perf_event__process_task(ops, event, sample, machine);
perf_event__repipe(ops, event, sample, session); perf_event__repipe(ops, event, sample, machine);
return err; return err;
} }
...@@ -97,7 +110,7 @@ static int perf_event__repipe_tracing_data(union perf_event *event, ...@@ -97,7 +110,7 @@ static int perf_event__repipe_tracing_data(union perf_event *event,
{ {
int err; int err;
perf_event__repipe_synth(NULL, event, session); perf_event__repipe_synth(NULL, event, NULL);
err = perf_event__process_tracing_data(event, session); err = perf_event__process_tracing_data(event, session);
return err; return err;
...@@ -118,10 +131,9 @@ static int dso__read_build_id(struct dso *self) ...@@ -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, 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; u16 misc = PERF_RECORD_MISC_USER;
struct machine *machine;
int err; int err;
if (dso__read_build_id(self) < 0) { 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, ...@@ -129,17 +141,11 @@ static int dso__inject_build_id(struct dso *self, struct perf_event_ops *ops,
return -1; 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) if (self->kernel)
misc = PERF_RECORD_MISC_KERNEL; misc = PERF_RECORD_MISC_KERNEL;
err = perf_event__synthesize_build_id(ops, self, misc, perf_event__repipe, err = perf_event__synthesize_build_id(ops, self, misc, perf_event__repipe,
machine, session); machine);
if (err) { if (err) {
pr_err("Can't synthesize build_id event for %s\n", self->long_name); pr_err("Can't synthesize build_id event for %s\n", self->long_name);
return -1; return -1;
...@@ -152,7 +158,7 @@ static int perf_event__inject_buildid(struct perf_event_ops *ops, ...@@ -152,7 +158,7 @@ static int perf_event__inject_buildid(struct perf_event_ops *ops,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel __used, struct perf_evsel *evsel __used,
struct perf_session *session) struct machine *machine)
{ {
struct addr_location al; struct addr_location al;
struct thread *thread; struct thread *thread;
...@@ -160,21 +166,21 @@ static int perf_event__inject_buildid(struct perf_event_ops *ops, ...@@ -160,21 +166,21 @@ static int perf_event__inject_buildid(struct perf_event_ops *ops,
cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; 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) { if (thread == NULL) {
pr_err("problem processing %d event, skipping it.\n", pr_err("problem processing %d event, skipping it.\n",
event->header.type); event->header.type);
goto repipe; goto repipe;
} }
thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION, thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION,
event->ip.pid, event->ip.ip, &al); event->ip.ip, &al);
if (al.map != NULL) { if (al.map != NULL) {
if (!al.map->dso->hit) { if (!al.map->dso->hit) {
al.map->dso->hit = 1; al.map->dso->hit = 1;
if (map__load(al.map, NULL) >= 0) { 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 * If this fails, too bad, let the other side
* account this as unresolved. * account this as unresolved.
...@@ -187,7 +193,7 @@ static int perf_event__inject_buildid(struct perf_event_ops *ops, ...@@ -187,7 +193,7 @@ static int perf_event__inject_buildid(struct perf_event_ops *ops,
} }
repipe: repipe:
perf_event__repipe(ops, event, sample, session); perf_event__repipe(ops, event, sample, machine);
return 0; return 0;
} }
...@@ -198,13 +204,13 @@ struct perf_event_ops inject_ops = { ...@@ -198,13 +204,13 @@ struct perf_event_ops inject_ops = {
.fork = perf_event__repipe, .fork = perf_event__repipe,
.exit = perf_event__repipe, .exit = perf_event__repipe,
.lost = perf_event__repipe, .lost = perf_event__repipe,
.read = perf_event__repipe, .read = perf_event__repipe_sample,
.throttle = perf_event__repipe, .throttle = perf_event__repipe,
.unthrottle = perf_event__repipe, .unthrottle = perf_event__repipe,
.attr = perf_event__repipe_attr, .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, .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; extern volatile int session_done;
......
...@@ -307,9 +307,9 @@ static int process_sample_event(struct perf_event_ops *ops __used, ...@@ -307,9 +307,9 @@ static int process_sample_event(struct perf_event_ops *ops __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel __used, struct perf_evsel *evsel __used,
struct perf_session *session) struct machine *machine)
{ {
struct thread *thread = perf_session__findnew(session, event->ip.pid); struct thread *thread = machine__findnew_thread(machine, event->ip.pid);
if (thread == NULL) { if (thread == NULL) {
pr_debug("problem processing %d event, skipping it.\n", pr_debug("problem processing %d event, skipping it.\n",
......
...@@ -849,9 +849,9 @@ static int process_sample_event(struct perf_event_ops *ops __used, ...@@ -849,9 +849,9 @@ static int process_sample_event(struct perf_event_ops *ops __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel __used, struct perf_evsel *evsel __used,
struct perf_session *s) struct machine *machine)
{ {
struct thread *thread = perf_session__findnew(s, sample->tid); struct thread *thread = machine__findnew_thread(machine, sample->tid);
if (thread == NULL) { if (thread == NULL) {
pr_debug("problem processing %d event, skipping it.\n", pr_debug("problem processing %d event, skipping it.\n",
......
...@@ -79,7 +79,7 @@ static void write_output(struct perf_record *rec, void *buf, size_t size) ...@@ -79,7 +79,7 @@ static void write_output(struct perf_record *rec, void *buf, size_t size)
static int process_synthesized_event(struct perf_event_ops *ops, static int process_synthesized_event(struct perf_event_ops *ops,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct perf_session *self __used) struct machine *machine __used)
{ {
struct perf_record *rec = container_of(ops, struct perf_record, ops); struct perf_record *rec = container_of(ops, struct perf_record, ops);
write_output(rec, event, event->header.size); write_output(rec, event, event->header.size);
...@@ -320,8 +320,6 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data) ...@@ -320,8 +320,6 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data)
{ {
int err; int err;
struct perf_event_ops *ops = data; struct perf_event_ops *ops = data;
struct perf_record *rec = container_of(ops, struct perf_record, ops);
struct perf_session *psession = rec->session;
if (machine__is_host(machine)) if (machine__is_host(machine))
return; return;
...@@ -335,7 +333,7 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data) ...@@ -335,7 +333,7 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data)
*in module instead of in guest kernel. *in module instead of in guest kernel.
*/ */
err = perf_event__synthesize_modules(ops, process_synthesized_event, err = perf_event__synthesize_modules(ops, process_synthesized_event,
psession, machine); machine);
if (err < 0) if (err < 0)
pr_err("Couldn't record guest kernel [%d]'s reference" pr_err("Couldn't record guest kernel [%d]'s reference"
" relocation symbol.\n", machine->pid); " relocation symbol.\n", machine->pid);
...@@ -345,11 +343,10 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data) ...@@ -345,11 +343,10 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data)
* have no _text sometimes. * have no _text sometimes.
*/ */
err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event, err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event,
psession, machine, "_text"); machine, "_text");
if (err < 0) if (err < 0)
err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event, err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event,
psession, machine, machine, "_stext");
"_stext");
if (err < 0) if (err < 0)
pr_err("Couldn't record guest kernel [%d]'s reference" pr_err("Couldn't record guest kernel [%d]'s reference"
" relocation symbol.\n", machine->pid); " relocation symbol.\n", machine->pid);
...@@ -497,6 +494,12 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) ...@@ -497,6 +494,12 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
rec->post_processing_offset = lseek(output, 0, SEEK_CUR); rec->post_processing_offset = lseek(output, 0, SEEK_CUR);
machine = perf_session__find_host_machine(session);
if (!machine) {
pr_err("Couldn't find native kernel information.\n");
return -1;
}
if (opts->pipe_output) { if (opts->pipe_output) {
err = perf_event__synthesize_attrs(ops, session, err = perf_event__synthesize_attrs(ops, session,
process_synthesized_event); process_synthesized_event);
...@@ -506,7 +509,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) ...@@ -506,7 +509,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
} }
err = perf_event__synthesize_event_types(ops, process_synthesized_event, err = perf_event__synthesize_event_types(ops, process_synthesized_event,
session); machine);
if (err < 0) { if (err < 0) {
pr_err("Couldn't synthesize event_types.\n"); pr_err("Couldn't synthesize event_types.\n");
return err; return err;
...@@ -522,8 +525,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) ...@@ -522,8 +525,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
* propagate errors that now are calling die() * propagate errors that now are calling die()
*/ */
err = perf_event__synthesize_tracing_data(ops, output, evsel_list, err = perf_event__synthesize_tracing_data(ops, output, evsel_list,
process_synthesized_event, process_synthesized_event);
session);
if (err <= 0) { if (err <= 0) {
pr_err("Couldn't record tracing data.\n"); pr_err("Couldn't record tracing data.\n");
return err; return err;
...@@ -532,24 +534,18 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) ...@@ -532,24 +534,18 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
} }
} }
machine = perf_session__find_host_machine(session);
if (!machine) {
pr_err("Couldn't find native kernel information.\n");
return -1;
}
err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event, err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event,
session, machine, "_text"); machine, "_text");
if (err < 0) if (err < 0)
err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event, err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event,
session, machine, "_stext"); machine, "_stext");
if (err < 0) if (err < 0)
pr_err("Couldn't record kernel reference relocation symbol\n" pr_err("Couldn't record kernel reference relocation symbol\n"
"Symbol resolution may be skewed if relocation was used (e.g. kexec).\n" "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n"
"Check /proc/kallsyms permission or run as root.\n"); "Check /proc/kallsyms permission or run as root.\n");
err = perf_event__synthesize_modules(ops, process_synthesized_event, err = perf_event__synthesize_modules(ops, process_synthesized_event,
session, machine); machine);
if (err < 0) if (err < 0)
pr_err("Couldn't record kernel module information.\n" pr_err("Couldn't record kernel module information.\n"
"Symbol resolution may be skewed if relocation was used (e.g. kexec).\n" "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n"
...@@ -562,10 +558,10 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) ...@@ -562,10 +558,10 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
if (!opts->system_wide) if (!opts->system_wide)
perf_event__synthesize_thread_map(ops, evsel_list->threads, perf_event__synthesize_thread_map(ops, evsel_list->threads,
process_synthesized_event, process_synthesized_event,
session); machine);
else else
perf_event__synthesize_threads(ops, process_synthesized_event, perf_event__synthesize_threads(ops, process_synthesized_event,
session); machine);
if (rec->realtime_prio) { if (rec->realtime_prio) {
struct sched_param param; struct sched_param param;
......
...@@ -52,18 +52,18 @@ struct perf_report { ...@@ -52,18 +52,18 @@ struct perf_report {
DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
}; };
static int perf_session__add_hist_entry(struct perf_session *session, static int perf_evsel__add_hist_entry(struct perf_evsel *evsel,
struct addr_location *al, struct addr_location *al,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel) struct machine *machine)
{ {
struct symbol *parent = NULL; struct symbol *parent = NULL;
int err = 0; int err = 0;
struct hist_entry *he; struct hist_entry *he;
if ((sort__has_parent || symbol_conf.use_callchain) && sample->callchain) { if ((sort__has_parent || symbol_conf.use_callchain) && sample->callchain) {
err = perf_session__resolve_callchain(session, evsel, al->thread, err = machine__resolve_callchain(machine, evsel, al->thread,
sample->callchain, &parent); sample->callchain, &parent);
if (err) if (err)
return err; return err;
} }
...@@ -107,12 +107,12 @@ static int process_sample_event(struct perf_event_ops *ops, ...@@ -107,12 +107,12 @@ static int process_sample_event(struct perf_event_ops *ops,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
struct perf_session *session) struct machine *machine)
{ {
struct perf_report *rep = container_of(ops, struct perf_report, ops); struct perf_report *rep = container_of(ops, struct perf_report, ops);
struct addr_location al; struct addr_location al;
if (perf_event__preprocess_sample(event, session, &al, sample, if (perf_event__preprocess_sample(event, machine, &al, sample,
rep->annotate_init) < 0) { rep->annotate_init) < 0) {
fprintf(stderr, "problem processing %d event, skipping it.\n", fprintf(stderr, "problem processing %d event, skipping it.\n",
event->header.type); event->header.type);
...@@ -128,7 +128,7 @@ static int process_sample_event(struct perf_event_ops *ops, ...@@ -128,7 +128,7 @@ static int process_sample_event(struct perf_event_ops *ops,
if (al.map != NULL) if (al.map != NULL)
al.map->dso->hit = 1; al.map->dso->hit = 1;
if (perf_session__add_hist_entry(session, &al, sample, evsel)) { if (perf_evsel__add_hist_entry(evsel, &al, sample, machine)) {
pr_debug("problem incrementing symbol period, skipping event\n"); pr_debug("problem incrementing symbol period, skipping event\n");
return -1; return -1;
} }
...@@ -139,11 +139,11 @@ static int process_sample_event(struct perf_event_ops *ops, ...@@ -139,11 +139,11 @@ static int process_sample_event(struct perf_event_ops *ops,
static int process_read_event(struct perf_event_ops *ops, static int process_read_event(struct perf_event_ops *ops,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct perf_session *session) struct perf_evsel *evsel,
struct machine *machine __used)
{ {
struct perf_report *rep = container_of(ops, struct perf_report, ops); struct perf_report *rep = container_of(ops, struct perf_report, ops);
struct perf_evsel *evsel = perf_evlist__id2evsel(session->evlist,
event->read.id);
if (rep->show_threads) { if (rep->show_threads) {
const char *name = evsel ? event_name(evsel) : "unknown"; const char *name = evsel ? event_name(evsel) : "unknown";
perf_read_values_add_value(&rep->show_threads_values, perf_read_values_add_value(&rep->show_threads_values,
......
This diff is collapsed.
...@@ -315,7 +315,7 @@ static bool sample_addr_correlates_sym(struct perf_event_attr *attr) ...@@ -315,7 +315,7 @@ static bool sample_addr_correlates_sym(struct perf_event_attr *attr)
static void print_sample_addr(union perf_event *event, static void print_sample_addr(union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_session *session, struct machine *machine,
struct thread *thread, struct thread *thread,
struct perf_event_attr *attr) struct perf_event_attr *attr)
{ {
...@@ -328,11 +328,11 @@ static void print_sample_addr(union perf_event *event, ...@@ -328,11 +328,11 @@ static void print_sample_addr(union perf_event *event,
if (!sample_addr_correlates_sym(attr)) if (!sample_addr_correlates_sym(attr))
return; return;
thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION, thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION,
event->ip.pid, sample->addr, &al); sample->addr, &al);
if (!al.map) if (!al.map)
thread__find_addr_map(thread, session, cpumode, MAP__VARIABLE, thread__find_addr_map(thread, machine, cpumode, MAP__VARIABLE,
event->ip.pid, sample->addr, &al); sample->addr, &al);
al.cpu = sample->cpu; al.cpu = sample->cpu;
al.sym = NULL; al.sym = NULL;
...@@ -362,7 +362,7 @@ static void print_sample_addr(union perf_event *event, ...@@ -362,7 +362,7 @@ static void print_sample_addr(union perf_event *event,
static void process_event(union perf_event *event __unused, static void process_event(union perf_event *event __unused,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
struct perf_session *session, struct machine *machine,
struct thread *thread) struct thread *thread)
{ {
struct perf_event_attr *attr = &evsel->attr; struct perf_event_attr *attr = &evsel->attr;
...@@ -377,15 +377,15 @@ static void process_event(union perf_event *event __unused, ...@@ -377,15 +377,15 @@ static void process_event(union perf_event *event __unused,
sample->raw_size); sample->raw_size);
if (PRINT_FIELD(ADDR)) if (PRINT_FIELD(ADDR))
print_sample_addr(event, sample, session, thread, attr); print_sample_addr(event, sample, machine, thread, attr);
if (PRINT_FIELD(IP)) { if (PRINT_FIELD(IP)) {
if (!symbol_conf.use_callchain) if (!symbol_conf.use_callchain)
printf(" "); printf(" ");
else else
printf("\n"); printf("\n");
perf_session__print_ip(event, evsel, sample, session, perf_event__print_ip(event, sample, machine, evsel,
PRINT_FIELD(SYM), PRINT_FIELD(DSO)); PRINT_FIELD(SYM), PRINT_FIELD(DSO));
} }
printf("\n"); printf("\n");
...@@ -438,9 +438,9 @@ static int process_sample_event(struct perf_event_ops *ops __used, ...@@ -438,9 +438,9 @@ static int process_sample_event(struct perf_event_ops *ops __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
struct perf_session *session) struct machine *machine)
{ {
struct thread *thread = perf_session__findnew(session, event->ip.pid); struct thread *thread = machine__findnew_thread(machine, event->ip.pid);
if (thread == NULL) { if (thread == NULL) {
pr_debug("problem processing %d event, skipping it.\n", pr_debug("problem processing %d event, skipping it.\n",
...@@ -462,9 +462,9 @@ static int process_sample_event(struct perf_event_ops *ops __used, ...@@ -462,9 +462,9 @@ static int process_sample_event(struct perf_event_ops *ops __used,
if (cpu_list && !test_bit(sample->cpu, cpu_bitmap)) if (cpu_list && !test_bit(sample->cpu, cpu_bitmap))
return 0; return 0;
scripting_ops->process_event(event, sample, evsel, session, thread); scripting_ops->process_event(event, sample, evsel, machine, thread);
session->hists.stats.total_period += sample->period; evsel->hists.stats.total_period += sample->period;
return 0; return 0;
} }
......
...@@ -277,7 +277,7 @@ static u64 cpus_pstate_state[MAX_CPUS]; ...@@ -277,7 +277,7 @@ static u64 cpus_pstate_state[MAX_CPUS];
static int process_comm_event(struct perf_event_ops *ops __used, static int process_comm_event(struct perf_event_ops *ops __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct perf_session *session __used) struct machine *machine __used)
{ {
pid_set_comm(event->comm.tid, event->comm.comm); pid_set_comm(event->comm.tid, event->comm.comm);
return 0; return 0;
...@@ -286,7 +286,7 @@ static int process_comm_event(struct perf_event_ops *ops __used, ...@@ -286,7 +286,7 @@ static int process_comm_event(struct perf_event_ops *ops __used,
static int process_fork_event(struct perf_event_ops *ops __used, static int process_fork_event(struct perf_event_ops *ops __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct perf_session *session __used) struct machine *machine __used)
{ {
pid_fork(event->fork.pid, event->fork.ppid, event->fork.time); pid_fork(event->fork.pid, event->fork.ppid, event->fork.time);
return 0; return 0;
...@@ -295,7 +295,7 @@ static int process_fork_event(struct perf_event_ops *ops __used, ...@@ -295,7 +295,7 @@ static int process_fork_event(struct perf_event_ops *ops __used,
static int process_exit_event(struct perf_event_ops *ops __used, static int process_exit_event(struct perf_event_ops *ops __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct perf_session *session __used) struct machine *machine __used)
{ {
pid_exit(event->fork.pid, event->fork.time); pid_exit(event->fork.pid, event->fork.time);
return 0; return 0;
...@@ -494,7 +494,7 @@ static int process_sample_event(struct perf_event_ops *ops __used, ...@@ -494,7 +494,7 @@ static int process_sample_event(struct perf_event_ops *ops __used,
union perf_event *event __used, union perf_event *event __used,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
struct perf_session *session __used) struct machine *machine __used)
{ {
struct trace_entry *te; struct trace_entry *te;
......
...@@ -258,11 +258,9 @@ static void show_details(struct hist_entry *he) ...@@ -258,11 +258,9 @@ static void show_details(struct hist_entry *he)
static const char CONSOLE_CLEAR[] = ""; static const char CONSOLE_CLEAR[] = "";
static struct hist_entry * static struct hist_entry *perf_evsel__add_hist_entry(struct perf_evsel *evsel,
perf_session__add_hist_entry(struct perf_session *session, struct addr_location *al,
struct addr_location *al, struct perf_sample *sample)
struct perf_sample *sample,
struct perf_evsel *evsel)
{ {
struct hist_entry *he; struct hist_entry *he;
...@@ -270,7 +268,7 @@ static struct hist_entry * ...@@ -270,7 +268,7 @@ static struct hist_entry *
if (he == NULL) if (he == NULL)
return NULL; return NULL;
session->hists.stats.total_period += sample->period; evsel->hists.stats.total_period += sample->period;
hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
return he; return he;
} }
...@@ -675,44 +673,12 @@ static int symbol_filter(struct map *map __used, struct symbol *sym) ...@@ -675,44 +673,12 @@ static int symbol_filter(struct map *map __used, struct symbol *sym)
static void perf_event__process_sample(const union perf_event *event, static void perf_event__process_sample(const union perf_event *event,
struct perf_evsel *evsel, struct perf_evsel *evsel,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_session *session) struct machine *machine)
{ {
struct symbol *parent = NULL; struct symbol *parent = NULL;
u64 ip = event->ip.ip; u64 ip = event->ip.ip;
struct addr_location al; struct addr_location al;
struct machine *machine;
int err; int err;
u8 origin = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
++top.samples;
switch (origin) {
case PERF_RECORD_MISC_USER:
++top.us_samples;
if (top.hide_user_symbols)
return;
machine = perf_session__find_host_machine(session);
break;
case PERF_RECORD_MISC_KERNEL:
++top.kernel_samples;
if (top.hide_kernel_symbols)
return;
machine = perf_session__find_host_machine(session);
break;
case PERF_RECORD_MISC_GUEST_KERNEL:
++top.guest_kernel_samples;
machine = perf_session__find_machine(session, event->ip.pid);
break;
case PERF_RECORD_MISC_GUEST_USER:
++top.guest_us_samples;
/*
* TODO: we don't process guest user from host side
* except simple counting.
*/
return;
default:
return;
}
if (!machine && perf_guest) { if (!machine && perf_guest) {
pr_err("Can't find guest [%d]'s kernel information\n", pr_err("Can't find guest [%d]'s kernel information\n",
...@@ -723,7 +689,7 @@ static void perf_event__process_sample(const union perf_event *event, ...@@ -723,7 +689,7 @@ static void perf_event__process_sample(const union perf_event *event,
if (event->header.misc & PERF_RECORD_MISC_EXACT_IP) if (event->header.misc & PERF_RECORD_MISC_EXACT_IP)
top.exact_samples++; top.exact_samples++;
if (perf_event__preprocess_sample(event, session, &al, sample, if (perf_event__preprocess_sample(event, machine, &al, sample,
symbol_filter) < 0 || symbol_filter) < 0 ||
al.filtered) al.filtered)
return; return;
...@@ -777,13 +743,13 @@ static void perf_event__process_sample(const union perf_event *event, ...@@ -777,13 +743,13 @@ static void perf_event__process_sample(const union perf_event *event,
if ((sort__has_parent || symbol_conf.use_callchain) && if ((sort__has_parent || symbol_conf.use_callchain) &&
sample->callchain) { sample->callchain) {
err = perf_session__resolve_callchain(session, evsel, al.thread, err = machine__resolve_callchain(machine, evsel, al.thread,
sample->callchain, &parent); sample->callchain, &parent);
if (err) if (err)
return; return;
} }
he = perf_session__add_hist_entry(session, &al, sample, evsel); he = perf_evsel__add_hist_entry(evsel, &al, sample);
if (he == NULL) { if (he == NULL) {
pr_err("Problem incrementing symbol period, skipping event\n"); pr_err("Problem incrementing symbol period, skipping event\n");
return; return;
...@@ -808,6 +774,8 @@ static void perf_session__mmap_read_idx(struct perf_session *self, int idx) ...@@ -808,6 +774,8 @@ static void perf_session__mmap_read_idx(struct perf_session *self, int idx)
struct perf_sample sample; struct perf_sample sample;
struct perf_evsel *evsel; struct perf_evsel *evsel;
union perf_event *event; union perf_event *event;
struct machine *machine;
u8 origin;
int ret; int ret;
while ((event = perf_evlist__mmap_read(top.evlist, idx)) != NULL) { while ((event = perf_evlist__mmap_read(top.evlist, idx)) != NULL) {
...@@ -820,11 +788,45 @@ static void perf_session__mmap_read_idx(struct perf_session *self, int idx) ...@@ -820,11 +788,45 @@ static void perf_session__mmap_read_idx(struct perf_session *self, int idx)
evsel = perf_evlist__id2evsel(self->evlist, sample.id); evsel = perf_evlist__id2evsel(self->evlist, sample.id);
assert(evsel != NULL); assert(evsel != NULL);
origin = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
if (event->header.type == PERF_RECORD_SAMPLE) if (event->header.type == PERF_RECORD_SAMPLE)
perf_event__process_sample(event, evsel, &sample, self); ++top.samples;
switch (origin) {
case PERF_RECORD_MISC_USER:
++top.us_samples;
if (top.hide_user_symbols)
continue;
machine = perf_session__find_host_machine(self);
break;
case PERF_RECORD_MISC_KERNEL:
++top.kernel_samples;
if (top.hide_kernel_symbols)
continue;
machine = perf_session__find_host_machine(self);
break;
case PERF_RECORD_MISC_GUEST_KERNEL:
++top.guest_kernel_samples;
machine = perf_session__find_machine(self, event->ip.pid);
break;
case PERF_RECORD_MISC_GUEST_USER:
++top.guest_us_samples;
/*
* TODO: we don't process guest user from host side
* except simple counting.
*/
/* Fall thru */
default:
continue;
}
if (event->header.type == PERF_RECORD_SAMPLE)
perf_event__process_sample(event, evsel, &sample, machine);
else if (event->header.type < PERF_RECORD_MAX) { else if (event->header.type < PERF_RECORD_MAX) {
hists__inc_nr_events(&evsel->hists, event->header.type); hists__inc_nr_events(&evsel->hists, event->header.type);
perf_event__process(&top.ops, event, &sample, self); perf_event__process(&top.ops, event, &sample, machine);
} else } else
++self->hists.stats.nr_unknown_events; ++self->hists.stats.nr_unknown_events;
} }
...@@ -967,10 +969,11 @@ static int __cmd_top(void) ...@@ -967,10 +969,11 @@ static int __cmd_top(void)
if (top.target_tid != -1) if (top.target_tid != -1)
perf_event__synthesize_thread_map(&top.ops, top.evlist->threads, perf_event__synthesize_thread_map(&top.ops, top.evlist->threads,
perf_event__process, top.session); perf_event__process,
&top.session->host_machine);
else else
perf_event__synthesize_threads(&top.ops, perf_event__process, top.session); perf_event__synthesize_threads(&top.ops, perf_event__process,
&top.session->host_machine);
start_counters(top.evlist); start_counters(top.evlist);
top.session->evlist = top.evlist; top.session->evlist = top.evlist;
perf_session__update_sample_type(top.session); perf_session__update_sample_type(top.session);
......
...@@ -19,11 +19,11 @@ static int build_id__mark_dso_hit(struct perf_event_ops *ops __used, ...@@ -19,11 +19,11 @@ static int build_id__mark_dso_hit(struct perf_event_ops *ops __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct perf_evsel *evsel __used, struct perf_evsel *evsel __used,
struct perf_session *session) struct machine *machine)
{ {
struct addr_location al; struct addr_location al;
u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
struct thread *thread = perf_session__findnew(session, event->ip.pid); struct thread *thread = machine__findnew_thread(machine, event->ip.pid);
if (thread == NULL) { if (thread == NULL) {
pr_err("problem processing %d event, skipping it.\n", pr_err("problem processing %d event, skipping it.\n",
...@@ -31,8 +31,8 @@ static int build_id__mark_dso_hit(struct perf_event_ops *ops __used, ...@@ -31,8 +31,8 @@ static int build_id__mark_dso_hit(struct perf_event_ops *ops __used,
return -1; return -1;
} }
thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION, thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION,
event->ip.pid, event->ip.ip, &al); event->ip.ip, &al);
if (al.map != NULL) if (al.map != NULL)
al.map->dso->hit = 1; al.map->dso->hit = 1;
...@@ -43,16 +43,16 @@ static int build_id__mark_dso_hit(struct perf_event_ops *ops __used, ...@@ -43,16 +43,16 @@ static int build_id__mark_dso_hit(struct perf_event_ops *ops __used,
static int perf_event__exit_del_thread(struct perf_event_ops *ops __used, static int perf_event__exit_del_thread(struct perf_event_ops *ops __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct perf_session *session) struct machine *machine)
{ {
struct thread *thread = perf_session__findnew(session, event->fork.tid); struct thread *thread = machine__findnew_thread(machine, event->fork.tid);
dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid, dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid,
event->fork.ppid, event->fork.ptid); event->fork.ppid, event->fork.ptid);
if (thread) { if (thread) {
rb_erase(&thread->rb_node, &session->host_machine.threads); rb_erase(&thread->rb_node, &machine->threads);
session->host_machine.last_match = NULL; machine->last_match = NULL;
thread__delete(thread); thread__delete(thread);
} }
......
This diff is collapsed.
...@@ -142,56 +142,53 @@ union perf_event { ...@@ -142,56 +142,53 @@ union perf_event {
void perf_event__print_totals(void); void perf_event__print_totals(void);
struct perf_event_ops; struct perf_event_ops;
struct perf_session;
struct thread_map; struct thread_map;
typedef int (*perf_event__handler_t)(struct perf_event_ops *ops, typedef int (*perf_event__handler_t)(struct perf_event_ops *ops,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_session *session); struct machine *machine);
int perf_event__synthesize_thread_map(struct perf_event_ops *ops, int perf_event__synthesize_thread_map(struct perf_event_ops *ops,
struct thread_map *threads, struct thread_map *threads,
perf_event__handler_t process, perf_event__handler_t process,
struct perf_session *session); struct machine *machine);
int perf_event__synthesize_threads(struct perf_event_ops *ops, int perf_event__synthesize_threads(struct perf_event_ops *ops,
perf_event__handler_t process, perf_event__handler_t process,
struct perf_session *session); struct machine *machine);
int perf_event__synthesize_kernel_mmap(struct perf_event_ops *ops, int perf_event__synthesize_kernel_mmap(struct perf_event_ops *ops,
perf_event__handler_t process, perf_event__handler_t process,
struct perf_session *session,
struct machine *machine, struct machine *machine,
const char *symbol_name); const char *symbol_name);
int perf_event__synthesize_modules(struct perf_event_ops *ops, int perf_event__synthesize_modules(struct perf_event_ops *ops,
perf_event__handler_t process, perf_event__handler_t process,
struct perf_session *session,
struct machine *machine); struct machine *machine);
int perf_event__process_comm(struct perf_event_ops *ops, int perf_event__process_comm(struct perf_event_ops *ops,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_session *session); struct machine *machine);
int perf_event__process_lost(struct perf_event_ops *ops, int perf_event__process_lost(struct perf_event_ops *ops,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_session *session); struct machine *machine);
int perf_event__process_mmap(struct perf_event_ops *ops, int perf_event__process_mmap(struct perf_event_ops *ops,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_session *session); struct machine *machine);
int perf_event__process_task(struct perf_event_ops *ops, int perf_event__process_task(struct perf_event_ops *ops,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_session *session); struct machine *machine);
int perf_event__process(struct perf_event_ops *ops, int perf_event__process(struct perf_event_ops *ops,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_session *session); struct machine *machine);
struct addr_location; struct addr_location;
int perf_event__preprocess_sample(const union perf_event *self, int perf_event__preprocess_sample(const union perf_event *self,
struct perf_session *session, struct machine *machine,
struct addr_location *al, struct addr_location *al,
struct perf_sample *sample, struct perf_sample *sample,
symbol_filter_t filter); symbol_filter_t filter);
......
...@@ -2072,8 +2072,7 @@ int perf_session__read_header(struct perf_session *session, int fd) ...@@ -2072,8 +2072,7 @@ int perf_session__read_header(struct perf_session *session, int fd)
int perf_event__synthesize_attr(struct perf_event_ops *ops, int perf_event__synthesize_attr(struct perf_event_ops *ops,
struct perf_event_attr *attr, u16 ids, u64 *id, struct perf_event_attr *attr, u16 ids, u64 *id,
perf_event__handler_t process, perf_event__handler_t process)
struct perf_session *session)
{ {
union perf_event *ev; union perf_event *ev;
size_t size; size_t size;
...@@ -2095,7 +2094,7 @@ int perf_event__synthesize_attr(struct perf_event_ops *ops, ...@@ -2095,7 +2094,7 @@ int perf_event__synthesize_attr(struct perf_event_ops *ops,
ev->attr.header.type = PERF_RECORD_HEADER_ATTR; ev->attr.header.type = PERF_RECORD_HEADER_ATTR;
ev->attr.header.size = size; ev->attr.header.size = size;
err = process(ops, ev, NULL, session); err = process(ops, ev, NULL, NULL);
free(ev); free(ev);
...@@ -2111,7 +2110,7 @@ int perf_event__synthesize_attrs(struct perf_event_ops *ops, ...@@ -2111,7 +2110,7 @@ int perf_event__synthesize_attrs(struct perf_event_ops *ops,
list_for_each_entry(attr, &session->evlist->entries, node) { list_for_each_entry(attr, &session->evlist->entries, node) {
err = perf_event__synthesize_attr(ops, &attr->attr, attr->ids, err = perf_event__synthesize_attr(ops, &attr->attr, attr->ids,
attr->id, process, session); attr->id, process);
if (err) { if (err) {
pr_debug("failed to create perf header attribute\n"); pr_debug("failed to create perf header attribute\n");
return err; return err;
...@@ -2161,7 +2160,7 @@ int perf_event__process_attr(union perf_event *event, ...@@ -2161,7 +2160,7 @@ int perf_event__process_attr(union perf_event *event,
int perf_event__synthesize_event_type(struct perf_event_ops *ops, int perf_event__synthesize_event_type(struct perf_event_ops *ops,
u64 event_id, char *name, u64 event_id, char *name,
perf_event__handler_t process, perf_event__handler_t process,
struct perf_session *session) struct machine *machine)
{ {
union perf_event ev; union perf_event ev;
size_t size = 0; size_t size = 0;
...@@ -2179,14 +2178,14 @@ int perf_event__synthesize_event_type(struct perf_event_ops *ops, ...@@ -2179,14 +2178,14 @@ int perf_event__synthesize_event_type(struct perf_event_ops *ops,
ev.event_type.header.size = sizeof(ev.event_type) - ev.event_type.header.size = sizeof(ev.event_type) -
(sizeof(ev.event_type.event_type.name) - size); (sizeof(ev.event_type.event_type.name) - size);
err = process(ops, &ev, NULL, session); err = process(ops, &ev, NULL, machine);
return err; return err;
} }
int perf_event__synthesize_event_types(struct perf_event_ops *ops, int perf_event__synthesize_event_types(struct perf_event_ops *ops,
perf_event__handler_t process, perf_event__handler_t process,
struct perf_session *session) struct machine *machine)
{ {
struct perf_trace_event_type *type; struct perf_trace_event_type *type;
int i, err = 0; int i, err = 0;
...@@ -2196,7 +2195,7 @@ int perf_event__synthesize_event_types(struct perf_event_ops *ops, ...@@ -2196,7 +2195,7 @@ int perf_event__synthesize_event_types(struct perf_event_ops *ops,
err = perf_event__synthesize_event_type(ops, type->event_id, err = perf_event__synthesize_event_type(ops, type->event_id,
type->name, process, type->name, process,
session); machine);
if (err) { if (err) {
pr_debug("failed to create perf header event type\n"); pr_debug("failed to create perf header event type\n");
return err; return err;
...@@ -2207,8 +2206,7 @@ int perf_event__synthesize_event_types(struct perf_event_ops *ops, ...@@ -2207,8 +2206,7 @@ int perf_event__synthesize_event_types(struct perf_event_ops *ops,
} }
int perf_event__process_event_type(struct perf_event_ops *ops __unused, int perf_event__process_event_type(struct perf_event_ops *ops __unused,
union perf_event *event, union perf_event *event)
struct perf_session *session __unused)
{ {
if (perf_header__push_event(event->event_type.event_type.event_id, if (perf_header__push_event(event->event_type.event_type.event_id,
event->event_type.event_type.name) < 0) event->event_type.event_type.name) < 0)
...@@ -2219,8 +2217,7 @@ int perf_event__process_event_type(struct perf_event_ops *ops __unused, ...@@ -2219,8 +2217,7 @@ int perf_event__process_event_type(struct perf_event_ops *ops __unused,
int perf_event__synthesize_tracing_data(struct perf_event_ops *ops, int fd, int perf_event__synthesize_tracing_data(struct perf_event_ops *ops, int fd,
struct perf_evlist *evlist, struct perf_evlist *evlist,
perf_event__handler_t process, perf_event__handler_t process)
struct perf_session *session __unused)
{ {
union perf_event ev; union perf_event ev;
struct tracing_data *tdata; struct tracing_data *tdata;
...@@ -2251,7 +2248,7 @@ int perf_event__synthesize_tracing_data(struct perf_event_ops *ops, int fd, ...@@ -2251,7 +2248,7 @@ int perf_event__synthesize_tracing_data(struct perf_event_ops *ops, int fd,
ev.tracing_data.header.size = sizeof(ev.tracing_data); ev.tracing_data.header.size = sizeof(ev.tracing_data);
ev.tracing_data.size = aligned_size; ev.tracing_data.size = aligned_size;
process(ops, &ev, NULL, session); process(ops, &ev, NULL, NULL);
/* /*
* The put function will copy all the tracing data * The put function will copy all the tracing data
...@@ -2296,8 +2293,7 @@ int perf_event__process_tracing_data(union perf_event *event, ...@@ -2296,8 +2293,7 @@ int perf_event__process_tracing_data(union perf_event *event,
int perf_event__synthesize_build_id(struct perf_event_ops *ops, int perf_event__synthesize_build_id(struct perf_event_ops *ops,
struct dso *pos, u16 misc, struct dso *pos, u16 misc,
perf_event__handler_t process, perf_event__handler_t process,
struct machine *machine, struct machine *machine)
struct perf_session *session)
{ {
union perf_event ev; union perf_event ev;
size_t len; size_t len;
...@@ -2317,7 +2313,7 @@ int perf_event__synthesize_build_id(struct perf_event_ops *ops, ...@@ -2317,7 +2313,7 @@ int perf_event__synthesize_build_id(struct perf_event_ops *ops,
ev.build_id.header.size = sizeof(ev.build_id) + len; ev.build_id.header.size = sizeof(ev.build_id) + len;
memcpy(&ev.build_id.filename, pos->long_name, pos->long_name_len); memcpy(&ev.build_id.filename, pos->long_name, pos->long_name_len);
err = process(ops, &ev, NULL, session); err = process(ops, &ev, NULL, machine);
return err; return err;
} }
......
...@@ -99,8 +99,7 @@ int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir); ...@@ -99,8 +99,7 @@ int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir);
int perf_event__synthesize_attr(struct perf_event_ops *ops, int perf_event__synthesize_attr(struct perf_event_ops *ops,
struct perf_event_attr *attr, u16 ids, u64 *id, struct perf_event_attr *attr, u16 ids, u64 *id,
perf_event__handler_t process, perf_event__handler_t process);
struct perf_session *session);
int perf_event__synthesize_attrs(struct perf_event_ops *ops, int perf_event__synthesize_attrs(struct perf_event_ops *ops,
struct perf_session *session, struct perf_session *session,
perf_event__handler_t process); perf_event__handler_t process);
...@@ -109,26 +108,23 @@ int perf_event__process_attr(union perf_event *event, struct perf_evlist **pevli ...@@ -109,26 +108,23 @@ int perf_event__process_attr(union perf_event *event, struct perf_evlist **pevli
int perf_event__synthesize_event_type(struct perf_event_ops *ops, int perf_event__synthesize_event_type(struct perf_event_ops *ops,
u64 event_id, char *name, u64 event_id, char *name,
perf_event__handler_t process, perf_event__handler_t process,
struct perf_session *session); struct machine *machine);
int perf_event__synthesize_event_types(struct perf_event_ops *ops, int perf_event__synthesize_event_types(struct perf_event_ops *ops,
perf_event__handler_t process, perf_event__handler_t process,
struct perf_session *session); struct machine *machine);
int perf_event__process_event_type(struct perf_event_ops *ops, int perf_event__process_event_type(struct perf_event_ops *ops,
union perf_event *event, union perf_event *event);
struct perf_session *session);
int perf_event__synthesize_tracing_data(struct perf_event_ops *ops, int perf_event__synthesize_tracing_data(struct perf_event_ops *ops,
int fd, struct perf_evlist *evlist, int fd, struct perf_evlist *evlist,
perf_event__handler_t process, perf_event__handler_t process);
struct perf_session *session);
int perf_event__process_tracing_data(union perf_event *event, int perf_event__process_tracing_data(union perf_event *event,
struct perf_session *session); struct perf_session *session);
int perf_event__synthesize_build_id(struct perf_event_ops *ops, int perf_event__synthesize_build_id(struct perf_event_ops *ops,
struct dso *pos, u16 misc, struct dso *pos, u16 misc,
perf_event__handler_t process, perf_event__handler_t process,
struct machine *machine, struct machine *machine);
struct perf_session *session);
int perf_event__process_build_id(struct perf_event_ops *ops, int perf_event__process_build_id(struct perf_event_ops *ops,
union perf_event *event, union perf_event *event,
struct perf_session *session); struct perf_session *session);
......
...@@ -18,9 +18,11 @@ enum map_type { ...@@ -18,9 +18,11 @@ enum map_type {
extern const char *map_type__name[MAP__NR_TYPES]; extern const char *map_type__name[MAP__NR_TYPES];
struct dso; struct dso;
struct ip_callchain;
struct ref_reloc_sym; struct ref_reloc_sym;
struct map_groups; struct map_groups;
struct machine; struct machine;
struct perf_evsel;
struct map { struct map {
union { union {
...@@ -61,6 +63,7 @@ struct map_groups { ...@@ -61,6 +63,7 @@ struct map_groups {
struct machine { struct machine {
struct rb_node rb_node; struct rb_node rb_node;
pid_t pid; pid_t pid;
u16 id_hdr_size;
char *root_dir; char *root_dir;
struct rb_root threads; struct rb_root threads;
struct list_head dead_threads; struct list_head dead_threads;
...@@ -151,6 +154,13 @@ int machine__init(struct machine *self, const char *root_dir, pid_t pid); ...@@ -151,6 +154,13 @@ int machine__init(struct machine *self, const char *root_dir, pid_t pid);
void machine__exit(struct machine *self); void machine__exit(struct machine *self);
void machine__delete(struct machine *self); void machine__delete(struct machine *self);
int machine__resolve_callchain(struct machine *machine,
struct perf_evsel *evsel, struct thread *thread,
struct ip_callchain *chain,
struct symbol **parent);
int maps__set_kallsyms_ref_reloc_sym(struct map **maps, const char *symbol_name,
u64 addr);
/* /*
* Default guest kernel is defined by parameter --guestkallsyms * Default guest kernel is defined by parameter --guestkallsyms
* and --guestmodules * and --guestmodules
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include "../../perf.h" #include "../../perf.h"
#include "../util.h" #include "../util.h"
#include "../thread.h"
#include "../event.h"
#include "../trace-event.h" #include "../trace-event.h"
#include <EXTERN.h> #include <EXTERN.h>
...@@ -248,7 +250,7 @@ static inline struct event *find_cache_event(int type) ...@@ -248,7 +250,7 @@ static inline struct event *find_cache_event(int type)
static void perl_process_event(union perf_event *pevent __unused, static void perl_process_event(union perf_event *pevent __unused,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
struct perf_session *session __unused, struct machine *machine __unused,
struct thread *thread) struct thread *thread)
{ {
struct format_field *field; struct format_field *field;
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include "../../perf.h" #include "../../perf.h"
#include "../util.h" #include "../util.h"
#include "../event.h"
#include "../thread.h"
#include "../trace-event.h" #include "../trace-event.h"
PyMODINIT_FUNC initperf_trace_context(void); PyMODINIT_FUNC initperf_trace_context(void);
...@@ -207,7 +209,7 @@ static inline struct event *find_cache_event(int type) ...@@ -207,7 +209,7 @@ static inline struct event *find_cache_event(int type)
static void python_process_event(union perf_event *pevent __unused, static void python_process_event(union perf_event *pevent __unused,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel __unused, struct perf_evsel *evsel __unused,
struct perf_session *session __unused, struct machine *machine __unused,
struct thread *thread) struct thread *thread)
{ {
PyObject *handler, *retval, *context, *t, *obj, *dict = NULL; PyObject *handler, *retval, *context, *t, *obj, *dict = NULL;
......
...@@ -84,6 +84,7 @@ void perf_session__update_sample_type(struct perf_session *self) ...@@ -84,6 +84,7 @@ void perf_session__update_sample_type(struct perf_session *self)
self->sample_size = __perf_evsel__sample_size(self->sample_type); self->sample_size = __perf_evsel__sample_size(self->sample_type);
self->sample_id_all = perf_evlist__sample_id_all(self->evlist); self->sample_id_all = perf_evlist__sample_id_all(self->evlist);
self->id_hdr_size = perf_evlist__id_hdr_size(self->evlist); self->id_hdr_size = perf_evlist__id_hdr_size(self->evlist);
self->host_machine.id_hdr_size = self->id_hdr_size;
} }
int perf_session__create_kernel_maps(struct perf_session *self) int perf_session__create_kernel_maps(struct perf_session *self)
...@@ -216,10 +217,10 @@ static bool symbol__match_parent_regex(struct symbol *sym) ...@@ -216,10 +217,10 @@ static bool symbol__match_parent_regex(struct symbol *sym)
return 0; return 0;
} }
int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel *evsel, int machine__resolve_callchain(struct machine *self, struct perf_evsel *evsel,
struct thread *thread, struct thread *thread,
struct ip_callchain *chain, struct ip_callchain *chain,
struct symbol **parent) struct symbol **parent)
{ {
u8 cpumode = PERF_RECORD_MISC_USER; u8 cpumode = PERF_RECORD_MISC_USER;
unsigned int i; unsigned int i;
...@@ -252,7 +253,7 @@ int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel ...@@ -252,7 +253,7 @@ int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel
al.filtered = false; al.filtered = false;
thread__find_addr_location(thread, self, cpumode, thread__find_addr_location(thread, self, cpumode,
MAP__FUNCTION, thread->pid, ip, &al, NULL); MAP__FUNCTION, ip, &al, NULL);
if (al.sym != NULL) { if (al.sym != NULL) {
if (sort__has_parent && !*parent && if (sort__has_parent && !*parent &&
symbol__match_parent_regex(al.sym)) symbol__match_parent_regex(al.sym))
...@@ -270,14 +271,6 @@ int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel ...@@ -270,14 +271,6 @@ int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel
return 0; return 0;
} }
static int process_event_synth_stub(struct perf_event_ops *ops __used,
union perf_event *event __used,
struct perf_session *session __used)
{
dump_printf(": unhandled!\n");
return 0;
}
static int process_event_synth_tracing_data_stub(union perf_event *event __used, static int process_event_synth_tracing_data_stub(union perf_event *event __used,
struct perf_session *session __used) struct perf_session *session __used)
{ {
...@@ -296,7 +289,7 @@ static int process_event_sample_stub(struct perf_event_ops *ops __used, ...@@ -296,7 +289,7 @@ static int process_event_sample_stub(struct perf_event_ops *ops __used,
union perf_event *event __used, union perf_event *event __used,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct perf_evsel *evsel __used, struct perf_evsel *evsel __used,
struct perf_session *session __used) struct machine *machine __used)
{ {
dump_printf(": unhandled!\n"); dump_printf(": unhandled!\n");
return 0; return 0;
...@@ -305,7 +298,7 @@ static int process_event_sample_stub(struct perf_event_ops *ops __used, ...@@ -305,7 +298,7 @@ static int process_event_sample_stub(struct perf_event_ops *ops __used,
static int process_event_stub(struct perf_event_ops *ops __used, static int process_event_stub(struct perf_event_ops *ops __used,
union perf_event *event __used, union perf_event *event __used,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct perf_session *session __used) struct machine *machine __used)
{ {
dump_printf(": unhandled!\n"); dump_printf(": unhandled!\n");
return 0; return 0;
...@@ -313,7 +306,14 @@ static int process_event_stub(struct perf_event_ops *ops __used, ...@@ -313,7 +306,14 @@ static int process_event_stub(struct perf_event_ops *ops __used,
static int process_finished_round_stub(struct perf_event_ops *ops __used, static int process_finished_round_stub(struct perf_event_ops *ops __used,
union perf_event *event __used, union perf_event *event __used,
struct perf_session *session __used) struct perf_session *perf_session __used)
{
dump_printf(": unhandled!\n");
return 0;
}
static int process_event_type_stub(struct perf_event_ops *ops __used,
union perf_event *event __used)
{ {
dump_printf(": unhandled!\n"); dump_printf(": unhandled!\n");
return 0; return 0;
...@@ -338,7 +338,7 @@ static void perf_event_ops__fill_defaults(struct perf_event_ops *handler) ...@@ -338,7 +338,7 @@ static void perf_event_ops__fill_defaults(struct perf_event_ops *handler)
if (handler->lost == NULL) if (handler->lost == NULL)
handler->lost = perf_event__process_lost; handler->lost = perf_event__process_lost;
if (handler->read == NULL) if (handler->read == NULL)
handler->read = process_event_stub; handler->read = process_event_sample_stub;
if (handler->throttle == NULL) if (handler->throttle == NULL)
handler->throttle = process_event_stub; handler->throttle = process_event_stub;
if (handler->unthrottle == NULL) if (handler->unthrottle == NULL)
...@@ -346,11 +346,11 @@ static void perf_event_ops__fill_defaults(struct perf_event_ops *handler) ...@@ -346,11 +346,11 @@ static void perf_event_ops__fill_defaults(struct perf_event_ops *handler)
if (handler->attr == NULL) if (handler->attr == NULL)
handler->attr = process_event_synth_attr_stub; handler->attr = process_event_synth_attr_stub;
if (handler->event_type == NULL) if (handler->event_type == NULL)
handler->event_type = process_event_synth_stub; handler->event_type = process_event_type_stub;
if (handler->tracing_data == NULL) if (handler->tracing_data == NULL)
handler->tracing_data = process_event_synth_tracing_data_stub; handler->tracing_data = process_event_synth_tracing_data_stub;
if (handler->build_id == NULL) if (handler->build_id == NULL)
handler->build_id = process_event_synth_stub; handler->build_id = process_finished_round_stub;
if (handler->finished_round == NULL) { if (handler->finished_round == NULL) {
if (handler->ordered_samples) if (handler->ordered_samples)
handler->finished_round = process_finished_round; handler->finished_round = process_finished_round;
...@@ -734,6 +734,18 @@ static void dump_sample(struct perf_session *session, union perf_event *event, ...@@ -734,6 +734,18 @@ static void dump_sample(struct perf_session *session, union perf_event *event,
callchain__printf(sample); callchain__printf(sample);
} }
static struct machine *
perf_session__find_machine_for_cpumode(struct perf_session *session,
union perf_event *event)
{
const u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL && perf_guest)
return perf_session__find_machine(session, event->ip.pid);
return perf_session__find_host_machine(session);
}
static int perf_session_deliver_event(struct perf_session *session, static int perf_session_deliver_event(struct perf_session *session,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
...@@ -741,6 +753,7 @@ static int perf_session_deliver_event(struct perf_session *session, ...@@ -741,6 +753,7 @@ static int perf_session_deliver_event(struct perf_session *session,
u64 file_offset) u64 file_offset)
{ {
struct perf_evsel *evsel; struct perf_evsel *evsel;
struct machine *machine;
dump_event(session, event, file_offset, sample); dump_event(session, event, file_offset, sample);
...@@ -762,6 +775,8 @@ static int perf_session_deliver_event(struct perf_session *session, ...@@ -762,6 +775,8 @@ static int perf_session_deliver_event(struct perf_session *session,
hists__inc_nr_events(&evsel->hists, event->header.type); hists__inc_nr_events(&evsel->hists, event->header.type);
} }
machine = perf_session__find_machine_for_cpumode(session, event);
switch (event->header.type) { switch (event->header.type) {
case PERF_RECORD_SAMPLE: case PERF_RECORD_SAMPLE:
dump_sample(session, event, sample); dump_sample(session, event, sample);
...@@ -769,23 +784,25 @@ static int perf_session_deliver_event(struct perf_session *session, ...@@ -769,23 +784,25 @@ static int perf_session_deliver_event(struct perf_session *session,
++session->hists.stats.nr_unknown_id; ++session->hists.stats.nr_unknown_id;
return -1; return -1;
} }
return ops->sample(ops, event, sample, evsel, session); return ops->sample(ops, event, sample, evsel, machine);
case PERF_RECORD_MMAP: case PERF_RECORD_MMAP:
return ops->mmap(ops, event, sample, session); return ops->mmap(ops, event, sample, machine);
case PERF_RECORD_COMM: case PERF_RECORD_COMM:
return ops->comm(ops, event, sample, session); return ops->comm(ops, event, sample, machine);
case PERF_RECORD_FORK: case PERF_RECORD_FORK:
return ops->fork(ops, event, sample, session); return ops->fork(ops, event, sample, machine);
case PERF_RECORD_EXIT: case PERF_RECORD_EXIT:
return ops->exit(ops, event, sample, session); return ops->exit(ops, event, sample, machine);
case PERF_RECORD_LOST: case PERF_RECORD_LOST:
return ops->lost(ops, event, sample, session); if (ops->lost == perf_event__process_lost)
session->hists.stats.total_lost += event->lost.lost;
return ops->lost(ops, event, sample, machine);
case PERF_RECORD_READ: case PERF_RECORD_READ:
return ops->read(ops, event, sample, session); return ops->read(ops, event, sample, evsel, machine);
case PERF_RECORD_THROTTLE: case PERF_RECORD_THROTTLE:
return ops->throttle(ops, event, sample, session); return ops->throttle(ops, event, sample, machine);
case PERF_RECORD_UNTHROTTLE: case PERF_RECORD_UNTHROTTLE:
return ops->unthrottle(ops, event, sample, session); return ops->unthrottle(ops, event, sample, machine);
default: default:
++session->hists.stats.nr_unknown_events; ++session->hists.stats.nr_unknown_events;
return -1; return -1;
...@@ -823,7 +840,7 @@ static int perf_session__process_user_event(struct perf_session *session, union ...@@ -823,7 +840,7 @@ static int perf_session__process_user_event(struct perf_session *session, union
perf_session__update_sample_type(session); perf_session__update_sample_type(session);
return err; return err;
case PERF_RECORD_HEADER_EVENT_TYPE: case PERF_RECORD_HEADER_EVENT_TYPE:
return ops->event_type(ops, event, session); return ops->event_type(ops, event);
case PERF_RECORD_HEADER_TRACING_DATA: case PERF_RECORD_HEADER_TRACING_DATA:
/* setup for reading amidst mmap */ /* setup for reading amidst mmap */
lseek(session->fd, file_offset, SEEK_SET); lseek(session->fd, file_offset, SEEK_SET);
...@@ -1170,9 +1187,8 @@ bool perf_session__has_traces(struct perf_session *self, const char *msg) ...@@ -1170,9 +1187,8 @@ bool perf_session__has_traces(struct perf_session *self, const char *msg)
return true; return true;
} }
int perf_session__set_kallsyms_ref_reloc_sym(struct map **maps, int maps__set_kallsyms_ref_reloc_sym(struct map **maps,
const char *symbol_name, const char *symbol_name, u64 addr)
u64 addr)
{ {
char *bracket; char *bracket;
enum map_type i; enum map_type i;
...@@ -1264,17 +1280,16 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session, ...@@ -1264,17 +1280,16 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
return NULL; return NULL;
} }
void perf_session__print_ip(union perf_event *event, struct perf_evsel *evsel, void perf_event__print_ip(union perf_event *event, struct perf_sample *sample,
struct perf_sample *sample, struct machine *machine, struct perf_evsel *evsel,
struct perf_session *session, int print_sym, int print_dso)
int print_sym, int print_dso)
{ {
struct addr_location al; struct addr_location al;
const char *symname, *dsoname; const char *symname, *dsoname;
struct callchain_cursor *cursor = &evsel->hists.callchain_cursor; struct callchain_cursor *cursor = &evsel->hists.callchain_cursor;
struct callchain_cursor_node *node; struct callchain_cursor_node *node;
if (perf_event__preprocess_sample(event, session, &al, sample, if (perf_event__preprocess_sample(event, machine, &al, sample,
NULL) < 0) { NULL) < 0) {
error("problem processing %d event, skipping it.\n", error("problem processing %d event, skipping it.\n",
event->header.type); event->header.type);
...@@ -1283,7 +1298,7 @@ void perf_session__print_ip(union perf_event *event, struct perf_evsel *evsel, ...@@ -1283,7 +1298,7 @@ void perf_session__print_ip(union perf_event *event, struct perf_evsel *evsel,
if (symbol_conf.use_callchain && sample->callchain) { if (symbol_conf.use_callchain && sample->callchain) {
if (perf_session__resolve_callchain(session, evsel, al.thread, if (machine__resolve_callchain(machine, evsel, al.thread,
sample->callchain, NULL) != 0) { sample->callchain, NULL) != 0) {
if (verbose) if (verbose)
error("Failed to resolve callchain. Skipping\n"); error("Failed to resolve callchain. Skipping\n");
......
...@@ -58,32 +58,34 @@ struct perf_event_ops; ...@@ -58,32 +58,34 @@ struct perf_event_ops;
typedef int (*event_sample)(struct perf_event_ops *ops, typedef int (*event_sample)(struct perf_event_ops *ops,
union perf_event *event, struct perf_sample *sample, union perf_event *event, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_session *session); struct perf_evsel *evsel, struct machine *machine);
typedef int (*event_op)(struct perf_event_ops *ops, union perf_event *event, typedef int (*event_op)(struct perf_event_ops *ops, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_session *session); struct machine *machine);
typedef int (*event_synth_op)(union perf_event *self, typedef int (*event_synth_op)(union perf_event *self,
struct perf_session *session); struct perf_session *session);
typedef int (*event_attr_op)(union perf_event *event, typedef int (*event_attr_op)(union perf_event *event,
struct perf_evlist **pevlist); struct perf_evlist **pevlist);
typedef int (*event_simple_op)(struct perf_event_ops *ops,
union perf_event *event);
typedef int (*event_op2)(struct perf_event_ops *ops, union perf_event *event, typedef int (*event_op2)(struct perf_event_ops *ops, union perf_event *event,
struct perf_session *session); struct perf_session *session);
struct perf_event_ops { struct perf_event_ops {
event_sample sample; event_sample sample,
read;
event_op mmap, event_op mmap,
comm, comm,
fork, fork,
exit, exit,
lost, lost,
read,
throttle, throttle,
unthrottle; unthrottle;
event_attr_op attr; event_attr_op attr;
event_synth_op tracing_data; event_synth_op tracing_data;
event_op2 event_type, event_simple_op event_type;
build_id, event_op2 finished_round,
finished_round; build_id;
bool ordered_samples; bool ordered_samples;
bool ordering_requires_timestamps; bool ordering_requires_timestamps;
}; };
...@@ -108,10 +110,6 @@ int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel ...@@ -108,10 +110,6 @@ int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel
bool perf_session__has_traces(struct perf_session *self, const char *msg); bool perf_session__has_traces(struct perf_session *self, const char *msg);
int perf_session__set_kallsyms_ref_reloc_sym(struct map **maps,
const char *symbol_name,
u64 addr);
void mem_bswap_64(void *src, int byte_size); void mem_bswap_64(void *src, int byte_size);
void perf_event__attr_swap(struct perf_event_attr *attr); void perf_event__attr_swap(struct perf_event_attr *attr);
...@@ -151,6 +149,9 @@ void perf_session__process_machines(struct perf_session *self, ...@@ -151,6 +149,9 @@ void perf_session__process_machines(struct perf_session *self,
return machines__process(&self->machines, process, ops); return machines__process(&self->machines, process, ops);
} }
struct thread *perf_session__findnew(struct perf_session *self, pid_t pid);
size_t perf_session__fprintf(struct perf_session *self, FILE *fp);
size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp); size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp);
size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, size_t perf_session__fprintf_dsos_buildid(struct perf_session *self,
...@@ -171,10 +172,9 @@ static inline int perf_session__parse_sample(struct perf_session *session, ...@@ -171,10 +172,9 @@ static inline int perf_session__parse_sample(struct perf_session *session,
struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session, struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
unsigned int type); unsigned int type);
void perf_session__print_ip(union perf_event *event, struct perf_evsel *evsel, void perf_event__print_ip(union perf_event *event, struct perf_sample *sample,
struct perf_sample *sample, struct machine *machine, struct perf_evsel *evsel,
struct perf_session *session, int print_sym, int print_dso);
int print_sym, int print_dso);
int perf_session__cpu_bitmap(struct perf_session *session, int perf_session__cpu_bitmap(struct perf_session *session,
const char *cpu_list, unsigned long *cpu_bitmap); const char *cpu_list, unsigned long *cpu_bitmap);
......
...@@ -18,16 +18,14 @@ struct thread { ...@@ -18,16 +18,14 @@ struct thread {
int comm_len; int comm_len;
}; };
struct perf_session; struct machine;
void thread__delete(struct thread *self); void thread__delete(struct thread *self);
int thread__set_comm(struct thread *self, const char *comm); int thread__set_comm(struct thread *self, const char *comm);
int thread__comm_len(struct thread *self); int thread__comm_len(struct thread *self);
struct thread *perf_session__findnew(struct perf_session *self, pid_t pid);
void thread__insert_map(struct thread *self, struct map *map); void thread__insert_map(struct thread *self, struct map *map);
int thread__fork(struct thread *self, struct thread *parent); int thread__fork(struct thread *self, struct thread *parent);
size_t perf_session__fprintf(struct perf_session *self, FILE *fp);
static inline struct map *thread__find_map(struct thread *self, static inline struct map *thread__find_map(struct thread *self,
enum map_type type, u64 addr) enum map_type type, u64 addr)
...@@ -35,14 +33,12 @@ static inline struct map *thread__find_map(struct thread *self, ...@@ -35,14 +33,12 @@ static inline struct map *thread__find_map(struct thread *self,
return self ? map_groups__find(&self->mg, type, addr) : NULL; return self ? map_groups__find(&self->mg, type, addr) : NULL;
} }
void thread__find_addr_map(struct thread *self, void thread__find_addr_map(struct thread *thread, struct machine *machine,
struct perf_session *session, u8 cpumode, u8 cpumode, enum map_type type, u64 addr,
enum map_type type, pid_t pid, u64 addr,
struct addr_location *al); struct addr_location *al);
void thread__find_addr_location(struct thread *self, void thread__find_addr_location(struct thread *thread, struct machine *machine,
struct perf_session *session, u8 cpumode, u8 cpumode, enum map_type type, u64 addr,
enum map_type type, pid_t pid, u64 addr,
struct addr_location *al, struct addr_location *al,
symbol_filter_t filter); symbol_filter_t filter);
#endif /* __PERF_THREAD_H */ #endif /* __PERF_THREAD_H */
...@@ -39,7 +39,7 @@ static int stop_script_unsupported(void) ...@@ -39,7 +39,7 @@ static int stop_script_unsupported(void)
static void process_event_unsupported(union perf_event *event __unused, static void process_event_unsupported(union perf_event *event __unused,
struct perf_sample *sample __unused, struct perf_sample *sample __unused,
struct perf_evsel *evsel __unused, struct perf_evsel *evsel __unused,
struct perf_session *session __unused, struct machine *machine __unused,
struct thread *thread __unused) struct thread *thread __unused)
{ {
} }
......
...@@ -3,7 +3,11 @@ ...@@ -3,7 +3,11 @@
#include <stdbool.h> #include <stdbool.h>
#include "parse-events.h" #include "parse-events.h"
#include "session.h"
struct machine;
struct perf_sample;
union perf_event;
struct thread;
#define __unused __attribute__((unused)) #define __unused __attribute__((unused))
...@@ -292,7 +296,7 @@ struct scripting_ops { ...@@ -292,7 +296,7 @@ struct scripting_ops {
void (*process_event) (union perf_event *event, void (*process_event) (union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
struct perf_session *session, struct machine *machine,
struct thread *thread); struct thread *thread);
int (*generate_script) (const char *outfile); int (*generate_script) (const char *outfile);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment