diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-11-28 07:56:39 -0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-11-28 10:39:12 -0200 |
commit | 743eb868657bdb1b26c7b24077ca21c67c82c777 (patch) | |
tree | 4803b557725213043ccd5d3f83d2eec796a49f69 | |
parent | d20deb64e0490ee9442b5181bc08a62d2cadcb90 (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>
-rw-r--r-- | tools/perf/builtin-annotate.c | 4 | ||||
-rw-r--r-- | tools/perf/builtin-diff.c | 9 | ||||
-rw-r--r-- | tools/perf/builtin-inject.c | 70 | ||||
-rw-r--r-- | tools/perf/builtin-kmem.c | 4 | ||||
-rw-r--r-- | tools/perf/builtin-lock.c | 4 | ||||
-rw-r--r-- | tools/perf/builtin-record.c | 38 | ||||
-rw-r--r-- | tools/perf/builtin-report.c | 24 | ||||
-rw-r--r-- | tools/perf/builtin-sched.c | 70 | ||||
-rw-r--r-- | tools/perf/builtin-script.c | 26 | ||||
-rw-r--r-- | tools/perf/builtin-timechart.c | 8 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 99 | ||||
-rw-r--r-- | tools/perf/util/build-id.c | 16 | ||||
-rw-r--r-- | tools/perf/util/event.c | 151 | ||||
-rw-r--r-- | tools/perf/util/event.h | 21 | ||||
-rw-r--r-- | tools/perf/util/header.c | 28 | ||||
-rw-r--r-- | tools/perf/util/header.h | 16 | ||||
-rw-r--r-- | tools/perf/util/map.h | 10 | ||||
-rw-r--r-- | tools/perf/util/scripting-engines/trace-event-perl.c | 4 | ||||
-rw-r--r-- | tools/perf/util/scripting-engines/trace-event-python.c | 4 | ||||
-rw-r--r-- | tools/perf/util/session.c | 91 | ||||
-rw-r--r-- | tools/perf/util/session.h | 30 | ||||
-rw-r--r-- | tools/perf/util/thread.h | 14 | ||||
-rw-r--r-- | tools/perf/util/trace-event-scripting.c | 2 | ||||
-rw-r--r-- | tools/perf/util/trace-event.h | 8 |
24 files changed, 376 insertions, 375 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 483cb946644..dff081a388b 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -83,12 +83,12 @@ static int process_sample_event(struct perf_event_ops *ops, union perf_event *event, struct perf_sample *sample, struct perf_evsel *evsel, - struct perf_session *session) + struct machine *machine) { struct perf_annotate *ann = container_of(ops, struct perf_annotate, ops); 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) { pr_warning("problem processing %d event, skipping it.\n", event->header.type); diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 9a0872f9e83..478b0aeb2a6 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -9,6 +9,7 @@ #include "util/debug.h" #include "util/event.h" #include "util/hist.h" +#include "util/evsel.h" #include "util/session.h" #include "util/sort.h" #include "util/symbol.h" @@ -34,11 +35,11 @@ static int diff__process_sample_event(struct perf_event_ops *ops __used, union perf_event *event, struct perf_sample *sample, struct perf_evsel *evsel __used, - struct perf_session *session) + struct machine *machine) { 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", event->header.type); return -1; @@ -47,12 +48,12 @@ static int diff__process_sample_event(struct perf_event_ops *ops __used, if (al.filtered || al.sym == NULL) 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"); return -1; } - session->hists.stats.total_period += sample->period; + evsel->hists.stats.total_period += sample->period; return 0; } diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 6ce6d80b59d..a5bcf81776f 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; diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 5d01218e50e..27b2a15dc7b 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -307,9 +307,9 @@ static int process_sample_event(struct perf_event_ops *ops __used, union perf_event *event, struct perf_sample *sample, 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) { pr_debug("problem processing %d event, skipping it.\n", diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index f06b0a44c7c..99b032adb83 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -849,9 +849,9 @@ static int process_sample_event(struct perf_event_ops *ops __used, union perf_event *event, struct perf_sample *sample, 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) { pr_debug("problem processing %d event, skipping it.\n", diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 4642d38b8d1..0af598a1059 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -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, union perf_event *event, 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); write_output(rec, event, event->header.size); @@ -320,8 +320,6 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data) { int err; 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)) return; @@ -335,7 +333,7 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data) *in module instead of in guest kernel. */ err = perf_event__synthesize_modules(ops, process_synthesized_event, - psession, machine); + machine); if (err < 0) pr_err("Couldn't record guest kernel [%d]'s reference" " relocation symbol.\n", machine->pid); @@ -345,11 +343,10 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data) * have no _text sometimes. */ err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event, - psession, machine, "_text"); + machine, "_text"); if (err < 0) err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event, - psession, machine, - "_stext"); + machine, "_stext"); if (err < 0) pr_err("Couldn't record guest kernel [%d]'s reference" " relocation symbol.\n", machine->pid); @@ -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); + machine = perf_session__find_host_machine(session); + if (!machine) { + pr_err("Couldn't find native kernel information.\n"); + return -1; + } + if (opts->pipe_output) { err = perf_event__synthesize_attrs(ops, session, process_synthesized_event); @@ -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, - session); + machine); if (err < 0) { pr_err("Couldn't synthesize event_types.\n"); return err; @@ -522,8 +525,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) * propagate errors that now are calling die() */ err = perf_event__synthesize_tracing_data(ops, output, evsel_list, - process_synthesized_event, - session); + process_synthesized_event); if (err <= 0) { pr_err("Couldn't record tracing data.\n"); return err; @@ -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, - session, machine, "_text"); + machine, "_text"); if (err < 0) err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event, - session, machine, "_stext"); + machine, "_stext"); if (err < 0) pr_err("Couldn't record kernel reference relocation symbol\n" "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n" "Check /proc/kallsyms permission or run as root.\n"); err = perf_event__synthesize_modules(ops, process_synthesized_event, - session, machine); + machine); if (err < 0) pr_err("Couldn't record kernel module information.\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) if (!opts->system_wide) perf_event__synthesize_thread_map(ops, evsel_list->threads, process_synthesized_event, - session); + machine); else perf_event__synthesize_threads(ops, process_synthesized_event, - session); + machine); if (rec->realtime_prio) { struct sched_param param; diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 8795520f6e1..ea64fbbdff4 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -52,18 +52,18 @@ struct perf_report { DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); }; -static int perf_session__add_hist_entry(struct perf_session *session, - struct addr_location *al, - struct perf_sample *sample, - struct perf_evsel *evsel) +static int perf_evsel__add_hist_entry(struct perf_evsel *evsel, + struct addr_location *al, + struct perf_sample *sample, + struct machine *machine) { struct symbol *parent = NULL; int err = 0; struct hist_entry *he; if ((sort__has_parent || symbol_conf.use_callchain) && sample->callchain) { - err = perf_session__resolve_callchain(session, evsel, al->thread, - sample->callchain, &parent); + err = machine__resolve_callchain(machine, evsel, al->thread, + sample->callchain, &parent); if (err) return err; } @@ -107,12 +107,12 @@ static int process_sample_event(struct perf_event_ops *ops, union perf_event *event, struct perf_sample *sample, struct perf_evsel *evsel, - struct perf_session *session) + struct machine *machine) { struct perf_report *rep = container_of(ops, struct perf_report, ops); 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) { fprintf(stderr, "problem processing %d event, skipping it.\n", event->header.type); @@ -128,7 +128,7 @@ static int process_sample_event(struct perf_event_ops *ops, if (al.map != NULL) 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"); return -1; } @@ -139,11 +139,11 @@ static int process_sample_event(struct perf_event_ops *ops, static int process_read_event(struct perf_event_ops *ops, union perf_event *event, 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_evsel *evsel = perf_evlist__id2evsel(session->evlist, - event->read.id); + if (rep->show_threads) { const char *name = evsel ? event_name(evsel) : "unknown"; perf_read_values_add_value(&rep->show_threads_values, diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index b11d6283fed..6a771f822e5 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -724,21 +724,21 @@ struct trace_migrate_task_event { struct trace_sched_handler { void (*switch_event)(struct trace_switch_event *, - struct perf_session *, + struct machine *, struct event *, int cpu, u64 timestamp, struct thread *thread); void (*runtime_event)(struct trace_runtime_event *, - struct perf_session *, + struct machine *, struct event *, int cpu, u64 timestamp, struct thread *thread); void (*wakeup_event)(struct trace_wakeup_event *, - struct perf_session *, + struct machine *, struct event *, int cpu, u64 timestamp, @@ -751,7 +751,7 @@ struct trace_sched_handler { struct thread *thread); void (*migrate_task_event)(struct trace_migrate_task_event *, - struct perf_session *session, + struct machine *machine, struct event *, int cpu, u64 timestamp, @@ -761,7 +761,7 @@ struct trace_sched_handler { static void replay_wakeup_event(struct trace_wakeup_event *wakeup_event, - struct perf_session *session __used, + struct machine *machine __used, struct event *event, int cpu __used, u64 timestamp __used, @@ -788,7 +788,7 @@ static u64 cpu_last_switched[MAX_CPUS]; static void replay_switch_event(struct trace_switch_event *switch_event, - struct perf_session *session __used, + struct machine *machine __used, struct event *event, int cpu, u64 timestamp, @@ -1022,7 +1022,7 @@ add_sched_in_event(struct work_atoms *atoms, u64 timestamp) static void latency_switch_event(struct trace_switch_event *switch_event, - struct perf_session *session, + struct machine *machine, struct event *event __used, int cpu, u64 timestamp, @@ -1046,8 +1046,8 @@ latency_switch_event(struct trace_switch_event *switch_event, die("hm, delta: %" PRIu64 " < 0 ?\n", delta); - sched_out = perf_session__findnew(session, switch_event->prev_pid); - sched_in = perf_session__findnew(session, switch_event->next_pid); + sched_out = machine__findnew_thread(machine, switch_event->prev_pid); + sched_in = machine__findnew_thread(machine, switch_event->next_pid); out_events = thread_atoms_search(&atom_root, sched_out, &cmp_pid); if (!out_events) { @@ -1075,13 +1075,13 @@ latency_switch_event(struct trace_switch_event *switch_event, static void latency_runtime_event(struct trace_runtime_event *runtime_event, - struct perf_session *session, + struct machine *machine, struct event *event __used, int cpu, u64 timestamp, struct thread *this_thread __used) { - struct thread *thread = perf_session__findnew(session, runtime_event->pid); + struct thread *thread = machine__findnew_thread(machine, runtime_event->pid); struct work_atoms *atoms = thread_atoms_search(&atom_root, thread, &cmp_pid); BUG_ON(cpu >= MAX_CPUS || cpu < 0); @@ -1098,7 +1098,7 @@ latency_runtime_event(struct trace_runtime_event *runtime_event, static void latency_wakeup_event(struct trace_wakeup_event *wakeup_event, - struct perf_session *session, + struct machine *machine, struct event *__event __used, int cpu __used, u64 timestamp, @@ -1112,7 +1112,7 @@ latency_wakeup_event(struct trace_wakeup_event *wakeup_event, if (!wakeup_event->success) return; - wakee = perf_session__findnew(session, wakeup_event->pid); + wakee = machine__findnew_thread(machine, wakeup_event->pid); atoms = thread_atoms_search(&atom_root, wakee, &cmp_pid); if (!atoms) { thread_atoms_insert(wakee); @@ -1146,7 +1146,7 @@ latency_wakeup_event(struct trace_wakeup_event *wakeup_event, static void latency_migrate_task_event(struct trace_migrate_task_event *migrate_task_event, - struct perf_session *session, + struct machine *machine, struct event *__event __used, int cpu __used, u64 timestamp, @@ -1162,7 +1162,7 @@ latency_migrate_task_event(struct trace_migrate_task_event *migrate_task_event, if (profile_cpu == -1) return; - migrant = perf_session__findnew(session, migrate_task_event->pid); + migrant = machine__findnew_thread(machine, migrate_task_event->pid); atoms = thread_atoms_search(&atom_root, migrant, &cmp_pid); if (!atoms) { thread_atoms_insert(migrant); @@ -1357,7 +1357,7 @@ static void sort_lat(void) static struct trace_sched_handler *trace_handler; static void -process_sched_wakeup_event(void *data, struct perf_session *session, +process_sched_wakeup_event(void *data, struct machine *machine, struct event *event, int cpu __used, u64 timestamp __used, @@ -1374,7 +1374,7 @@ process_sched_wakeup_event(void *data, struct perf_session *session, FILL_FIELD(wakeup_event, cpu, event, data); if (trace_handler->wakeup_event) - trace_handler->wakeup_event(&wakeup_event, session, event, + trace_handler->wakeup_event(&wakeup_event, machine, event, cpu, timestamp, thread); } @@ -1393,7 +1393,7 @@ static char next_shortname2 = '0'; static void map_switch_event(struct trace_switch_event *switch_event, - struct perf_session *session, + struct machine *machine, struct event *event __used, int this_cpu, u64 timestamp, @@ -1421,8 +1421,8 @@ map_switch_event(struct trace_switch_event *switch_event, die("hm, delta: %" PRIu64 " < 0 ?\n", delta); - sched_out = perf_session__findnew(session, switch_event->prev_pid); - sched_in = perf_session__findnew(session, switch_event->next_pid); + sched_out = machine__findnew_thread(machine, switch_event->prev_pid); + sched_in = machine__findnew_thread(machine, switch_event->next_pid); curr_thread[this_cpu] = sched_in; @@ -1472,7 +1472,7 @@ map_switch_event(struct trace_switch_event *switch_event, static void -process_sched_switch_event(void *data, struct perf_session *session, +process_sched_switch_event(void *data, struct machine *machine, struct event *event, int this_cpu, u64 timestamp __used, @@ -1499,14 +1499,14 @@ process_sched_switch_event(void *data, struct perf_session *session, nr_context_switch_bugs++; } if (trace_handler->switch_event) - trace_handler->switch_event(&switch_event, session, event, + trace_handler->switch_event(&switch_event, machine, event, this_cpu, timestamp, thread); curr_pid[this_cpu] = switch_event.next_pid; } static void -process_sched_runtime_event(void *data, struct perf_session *session, +process_sched_runtime_event(void *data, struct machine *machine, struct event *event, int cpu __used, u64 timestamp __used, @@ -1520,7 +1520,7 @@ process_sched_runtime_event(void *data, struct perf_session *session, FILL_FIELD(runtime_event, vruntime, event, data); if (trace_handler->runtime_event) - trace_handler->runtime_event(&runtime_event, session, event, cpu, timestamp, thread); + trace_handler->runtime_event(&runtime_event, machine, event, cpu, timestamp, thread); } static void @@ -1555,7 +1555,7 @@ process_sched_exit_event(struct event *event, } static void -process_sched_migrate_task_event(void *data, struct perf_session *session, +process_sched_migrate_task_event(void *data, struct machine *machine, struct event *event, int cpu __used, u64 timestamp __used, @@ -1571,12 +1571,12 @@ process_sched_migrate_task_event(void *data, struct perf_session *session, FILL_FIELD(migrate_task_event, cpu, event, data); if (trace_handler->migrate_task_event) - trace_handler->migrate_task_event(&migrate_task_event, session, + trace_handler->migrate_task_event(&migrate_task_event, machine, event, cpu, timestamp, thread); } static void process_raw_event(union perf_event *raw_event __used, - struct perf_session *session, void *data, int cpu, + struct machine *machine, void *data, int cpu, u64 timestamp, struct thread *thread) { struct event *event; @@ -1587,33 +1587,33 @@ static void process_raw_event(union perf_event *raw_event __used, event = trace_find_event(type); if (!strcmp(event->name, "sched_switch")) - process_sched_switch_event(data, session, event, cpu, timestamp, thread); + process_sched_switch_event(data, machine, event, cpu, timestamp, thread); if (!strcmp(event->name, "sched_stat_runtime")) - process_sched_runtime_event(data, session, event, cpu, timestamp, thread); + process_sched_runtime_event(data, machine, event, cpu, timestamp, thread); if (!strcmp(event->name, "sched_wakeup")) - process_sched_wakeup_event(data, session, event, cpu, timestamp, thread); + process_sched_wakeup_event(data, machine, event, cpu, timestamp, thread); if (!strcmp(event->name, "sched_wakeup_new")) - process_sched_wakeup_event(data, session, event, cpu, timestamp, thread); + process_sched_wakeup_event(data, machine, event, cpu, timestamp, thread); if (!strcmp(event->name, "sched_process_fork")) process_sched_fork_event(data, event, cpu, timestamp, thread); if (!strcmp(event->name, "sched_process_exit")) process_sched_exit_event(event, cpu, timestamp, thread); if (!strcmp(event->name, "sched_migrate_task")) - process_sched_migrate_task_event(data, session, event, cpu, timestamp, thread); + process_sched_migrate_task_event(data, machine, event, cpu, timestamp, thread); } static int process_sample_event(struct perf_event_ops *ops __used, union perf_event *event, struct perf_sample *sample, struct perf_evsel *evsel, - struct perf_session *session) + struct machine *machine) { struct thread *thread; if (!(evsel->attr.sample_type & PERF_SAMPLE_RAW)) return 0; - thread = perf_session__findnew(session, sample->pid); + thread = machine__findnew_thread(machine, sample->pid); if (thread == NULL) { pr_debug("problem processing %d event, skipping it.\n", event->header.type); @@ -1625,7 +1625,7 @@ static int process_sample_event(struct perf_event_ops *ops __used, if (profile_cpu != -1 && profile_cpu != (int)sample->cpu) return 0; - process_raw_event(event, session, sample->raw_data, sample->cpu, + process_raw_event(event, machine, sample->raw_data, sample->cpu, sample->time, thread); return 0; diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 3b7820612eb..31a8d14e5fb 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -315,7 +315,7 @@ static bool sample_addr_correlates_sym(struct perf_event_attr *attr) static void print_sample_addr(union perf_event *event, struct perf_sample *sample, - struct perf_session *session, + struct machine *machine, struct thread *thread, struct perf_event_attr *attr) { @@ -328,11 +328,11 @@ static void print_sample_addr(union perf_event *event, if (!sample_addr_correlates_sym(attr)) return; - thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION, - event->ip.pid, sample->addr, &al); + thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION, + sample->addr, &al); if (!al.map) - thread__find_addr_map(thread, session, cpumode, MAP__VARIABLE, - event->ip.pid, sample->addr, &al); + thread__find_addr_map(thread, machine, cpumode, MAP__VARIABLE, + sample->addr, &al); al.cpu = sample->cpu; al.sym = NULL; @@ -362,7 +362,7 @@ static void print_sample_addr(union perf_event *event, static void process_event(union perf_event *event __unused, struct perf_sample *sample, struct perf_evsel *evsel, - struct perf_session *session, + struct machine *machine, struct thread *thread) { struct perf_event_attr *attr = &evsel->attr; @@ -377,15 +377,15 @@ static void process_event(union perf_event *event __unused, sample->raw_size); 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 (!symbol_conf.use_callchain) printf(" "); else printf("\n"); - perf_session__print_ip(event, evsel, sample, session, - PRINT_FIELD(SYM), PRINT_FIELD(DSO)); + perf_event__print_ip(event, sample, machine, evsel, + PRINT_FIELD(SYM), PRINT_FIELD(DSO)); } printf("\n"); @@ -438,9 +438,9 @@ stat |