perf tools: Kill event_t typedef, use 'union perf_event' instead

And move the event_t methods to the perf_event__ too.

No code changes, just namespace consistency.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 8d50e5b4
......@@ -58,12 +58,13 @@ static int hists__add_entry(struct hists *self, struct addr_location *al)
return hist_entry__inc_addr_samples(he, al->addr);
}
static int process_sample_event(event_t *event, struct perf_sample *sample,
static int process_sample_event(union perf_event *event,
struct perf_sample *sample,
struct perf_session *session)
{
struct addr_location al;
if (event__preprocess_sample(event, session, &al, sample, NULL) < 0) {
if (perf_event__preprocess_sample(event, session, &al, sample, NULL) < 0) {
pr_warning("problem processing %d event, skipping it.\n",
event->header.type);
return -1;
......@@ -372,9 +373,9 @@ static void hists__find_annotations(struct hists *self)
static struct perf_event_ops event_ops = {
.sample = process_sample_event,
.mmap = event__process_mmap,
.comm = event__process_comm,
.fork = event__process_task,
.mmap = perf_event__process_mmap,
.comm = perf_event__process_comm,
.fork = perf_event__process_task,
.ordered_samples = true,
.ordering_requires_timestamps = true,
};
......
......@@ -30,13 +30,13 @@ static int hists__add_entry(struct hists *self,
return -ENOMEM;
}
static int diff__process_sample_event(event_t *event,
static int diff__process_sample_event(union perf_event *event,
struct perf_sample *sample,
struct perf_session *session)
{
struct addr_location al;
if (event__preprocess_sample(event, session, &al, sample, NULL) < 0) {
if (perf_event__preprocess_sample(event, session, &al, sample, NULL) < 0) {
pr_warning("problem processing %d event, skipping it.\n",
event->header.type);
return -1;
......@@ -56,11 +56,11 @@ static int diff__process_sample_event(event_t *event,
static struct perf_event_ops event_ops = {
.sample = diff__process_sample_event,
.mmap = event__process_mmap,
.comm = event__process_comm,
.exit = event__process_task,
.fork = event__process_task,
.lost = event__process_lost,
.mmap = perf_event__process_mmap,
.comm = perf_event__process_comm,
.exit = perf_event__process_task,
.fork = perf_event__process_task,
.lost = perf_event__process_lost,
.ordered_samples = true,
.ordering_requires_timestamps = true,
};
......
......@@ -16,7 +16,7 @@
static char const *input_name = "-";
static bool inject_build_ids;
static int event__repipe_synth(event_t *event,
static int perf_event__repipe_synth(union perf_event *event,
struct perf_session *session __used)
{
uint32_t size;
......@@ -36,41 +36,44 @@ static int event__repipe_synth(event_t *event,
return 0;
}
static int event__repipe(event_t *event, struct perf_sample *sample __used,
static int perf_event__repipe(union perf_event *event,
struct perf_sample *sample __used,
struct perf_session *session)
{
return event__repipe_synth(event, session);
return perf_event__repipe_synth(event, session);
}
static int event__repipe_mmap(event_t *self, struct perf_sample *sample,
static int perf_event__repipe_mmap(union perf_event *event,
struct perf_sample *sample,
struct perf_session *session)
{
int err;
err = event__process_mmap(self, sample, session);
event__repipe(self, sample, session);
err = perf_event__process_mmap(event, sample, session);
perf_event__repipe(event, sample, session);
return err;
}
static int event__repipe_task(event_t *self, struct perf_sample *sample,
static int perf_event__repipe_task(union perf_event *event,
struct perf_sample *sample,
struct perf_session *session)
{
int err;
err = event__process_task(self, sample, session);
event__repipe(self, sample, session);
err = perf_event__process_task(event, sample, session);
perf_event__repipe(event, sample, session);
return err;
}
static int event__repipe_tracing_data(event_t *self,
static int perf_event__repipe_tracing_data(union perf_event *event,
struct perf_session *session)
{
int err;
event__repipe_synth(self, session);
err = event__process_tracing_data(self, session);
perf_event__repipe_synth(event, session);
err = perf_event__process_tracing_data(event, session);
return err;
}
......@@ -109,7 +112,7 @@ static int dso__inject_build_id(struct dso *self, struct perf_session *session)
if (self->kernel)
misc = PERF_RECORD_MISC_KERNEL;
err = event__synthesize_build_id(self, misc, event__repipe,
err = perf_event__synthesize_build_id(self, misc, perf_event__repipe,
machine, session);
if (err) {
pr_err("Can't synthesize build_id event for %s\n", self->long_name);
......@@ -119,7 +122,8 @@ static int dso__inject_build_id(struct dso *self, struct perf_session *session)
return 0;
}
static int event__inject_buildid(event_t *event, struct perf_sample *sample,
static int perf_event__inject_buildid(union perf_event *event,
struct perf_sample *sample,
struct perf_session *session)
{
struct addr_location al;
......@@ -155,24 +159,24 @@ static int event__inject_buildid(event_t *event, struct perf_sample *sample,
}
repipe:
event__repipe(event, sample, session);
perf_event__repipe(event, sample, session);
return 0;
}
struct perf_event_ops inject_ops = {
.sample = event__repipe,
.mmap = event__repipe,
.comm = event__repipe,
.fork = event__repipe,
.exit = event__repipe,
.lost = event__repipe,
.read = event__repipe,
.throttle = event__repipe,
.unthrottle = event__repipe,
.attr = event__repipe_synth,
.event_type = event__repipe_synth,
.tracing_data = event__repipe_synth,
.build_id = event__repipe_synth,
.sample = perf_event__repipe,
.mmap = perf_event__repipe,
.comm = perf_event__repipe,
.fork = perf_event__repipe,
.exit = perf_event__repipe,
.lost = perf_event__repipe,
.read = perf_event__repipe,
.throttle = perf_event__repipe,
.unthrottle = perf_event__repipe,
.attr = perf_event__repipe_synth,
.event_type = perf_event__repipe_synth,
.tracing_data = perf_event__repipe_synth,
.build_id = perf_event__repipe_synth,
};
extern volatile int session_done;
......@@ -190,10 +194,10 @@ static int __cmd_inject(void)
signal(SIGINT, sig_handler);
if (inject_build_ids) {
inject_ops.sample = event__inject_buildid;
inject_ops.mmap = event__repipe_mmap;
inject_ops.fork = event__repipe_task;
inject_ops.tracing_data = event__repipe_tracing_data;
inject_ops.sample = perf_event__inject_buildid;
inject_ops.mmap = perf_event__repipe_mmap;
inject_ops.fork = perf_event__repipe_task;
inject_ops.tracing_data = perf_event__repipe_tracing_data;
}
session = perf_session__new(input_name, O_RDONLY, false, true, &inject_ops);
......
......@@ -275,8 +275,7 @@ static void process_free_event(void *data,
s_alloc->alloc_cpu = -1;
}
static void
process_raw_event(event_t *raw_event __used, void *data,
static void process_raw_event(union perf_event *raw_event __used, void *data,
int cpu, u64 timestamp, struct thread *thread)
{
struct event *event;
......@@ -304,7 +303,8 @@ process_raw_event(event_t *raw_event __used, void *data,
}
}
static int process_sample_event(event_t *event, struct perf_sample *sample,
static int process_sample_event(union perf_event *event,
struct perf_sample *sample,
struct perf_session *session)
{
struct thread *thread = perf_session__findnew(session, event->ip.pid);
......@@ -325,7 +325,7 @@ static int process_sample_event(event_t *event, struct perf_sample *sample,
static struct perf_event_ops event_ops = {
.sample = process_sample_event,
.comm = event__process_comm,
.comm = perf_event__process_comm,
.ordered_samples = true,
};
......
......@@ -834,14 +834,14 @@ static void dump_info(void)
die("Unknown type of information\n");
}
static int process_sample_event(event_t *self, struct perf_sample *sample,
static int process_sample_event(union perf_event *event, struct perf_sample *sample,
struct perf_session *s)
{
struct thread *thread = perf_session__findnew(s, sample->tid);
if (thread == NULL) {
pr_debug("problem processing %d event, skipping it.\n",
self->header.type);
event->header.type);
return -1;
}
......@@ -852,7 +852,7 @@ static int process_sample_event(event_t *self, struct perf_sample *sample,
static struct perf_event_ops eops = {
.sample = process_sample_event,
.comm = event__process_comm,
.comm = perf_event__process_comm,
.ordered_samples = true,
};
......
......@@ -100,7 +100,7 @@ static void write_output(void *buf, size_t size)
}
}
static int process_synthesized_event(event_t *event,
static int process_synthesized_event(union perf_event *event,
struct perf_sample *sample __used,
struct perf_session *self __used)
{
......@@ -404,7 +404,7 @@ static void atexit_header(void)
}
}
static void event__synthesize_guest_os(struct machine *machine, void *data)
static void perf_event__synthesize_guest_os(struct machine *machine, void *data)
{
int err;
struct perf_session *psession = data;
......@@ -420,7 +420,7 @@ static void event__synthesize_guest_os(struct machine *machine, void *data)
*method is used to avoid symbol missing when the first addr is
*in module instead of in guest kernel.
*/
err = event__synthesize_modules(process_synthesized_event,
err = perf_event__synthesize_modules(process_synthesized_event,
psession, machine);
if (err < 0)
pr_err("Couldn't record guest kernel [%d]'s reference"
......@@ -430,11 +430,12 @@ static void event__synthesize_guest_os(struct machine *machine, void *data)
* We use _stext for guest kernel because guest kernel's /proc/kallsyms
* have no _text sometimes.
*/
err = event__synthesize_kernel_mmap(process_synthesized_event,
err = perf_event__synthesize_kernel_mmap(process_synthesized_event,
psession, machine, "_text");
if (err < 0)
err = event__synthesize_kernel_mmap(process_synthesized_event,
psession, machine, "_stext");
err = perf_event__synthesize_kernel_mmap(process_synthesized_event,
psession, machine,
"_stext");
if (err < 0)
pr_err("Couldn't record guest kernel [%d]'s reference"
" relocation symbol.\n", machine->pid);
......@@ -617,7 +618,7 @@ static int __cmd_record(int argc, const char **argv)
perf_session__set_sample_id_all(session, sample_id_all_avail);
if (pipe_output) {
err = event__synthesize_attrs(&session->header,
err = perf_event__synthesize_attrs(&session->header,
process_synthesized_event,
session);
if (err < 0) {
......@@ -625,7 +626,7 @@ static int __cmd_record(int argc, const char **argv)
return err;
}
err = event__synthesize_event_types(process_synthesized_event,
err = perf_event__synthesize_event_types(process_synthesized_event,
session);
if (err < 0) {
pr_err("Couldn't synthesize event_types.\n");
......@@ -641,7 +642,7 @@ static int __cmd_record(int argc, const char **argv)
* return this more properly and also
* propagate errors that now are calling die()
*/
err = event__synthesize_tracing_data(output, evsel_list,
err = perf_event__synthesize_tracing_data(output, evsel_list,
process_synthesized_event,
session);
if (err <= 0) {
......@@ -658,17 +659,17 @@ static int __cmd_record(int argc, const char **argv)
return -1;
}
err = event__synthesize_kernel_mmap(process_synthesized_event,
err = perf_event__synthesize_kernel_mmap(process_synthesized_event,
session, machine, "_text");
if (err < 0)
err = event__synthesize_kernel_mmap(process_synthesized_event,
err = perf_event__synthesize_kernel_mmap(process_synthesized_event,
session, 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 = event__synthesize_modules(process_synthesized_event,
err = perf_event__synthesize_modules(process_synthesized_event,
session, machine);
if (err < 0)
pr_err("Couldn't record kernel module information.\n"
......@@ -676,13 +677,16 @@ static int __cmd_record(int argc, const char **argv)
"Check /proc/modules permission or run as root.\n");
if (perf_guest)
perf_session__process_machines(session, event__synthesize_guest_os);
perf_session__process_machines(session,
perf_event__synthesize_guest_os);
if (!system_wide)
event__synthesize_thread(target_tid, process_synthesized_event,
perf_event__synthesize_thread(target_tid,
process_synthesized_event,
session);
else
event__synthesize_threads(process_synthesized_event, session);
perf_event__synthesize_threads(process_synthesized_event,
session);
if (realtime_prio) {
struct sched_param param;
......
......@@ -149,13 +149,14 @@ static int add_event_total(struct perf_session *session,
return 0;
}
static int process_sample_event(event_t *event, struct perf_sample *sample,
static int process_sample_event(union perf_event *event,
struct perf_sample *sample,
struct perf_session *session)
{
struct addr_location al;
struct perf_event_attr *attr;
if (event__preprocess_sample(event, session, &al, sample, NULL) < 0) {
if (perf_event__preprocess_sample(event, session, &al, sample, NULL) < 0) {
fprintf(stderr, "problem processing %d event, skipping it.\n",
event->header.type);
return -1;
......@@ -179,7 +180,8 @@ static int process_sample_event(event_t *event, struct perf_sample *sample,
return 0;
}
static int process_read_event(event_t *event, struct perf_sample *sample __used,
static int process_read_event(union perf_event *event,
struct perf_sample *sample __used,
struct perf_session *session __used)
{
struct perf_event_attr *attr;
......@@ -233,16 +235,16 @@ static int perf_session__setup_sample_type(struct perf_session *self)
static struct perf_event_ops event_ops = {
.sample = process_sample_event,
.mmap = event__process_mmap,
.comm = event__process_comm,
.exit = event__process_task,
.fork = event__process_task,
.lost = event__process_lost,
.mmap = perf_event__process_mmap,
.comm = perf_event__process_comm,
.exit = perf_event__process_task,
.fork = perf_event__process_task,
.lost = perf_event__process_lost,
.read = process_read_event,
.attr = event__process_attr,
.event_type = event__process_event_type,
.tracing_data = event__process_tracing_data,
.build_id = event__process_build_id,
.attr = perf_event__process_attr,
.event_type = perf_event__process_event_type,
.tracing_data = perf_event__process_tracing_data,
.build_id = perf_event__process_build_id,
.ordered_samples = true,
.ordering_requires_timestamps = true,
};
......
......@@ -1580,9 +1580,9 @@ process_sched_migrate_task_event(void *data, struct perf_session *session,
event, cpu, timestamp, thread);
}
static void
process_raw_event(event_t *raw_event __used, struct perf_session *session,
void *data, int cpu, u64 timestamp, struct thread *thread)
static void process_raw_event(union perf_event *raw_event __used,
struct perf_session *session, void *data, int cpu,
u64 timestamp, struct thread *thread)
{
struct event *event;
int type;
......@@ -1607,7 +1607,8 @@ process_raw_event(event_t *raw_event __used, struct perf_session *session,
process_sched_migrate_task_event(data, session, event, cpu, timestamp, thread);
}
static int process_sample_event(event_t *event, struct perf_sample *sample,
static int process_sample_event(union perf_event *event,
struct perf_sample *sample,
struct perf_session *session)
{
struct thread *thread;
......@@ -1635,9 +1636,9 @@ static int process_sample_event(event_t *event, struct perf_sample *sample,
static struct perf_event_ops event_ops = {
.sample = process_sample_event,
.comm = event__process_comm,
.lost = event__process_lost,
.fork = event__process_task,
.comm = perf_event__process_comm,
.lost = perf_event__process_lost,
.fork = perf_event__process_task,
.ordered_samples = true,
};
......
......@@ -63,7 +63,8 @@ static int cleanup_scripting(void)
static char const *input_name = "perf.data";
static int process_sample_event(event_t *event, struct perf_sample *sample,
static int process_sample_event(union perf_event *event,
struct perf_sample *sample,
struct perf_session *session)
{
struct thread *thread = perf_session__findnew(session, event->ip.pid);
......@@ -101,13 +102,13 @@ static int process_sample_event(event_t *event, struct perf_sample *sample,
static struct perf_event_ops event_ops = {
.sample = process_sample_event,
.comm = event__process_comm,
.attr = event__process_attr,
.event_type = event__process_event_type,
.tracing_data = event__process_tracing_data,
.build_id = event__process_build_id,
.ordering_requires_timestamps = true,
.comm = perf_event__process_comm,
.attr = perf_event__process_attr,
.event_type = perf_event__process_event_type,
.tracing_data = perf_event__process_tracing_data,
.build_id = perf_event__process_build_id,
.ordered_samples = true,
.ordering_requires_timestamps = true,
};
extern volatile int session_done;
......
......@@ -454,7 +454,7 @@ static int test__open_syscall_event_on_all_cpus(void)
static int test__basic_mmap(void)
{
int err = -1;
event_t *event;
union perf_event *event;
struct thread_map *threads;
struct cpu_map *cpus;
struct perf_evlist *evlist;
......@@ -554,11 +554,11 @@ static int test__basic_mmap(void)
if (event->header.type != PERF_RECORD_SAMPLE) {
pr_debug("unexpected %s event\n",
event__get_event_name(event->header.type));
perf_event__name(event->header.type));
goto out_munmap;
}
event__parse_sample(event, attr.sample_type, false, &sample);
perf_event__parse_sample(event, attr.sample_type, false, &sample);
evsel = perf_evlist__id2evsel(evlist, sample.id);
if (evsel == NULL) {
pr_debug("event with id %" PRIu64
......
......@@ -276,21 +276,24 @@ static int cpus_cstate_state[MAX_CPUS];
static u64 cpus_pstate_start_times[MAX_CPUS];
static u64 cpus_pstate_state[MAX_CPUS];
static int process_comm_event(event_t *event, struct perf_sample *sample __used,
static int process_comm_event(union perf_event *event,
struct perf_sample *sample __used,
struct perf_session *session __used)
{
pid_set_comm(event->comm.tid, event->comm.comm);
return 0;
}
static int process_fork_event(event_t *event, struct perf_sample *sample __used,
static int process_fork_event(union perf_event *event,
struct perf_sample *sample __used,
struct perf_session *session __used)
{
pid_fork(event->fork.pid, event->fork.ppid, event->fork.time);
return 0;
}
static int process_exit_event(event_t *event, struct perf_sample *sample __used,
static int process_exit_event(union perf_event *event,
struct perf_sample *sample __used,
struct perf_session *session __used)
{
pid_exit(event->fork.pid, event->fork.time);
......@@ -486,7 +489,7 @@ static void sched_switch(int cpu, u64 timestamp, struct trace_entry *te)
}
static int process_sample_event(event_t *event __used,
static int process_sample_event(union perf_event *event __used,
struct perf_sample *sample,
struct perf_session *session)
{
......
......@@ -401,7 +401,7 @@ static void show_details(struct sym_entry *syme)
}
/*
* Symbols will be added here in event__process_sample and will get out
* Symbols will be added here in perf_event__process_sample and will get out
* after decayed.
*/
static LIST_HEAD(active_symbols);
......@@ -996,15 +996,15 @@ static int symbol_filter(struct map *map, struct symbol *sym)
return 0;
}
static void event__process_sample(const event_t *self,
static void perf_event__process_sample(const union perf_event *event,
struct perf_sample *sample,
struct perf_session *session)
{
u64 ip = self->ip.ip;
u64 ip = event->ip.ip;
struct sym_entry *syme;
struct addr_location al;
struct machine *machine;
u8 origin = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
u8 origin = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
++samples;
......@@ -1023,7 +1023,7 @@ static void event__process_sample(const event_t *self,
break;
case PERF_RECORD_MISC_GUEST_KERNEL:
++guest_kernel_samples;
machine = perf_session__find_machine(session, self->ip.pid);
machine = perf_session__find_machine(session, event->ip.pid);
break;
case PERF_RECORD_MISC_GUEST_USER:
++guest_us_samples;
......@@ -1038,14 +1038,14 @@ static void event__process_sample(const event_t *self,
if (!machine && perf_guest) {
pr_err("Can't find guest [%d]'s kernel information\n",
self->ip.pid);
event->ip.pid);
return;
}
if (self->header.misc & PERF_RECORD_MISC_EXACT_IP)
if (event->header.misc & PERF_RECORD_MISC_EXACT_IP)
exact_samples++;
if (event__preprocess_sample(self, session, &al, sample,
if (perf_event__preprocess_sample(event, session, &al, sample,
symbol_filter) < 0 ||
al.filtered)
return;
......@@ -1108,15 +1108,15 @@ static void event__process_sample(const event_t *self,
static void perf_session__mmap_read_cpu(struct perf_session *self, int cpu)
{
struct perf_sample sample;
event_t *event;
union perf_event *event;
while ((event = perf_evlist__read_on_cpu(evsel_list, cpu)) != NULL) {
perf_session__parse_sample(self, event, &sample);
if (event->header.type == PERF_RECORD_SAMPLE)
event__process_sample(event, &sample, self);
perf_event__process_sample(event, &sample, self);
else
event__process(event, &sample, self);
perf_event__process(event, &sample, self);
}
}
......@@ -1199,9 +1199,10 @@ static int __cmd_top(void)
return -ENOMEM;
if (target_tid != -1)
event__synthesize_thread(target_tid, event__process, session);
perf_event__synthesize_thread(target_tid, perf_event__process,
session);
else
event__synthesize_threads(event__process, session);
perf_event__synthesize_threads(perf_event__process, session);
start_counters(evsel_list);
first = list_entry(evsel_list->entries.next, struct perf_evsel, node);
......
......@@ -14,7 +14,7 @@
#include <linux/kernel.h>
#include "debug.h"
static int build_id__mark_dso_hit(event_t *event,
static int build_id__mark_dso_hit(union perf_event *event,
struct perf_sample *sample __used,
struct perf_session *session)
{
......@@ -37,13 +37,14 @@ static int build_id__mark_dso_hit(event_t *event,
return 0;
}
static int event__exit_del_thread(event_t *self, struct perf_sample *sample __used,
static int perf_event__exit_del_thread(union perf_event *event,
struct perf_sample *sample __used,
struct perf_session *session)
{
struct thread *thread = perf_session__findnew(session, self->fork.tid);
struct thread *thread = perf_session__findnew(session, event->fork.tid);
dump_printf("(%d:%d):(%d:%d)\n", self->fork.pid, self->fork.tid,
self->fork.ppid, self->fork.ptid);
dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid,
event->fork.ppid, event->fork.ptid);
if (thread) {
rb_erase(&thread->rb_node, &session->threads);
......@@ -56,9 +57,9 @@ static int event__exit_del_thread(event_t *self, struct perf_sample *sample __us
struct perf_event_ops build_id__mark_dso_hit_ops = {
.sample = build_id__mark_dso_hit,
.mmap = event__process_mmap,
.fork = event__process_task,
.exit = event__exit_del_thread,
.mmap = perf_event__process_mmap,
.fork = perf_event__process_task,
.exit = perf_event__exit_del_thread,
};
char *dso__build_id_filename(struct dso *self, char *bf, size_t size)
......
......@@ -18,7 +18,8 @@
#include "util.h"
#include "callchain.h"
bool ip_callchain__valid(struct ip_callchain *chain, const event_t *event)
bool ip_callchain__valid(struct ip_callchain *chain,
const union perf_event *event)
{
unsigned int chain_size = event->header.size;
chain_size -= (unsigned long)&event->ip.__more_data - (unsigned long)event;
......
......@@ -95,8 +95,8 @@ int callchain_append(struct callchain_root *root,
int callchain_merge(struct callchain_cursor *cursor,
struct callchain_root *dst, struct callchain_root *src);
bool ip_callchain__valid(struct ip_callchain *chain, const event_t *event);
bool ip_callchain__valid(struct ip_callchain *chain,
const union perf_event *event);
/*
* Initialize a cursor before adding entries inside, but keep
* the previously allocated entries as a cache.
......
......@@ -57,7 +57,7 @@ void ui__warning(const char *format, ...)
}
#endif
void trace_event(event_t *event)
void trace_event(union perf_event *event)
{
unsigned char *raw_event = (void *)event;
const char *color = PERF_COLOR_BLUE;
......
......@@ -9,7 +9,7 @@ extern int verbose;
extern bool quiet, dump_trace;
int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
void trace_event(event_t *event);
void trace_event(union perf_event *event);
struct ui_progress;
......
This diff is collapsed.
......@@ -117,7 +117,7 @@ struct tracing_data_event {
u32 size;
};
typedef union event_union {
union perf_event {
struct perf_event_header header;
struct ip_event ip;
struct mmap_event mmap;
......@@ -130,49 +130,52 @@ typedef union event_union {
struct event_type_event event_type;
struct tracing_data_event tracing_data;
struct build_id_event build_id;
} event_t;
};
void event__print_totals(void);
void perf_event__print_totals(void);
struct perf_session;
typedef int (*event__handler_synth_t)(event_t *event,
typedef int (*perf_event__handler_synth_t)(union perf_event *event,
struct perf_session *session);
typedef int (*event__handler_t)(event_t *event, struct perf_sample *sample,
typedef int (*perf_event__handler_t)(union perf_event *event,
struct perf_sample *sample,
struct perf_session *session);
int event__synthesize_thread(pid_t pid, event__handler_t process,
int perf_event__synthesize_thread(pid_t pid, perf_event__handler_t process,
struct perf_session *session);
int event__synthesize_threads(event__handler_t process,
int perf_event__synthesize_threads(perf_event__handler_t process,
struct perf_session *session);
int event__synthesize_kernel_mmap(event__handler_t process,
int perf_event__synthesize_kernel_mmap(perf_event__handler_t process,
struct perf_session *session,
struct machine *machine,
const char *symbol_name);
int event__synthesize_modules(event__handler_t process,
int perf_event__synthesize_modules(perf_event__handler_t process,
struct perf_session *session,
struct machine *machine);
int event__process_comm(event_t *event, struct perf_sample *sample,
int perf_event__process_comm(union perf_event *event, struct perf_sample *sample,
struct perf_session *session);
int event__process_lost(event_t *event, struct perf_sample *sample,
int perf_event__process_lost(union perf_event *event, struct perf_sample *sample,
struct perf_session *session);
int event__process_mmap(event_t *event, struct perf_sample *sample,
int perf_event__process_mmap(union perf_event *event, struct perf_sample *sample,
struct perf_session *session);
int event__process_task(event_t *event, struct perf_sample *sample,
int perf_event__process_task(union perf_event *event, struct perf_sample *sample,
struct perf_session *session);
int event__process(event_t *event, struct perf_sample *sample,
int perf_event__process(union perf_event *event, struct perf_sample *sample,
struct perf_session *session);
struct addr_location;
int event__preprocess_sample(const event_t *self, struct perf_session *session,
struct addr_location *al, struct perf_sample *sample,
int perf_event__preprocess_sample(const union perf_event *self,
struct perf_session *session,
struct addr_location *al,
struct perf_sample *sample,
symbol_filter_t filter);
const char *event__get_event_name(unsigned int id);
const char *perf_event__name(unsigned int id);
int event__parse_sample(const event_t *event, u64 type, bool sample_id_all,
struct perf_sample *sample);
int perf_event__parse_sample(const union perf_event *event, u64 type,
bool sample_id_all, struct perf_sample *sample);
#endif /* __PERF_RECORD_H */
......@@ -107,7 +107,7 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id)
return NULL;
}
event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu)
union perf_event *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu)
{
/* XXX Move this to perf.c, making it generally available */
unsigned int page_size = sysconf(_SC_PAGE_SIZE);
......@@ -115,7 +115,7 @@ event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu)
unsigned int head = perf_mmap__read_head(md);
unsigned int old = md->prev;
unsigned char *data = md->base + page_size;
event_t *event = NULL;
union perf_event *event = NULL;
if (evlist->overwrite) {
/*
......@@ -140,7 +140,7 @@ event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu)
if (old != head) {
size_t size;
event = (event_t *)&data[old & md->mask];
event = (union perf_event *)&data[old & md->mask];
size = event->header.size;
/*
......
......@@ -17,7 +17,7 @@ struct perf_evlist {
int nr_fds;
int mmap_len;
bool overwrite;
event_t event_copy;
union perf_event event_copy;
struct perf_mmap *mmap;
struct pollfd *pollfd;
};
......@@ -37,6 +37,6 @@ void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd);
struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);
event_t *perf_evlist__read_on_cpu(struct perf_evlist *self, int cpu);
union perf_event *perf_evlist__read_on_cpu(struct perf_evlist *self, int cpu);
#endif /* __PERF_EVLIST_H */
......@@ -367,7 +367,7 @@ int perf_evlist__mmap(struct perf_evlist *evlist, struct cpu_map *cpus,
return -1;
}
static int event__parse_id_sample(const event_t *event, u64 type,
static int perf_event__parse_id_sample(const union perf_event *event, u64 type,
struct perf_sample *sample)
{
const u64 *array = event->sample.array;
......@@ -405,8 +405,8 @@ static int event__parse_id_sample(const event_t *event, u64 type,
return 0;
}
int event__parse_sample(const event_t *event, u64 type, bool sample_id_all,
struct perf_sample *data)
int perf_event__parse_sample(const union perf_event *event, u64 type,
bool sample_id_all, struct perf_sample *data)
{
const u64 *array;
......@@ -416,7 +416,7 @@ int event__parse_sample(const event_t *event, u64 type, bool sample_id_all,
if (event->header.type != PERF_RECORD_SAMPLE) {
if (!sample_id_all)
return 0;
return event__parse_id_sample(event, type, data);
return perf_event__parse_id_sample(event, type, data);
}
array = event->sample.array;
......
......@@ -1000,11 +1000,11 @@ perf_header__find_attr(u64 id, struct perf_header *header)
return NULL;
}
int event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id,
event__handler_t process,
int perf_event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id,
perf_event__handler_t process,
struct perf_session *session)
{
event_t *ev;
union perf_event *ev;
size_t size;
int err;
......@@ -1031,7 +1031,8 @@ int event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id,
return err;
}
int event__synthesize_attrs(struct perf_header *self, event__handler_t process,
int perf_event__synthesize_attrs(struct perf_header *self,
perf_event__handler_t process,
struct perf_session *session)
{
struct perf_header_attr *attr;
......@@ -1040,8 +1041,8 @@ int event__synthesize_attrs(struct perf_header *self, event__handler_t process,
for (i = 0; i < self->attrs; i++) {
attr = self->attr[i];
err = event__synthesize_attr(&attr->attr, attr->ids, attr->id,
process, session);
err = perf_event__synthesize_attr(&attr->attr, attr->ids,
attr->id, process, session);
if (err) {
pr_debug("failed to create perf header attribute\n");
return err;
......@@ -1051,21 +1052,22 @@ int event__synthesize_attrs(struct perf_header *self, event__handler_t process,
return err;
}
int event__process_attr(event_t *self, struct perf_session *session)
int perf_event__process_attr(union perf_event *event,
struct perf_session *session)
{
struct perf_header_attr *attr;
unsigned int i, ids, n_ids;
attr = perf_header_attr__new(&self->attr.attr);
attr = perf_header_attr__new(&event->attr.attr);
if (attr == NULL)
return -ENOMEM;
ids = self->header.size;
ids -= (void *)&self->attr.id - (void *)self;
ids = event->header.size;
ids -= (void *)&event->attr.id - (void *)event;
n_ids = ids / sizeof(u64);
for (i = 0; i < n_ids; i++) {
if (perf_header_attr__add_id(attr, self->attr.id[i]) < 0) {
if (perf_header_attr__add_id(attr, event->attr.id[i]) < 0) {
perf_header_attr__delete(attr);
return -ENOMEM;
}
......@@ -1081,11 +1083,11 @@ int event__process_attr(event_t *self, struct perf_session *session)
return 0;
}
int event__synthesize_event_type(u64 event_id, char *name,
event__handler_t process,
int perf_event__synthesize_event_type(u64 event_id, char *name,
perf_event__handler_t process,
struct perf_session *session)
{
event_t ev;
union perf_event ev;
size_t size = 0;
int err = 0;
......@@ -1106,7 +1108,7 @@ int event__synthesize_event_type(u64 event_id, char *name,
return err;
}
int event__synthesize_event_types(event__handler_t process,
int perf_event__synthesize_event_types(perf_event__handler_t process,
struct perf_session *session)
{
struct perf_trace_event_type *type;
......@@ -1115,8 +1117,9 @@ int event__synthesize_event_types(event__handler_t process,
for (i = 0; i < event_count; i++) {
type = &events[i];
err = event__synthesize_event_type(type->event_id, type->name,
process, session);
err = perf_event__synthesize_event_type(type->event_id,
type->name, process,
session);
if (err) {
pr_debug("failed to create perf header event type\n");
return err;
......@@ -1126,21 +1129,21 @@ int event__synthesize_event_types(event__handler_t process,
return err;
}
int event__process_event_type(event_t *self,
int perf_event__process_event_type(union perf_event *event,
struct perf_session *session __unused)
{
if (perf_header__push_event(self->event_type.event_type.event_id,
self->event_type.event_type.name) < 0)
if (perf_header__push_event(event->event_type.event_type.event_id,
event->event_type.event_type.name) < 0)
return -ENOMEM;
return 0;
}
int event__synthesize_tracing_data(int fd, struct perf_evlist *evlist,
event__handler_t process,
int perf_event__synthesize_tracing_data(int fd, struct perf_evlist *evlist,
perf_event__handler_t process,
struct perf_session *session __unused)
{
event_t ev;
union perf_event ev;
ssize_t size = 0, aligned_size = 0, padding;
int err = 0;
......@@ -1163,10 +1166,10 @@ int event__synthesize_tracing_data(int fd, struct perf_evlist *evlist,
return aligned_size;
}
int event__process_tracing_data(event_t *self,
int perf_event__process_tracing_data(union perf_event *event,
struct perf_session *session)
{
ssize_t size_read, padding, size = self->tracing_data.size;
ssize_t size_read, padding, size = event->tracing_data.size;
off_t offset = lseek(session->fd, 0, SEEK_CUR);
char buf[BUFSIZ];
......@@ -1192,12 +1195,12 @@ int event__process_tracing_data(event_t *self,
return size_read + padding;
}
int event__synthesize_build_id(struct dso *pos, u16 misc,
event__handler_t process,
int perf_event__synthesize_build_id(struct dso *pos, u16 misc,
perf_event__handler_t process,
struct machine *machine,
struct perf_session *session)
{
event_t ev;
union perf_event ev;
size_t len;
int err = 0;
......@@ -1220,11 +1223,11 @@ int event__synthesize_build_id(struct dso *pos, u16 misc,
return err;
}
int event__process_build_id(event_t *self,
int perf_event__process_build_id(union perf_event *event,
struct perf_session *session)
{
__event_process_build_id(&self->build_id,
self->build_id.filename,
__event_process_build_id(&event->build_id,
event->build_id.filename,
session);
return 0;
}
......
......@@ -100,32 +100,32 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
const char *name, bool is_kallsyms);
int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir);
int event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id,
event__handler_t process,
int perf_event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id,
perf_event__handler_t process,
struct perf_session *session);
int event__synthesize_attrs(struct perf_header *self,
event__handler_t process,
int perf_event__synthesize_attrs(struct perf_header *self,
perf_event__handler_t process,
struct perf_session *session);
int event__process_attr(event_t *self, struct perf_session *session);
int perf_event__process_attr(union perf_event *event, struct perf_session *session);
int event__synthesize_event_type(u64 event_id, char *name,
event__handler_t process,
int perf_event__synthesize_event_type(u64 event_id, char *name,
perf_event__handler_t process,
struct perf_session *session);
int event__synthesize_event_types(event__handler_t process,
int perf_event__synthesize_event_types(perf_event__handler_t process,
struct perf_session *session);
int event__process_event_type(event_t *self,
int perf_event__process_event_type(union perf_event *event,
struct perf_session *session);
int event__synthesize_tracing_data(int fd, struct perf_evlist *evlist,
event__handler_t process,
int perf_event__synthesize_tracing_data(int fd, struct perf_evlist *evlist,
perf_event__handler_t process,
struct perf_session *session);
int event__process_tracing_data(event_t *self,
int perf_event__process_tracing_data(union perf_event *event,
struct perf_session *session);
int event__synthesize_build_id(struct dso *pos, u16 misc,
event__handler_t process,
int perf_event__synthesize_build_id(struct dso *pos, u16 misc,
perf_event__handler_t process,
struct machine *machine,
struct perf_session *session);
int event__process_build_id(event_t *self, struct perf_session *session);
int perf_event__process_build_id(union perf_event *event,
struct perf_session *session);
#endif /* __PERF_HEADER_H */
......@@ -1182,7 +1182,7 @@ size_t hists__fprintf_nr_events(struct hists *self, FILE *fp)
size_t ret = 0;
for (i = 0; i < PERF_RECORD_HEADER_MAX; ++i) {
const char *name = event__get_event_name(i);
const char *name = perf_event__name(i);
if (!strcmp(name, "UNKNOWN"))
continue;
......
This diff is collapsed.
......@@ -57,10 +57,11 @@ struct perf_session {
struct perf_event_ops;
typedef int (*event_op)(event_t *self, struct perf_sample *sample,
typedef int (*event_op)(union perf_event *self, struct perf_sample *sample,
struct perf_session *session);
typedef int (*event_synth_op)(event_t *self, struct perf_session *session);
typedef int (*event_op2)(event_t *self, struct perf_session *session,
typedef int (*event_synth_op)(union perf_event *self,
struct perf_session *session);
typedef int (*event_op2)(union perf_event *self, struct perf_session *session,
struct perf_event_ops *ops);
struct perf_event_ops {
......@@ -157,10 +158,10 @@ size_t perf_session__fprintf_nr_events(struct perf_session *self, FILE *fp)
}
static inline int perf_session__parse_sample(struct perf_session *session,
const event_t *event,
const union perf_event *event,
struct perf_sample *sample)
{
return event__parse_sample(event, session->sample_type,
return perf_event__parse_sample(event, session->sample_type,
session->sample_id_all, sample);
}
......
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