Skip to content

Commit

Permalink
perf tools: Kill event_t typedef, use 'union perf_event' instead
Browse files Browse the repository at this point in the history
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: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
acmel committed Jan 29, 2011
1 parent 8d50e5b commit 8115d60
Show file tree
Hide file tree
Showing 27 changed files with 475 additions and 439 deletions.
11 changes: 6 additions & 5 deletions tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
};
Expand Down
14 changes: 7 additions & 7 deletions tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
};
Expand Down
82 changes: 43 additions & 39 deletions tools/perf/builtin-inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
static char const *input_name = "-";
static bool inject_build_ids;

static int event__repipe_synth(event_t *event,
struct perf_session *session __used)
static int perf_event__repipe_synth(union perf_event *event,
struct perf_session *session __used)
{
uint32_t size;
void *buf = event;
Expand All @@ -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,
struct perf_session *session)
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,
struct perf_session *session)
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,
struct perf_session *session)
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,
struct perf_session *session)
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;
}
Expand Down Expand Up @@ -109,8 +112,8 @@ 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,
machine, session);
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);
return -1;
Expand All @@ -119,8 +122,9 @@ 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,
struct perf_session *session)
static int perf_event__inject_buildid(union perf_event *event,
struct perf_sample *sample,
struct perf_session *session)
{
struct addr_location al;
struct thread *thread;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions tools/perf/builtin-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,8 @@ static void process_free_event(void *data,
s_alloc->alloc_cpu = -1;
}

static void
process_raw_event(event_t *raw_event __used, void *data,
int cpu, u64 timestamp, struct thread *thread)
static void process_raw_event(union perf_event *raw_event __used, void *data,
int cpu, u64 timestamp, struct thread *thread)
{
struct event *event;
int type;
Expand All @@ -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);
Expand All @@ -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,
};

Expand Down
6 changes: 3 additions & 3 deletions tools/perf/builtin-lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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,
};

Expand Down
56 changes: 30 additions & 26 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand All @@ -420,8 +420,8 @@ 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,
psession, machine);
err = perf_event__synthesize_modules(process_synthesized_event,
psession, machine);
if (err < 0)
pr_err("Couldn't record guest kernel [%d]'s reference"
" relocation symbol.\n", machine->pid);
Expand All @@ -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,
psession, machine, "_text");
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);
Expand Down Expand Up @@ -617,16 +618,16 @@ 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,
process_synthesized_event,
session);
err = perf_event__synthesize_attrs(&session->header,
process_synthesized_event,
session);
if (err < 0) {
pr_err("Couldn't synthesize attrs.\n");
return err;
}

err = event__synthesize_event_types(process_synthesized_event,
session);
err = perf_event__synthesize_event_types(process_synthesized_event,
session);
if (err < 0) {
pr_err("Couldn't synthesize event_types.\n");
return err;
Expand All @@ -641,9 +642,9 @@ 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,
process_synthesized_event,
session);
err = perf_event__synthesize_tracing_data(output, evsel_list,
process_synthesized_event,
session);
if (err <= 0) {
pr_err("Couldn't record tracing data.\n");
return err;
Expand All @@ -658,31 +659,34 @@ static int __cmd_record(int argc, const char **argv)
return -1;
}

err = event__synthesize_kernel_mmap(process_synthesized_event,
session, machine, "_text");
err = perf_event__synthesize_kernel_mmap(process_synthesized_event,
session, machine, "_text");
if (err < 0)
err = event__synthesize_kernel_mmap(process_synthesized_event,
session, machine, "_stext");
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,
session, machine);
err = perf_event__synthesize_modules(process_synthesized_event,
session, 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"
"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,
session);
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;
Expand Down
Loading

0 comments on commit 8115d60

Please sign in to comment.