Skip to content

Commit

Permalink
perf ordered_events: Shorten function signatures
Browse files Browse the repository at this point in the history
By keeping pointers to machines, evlist and tool in ordered_events.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-0c6huyaf59mqtm2ek9pmposl@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
acmel committed Mar 11, 2015
1 parent fa713a4 commit b7b61cb
Show file tree
Hide file tree
Showing 19 changed files with 68 additions and 83 deletions.
2 changes: 1 addition & 1 deletion tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
goto out;
}

ret = perf_session__process_events(session, &ann->tool);
ret = perf_session__process_events(session);
if (ret)
goto out;

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-buildid-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static int perf_session__list_build_ids(bool force, bool with_hits)
* the record stream. Buildids are stored as RECORD_HEADER_BUILD_ID
*/
if (with_hits || perf_data_file__is_pipe(&file))
perf_session__process_events(session, &build_id__mark_dso_hit_ops);
perf_session__process_events(session);

perf_session__fprintf_dsos_buildid(session, stdout, dso__skip_buildid, with_hits);
perf_session__delete(session);
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ static int __cmd_diff(void)
goto out_delete;
}

ret = perf_session__process_events(d->session, &tool);
ret = perf_session__process_events(d->session);
if (ret) {
pr_err("Failed to process %s\n", d->file.path);
goto out_delete;
Expand Down
6 changes: 3 additions & 3 deletions tools/perf/builtin-inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,6 @@ static int __cmd_inject(struct perf_inject *inject)
} else if (inject->sched_stat) {
struct perf_evsel *evsel;

inject->tool.ordered_events = true;

evlist__for_each(session->evlist, evsel) {
const char *name = perf_evsel__name(evsel);

Expand All @@ -379,7 +377,7 @@ static int __cmd_inject(struct perf_inject *inject)
if (!file_out->is_pipe)
lseek(fd, session->header.data_offset, SEEK_SET);

ret = perf_session__process_events(session, &inject->tool);
ret = perf_session__process_events(session);

if (!file_out->is_pipe) {
if (inject->build_ids)
Expand Down Expand Up @@ -458,6 +456,8 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused)
return -1;
}

inject.tool.ordered_events = inject.sched_stat;

file.path = inject.input_name;
inject.session = perf_session__new(&file, true, &inject.tool);
if (inject.session == NULL)
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ static int __cmd_kmem(struct perf_session *session)
}

setup_pager();
err = perf_session__process_events(session, &perf_kmem);
err = perf_session__process_events(session);
if (err != 0)
goto out;
sort_result();
Expand Down
6 changes: 3 additions & 3 deletions tools/perf/builtin-kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,9 +730,9 @@ static s64 perf_kvm__mmap_read_idx(struct perf_kvm_stat *kvm, int idx,
return -1;
}

err = perf_session_queue_event(kvm->session, event, &kvm->tool, &sample, 0);
err = perf_session__queue_event(kvm->session, event, &sample, 0);
/*
* FIXME: Here we can't consume the event, as perf_session_queue_event will
* FIXME: Here we can't consume the event, as perf_session__queue_event will
* point to it, and it'll get possibly overwritten by the kernel.
*/
perf_evlist__mmap_consume(kvm->evlist, idx);
Expand Down Expand Up @@ -1066,7 +1066,7 @@ static int read_events(struct perf_kvm_stat *kvm)
if (ret < 0)
return ret;

return perf_session__process_events(kvm->session, &kvm->tool);
return perf_session__process_events(kvm->session);
}

static int parse_target_str(struct perf_kvm_stat *kvm)
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ static int __cmd_report(bool display_info)
if (select_key())
goto out_delete;

err = perf_session__process_events(session, &eops);
err = perf_session__process_events(session);
if (err)
goto out_delete;

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static int report_raw_events(struct perf_mem *mem)

printf("# PID, TID, IP, ADDR, LOCAL WEIGHT, DSRC, SYMBOL\n");

err = perf_session__process_events(session, &mem->tool);
err = perf_session__process_events(session);
if (err)
return err;

Expand Down
4 changes: 2 additions & 2 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ static int process_buildids(struct record *rec)
*/
symbol_conf.ignore_vmlinux_buildid = true;

return perf_session__process_events(session, &rec->tool);
return perf_session__process_events(session);
}

static void perf_event__synthesize_guest_os(struct machine *machine, void *data)
Expand Down Expand Up @@ -343,7 +343,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler);

session = perf_session__new(file, false, NULL);
session = perf_session__new(file, false, tool);
if (session == NULL) {
pr_err("Perf session creation failed.\n");
return -1;
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ static int __cmd_report(struct report *rep)
if (ret)
return ret;

ret = perf_session__process_events(session, &rep->tool);
ret = perf_session__process_events(session);
if (ret)
return ret;

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ static int perf_sched__read_events(struct perf_sched *sched)
goto out_delete;

if (perf_session__has_traces(session, "record -R")) {
int err = perf_session__process_events(session, &sched->tool);
int err = perf_session__process_events(session);
if (err) {
pr_err("Failed to process events, error %d", err);
goto out_delete;
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-script.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ static int __cmd_script(struct perf_script *script)
script->tool.mmap2 = process_mmap2_event;
}

ret = perf_session__process_events(script->session, &script->tool);
ret = perf_session__process_events(script->session);

if (debug_mode)
pr_err("Misordered timestamps: %" PRIu64 "\n", nr_unordered);
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-timechart.c
Original file line number Diff line number Diff line change
Expand Up @@ -1623,7 +1623,7 @@ static int __cmd_timechart(struct timechart *tchart, const char *output_name)
goto out_delete;
}

ret = perf_session__process_events(session, &tchart->tool);
ret = perf_session__process_events(session);
if (ret)
goto out_delete;

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -2408,7 +2408,7 @@ static int trace__replay(struct trace *trace)

setup_pager();

err = perf_session__process_events(session, &trace->tool);
err = perf_session__process_events(session);
if (err)
pr_err("Failed to process events, error %d", err);

Expand Down
4 changes: 2 additions & 2 deletions tools/perf/util/data-convert-bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ int bt_convert__perf2ctf(const char *input, const char *path)
return -1;

/* perf.data session */
session = perf_session__new(&file, 0, NULL);
session = perf_session__new(&file, 0, &c.tool);
if (!session)
goto free_writer;

Expand All @@ -591,7 +591,7 @@ int bt_convert__perf2ctf(const char *input, const char *path)
if (setup_events(cw, session))
goto free_session;

err = perf_session__process_events(session, &c.tool);
err = perf_session__process_events(session);
if (!err)
err = bt_ctf_stream_flush(cw->stream);

Expand Down
23 changes: 11 additions & 12 deletions tools/perf/util/ordered-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,7 @@ void ordered_events__delete(struct ordered_events *oe, struct ordered_event *eve
free_dup_event(oe, event->event);
}

static int __ordered_events__flush(struct ordered_events *oe,
struct machines *machines,
struct perf_evlist *evlist,
struct perf_tool *tool)
static int __ordered_events__flush(struct ordered_events *oe)
{
struct list_head *head = &oe->events;
struct ordered_event *tmp, *iter;
Expand All @@ -180,12 +177,12 @@ static int __ordered_events__flush(struct ordered_events *oe,
if (iter->timestamp > limit)
break;

ret = perf_evlist__parse_sample(evlist, iter->event, &sample);
ret = perf_evlist__parse_sample(oe->evlist, iter->event, &sample);
if (ret)
pr_err("Can't parse sample, err = %d\n", ret);
else {
ret = machines__deliver_event(machines, evlist, iter->event,
&sample, tool, iter->file_offset);
ret = machines__deliver_event(oe->machines, oe->evlist, iter->event,
&sample, oe->tool, iter->file_offset);
if (ret)
return ret;
}
Expand All @@ -205,9 +202,7 @@ static int __ordered_events__flush(struct ordered_events *oe,
return 0;
}

int ordered_events__flush(struct ordered_events *oe, struct machines *machines,
struct perf_evlist *evlist, struct perf_tool *tool,
enum oe_flush how)
int ordered_events__flush(struct ordered_events *oe, enum oe_flush how)
{
static const char * const str[] = {
"NONE",
Expand Down Expand Up @@ -252,7 +247,7 @@ int ordered_events__flush(struct ordered_events *oe, struct machines *machines,
str[how], oe->nr_events);
pr_oe_time(oe->max_timestamp, "max_timestamp\n");

err = __ordered_events__flush(oe, machines, evlist, tool);
err = __ordered_events__flush(oe);

if (!err) {
if (how == OE_FLUSH__ROUND)
Expand All @@ -268,13 +263,17 @@ int ordered_events__flush(struct ordered_events *oe, struct machines *machines,
return err;
}

void ordered_events__init(struct ordered_events *oe)
void ordered_events__init(struct ordered_events *oe, struct machines *machines,
struct perf_evlist *evlist, struct perf_tool *tool)
{
INIT_LIST_HEAD(&oe->events);
INIT_LIST_HEAD(&oe->cache);
INIT_LIST_HEAD(&oe->to_free);
oe->max_alloc_size = (u64) -1;
oe->cur_alloc_size = 0;
oe->evlist = evlist;
oe->machines = machines;
oe->tool = tool;
}

void ordered_events__free(struct ordered_events *oe)
Expand Down
10 changes: 6 additions & 4 deletions tools/perf/util/ordered-events.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ struct ordered_events {
struct list_head to_free;
struct ordered_event *buffer;
struct ordered_event *last;
struct machines *machines;
struct perf_evlist *evlist;
struct perf_tool *tool;
int buffer_idx;
unsigned int nr_events;
enum oe_flush last_flush_type;
Expand All @@ -41,10 +44,9 @@ struct ordered_events {
struct ordered_event *ordered_events__new(struct ordered_events *oe, u64 timestamp,
union perf_event *event);
void ordered_events__delete(struct ordered_events *oe, struct ordered_event *event);
int ordered_events__flush(struct ordered_events *oe, struct machines *machines,
struct perf_evlist *evlist, struct perf_tool *tool,
enum oe_flush how);
void ordered_events__init(struct ordered_events *oe);
int ordered_events__flush(struct ordered_events *oe, enum oe_flush how);
void ordered_events__init(struct ordered_events *oe, struct machines *machines,
struct perf_evlist *evlsit, struct perf_tool *tool);
void ordered_events__free(struct ordered_events *oe);

static inline
Expand Down
Loading

0 comments on commit b7b61cb

Please sign in to comment.