Skip to content

Commit

Permalink
perf tools: Remove repipe argument from perf_session__new()
Browse files Browse the repository at this point in the history
The repipe argument is only used by perf inject and the all others
passes 'false'.  Let's remove it from the function signature and add
__perf_session__new() to be called from perf inject directly.

This is a preparation of the change the pipe input/output.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20210719223153.1618812-2-namhyung@kernel.org
[ Fixed up some trivial conflicts as this patchset fell thru the cracks ;-( ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Namhyung Kim authored and Arnaldo Carvalho de Melo committed Aug 2, 2021
1 parent 8805692 commit 2681bd8
Show file tree
Hide file tree
Showing 25 changed files with 43 additions and 36 deletions.
4 changes: 2 additions & 2 deletions tools/perf/bench/synthesize.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static int run_single_threaded(void)
int err;

perf_set_singlethreaded();
session = perf_session__new(NULL, false, NULL);
session = perf_session__new(NULL, NULL);
if (IS_ERR(session)) {
pr_err("Session creation failed.\n");
return PTR_ERR(session);
Expand Down Expand Up @@ -161,7 +161,7 @@ static int do_run_multi_threaded(struct target *target,
init_stats(&time_stats);
init_stats(&event_stats);
for (i = 0; i < multi_iterations; i++) {
session = perf_session__new(NULL, false, NULL);
session = perf_session__new(NULL, NULL);
if (IS_ERR(session))
return PTR_ERR(session);

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ int cmd_annotate(int argc, const char **argv)

data.path = input_name;

annotate.session = perf_session__new(&data, false, &annotate.tool);
annotate.session = perf_session__new(&data, &annotate.tool);
if (IS_ERR(annotate.session))
return PTR_ERR(annotate.session);

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-buildid-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ int cmd_buildid_cache(int argc, const char **argv)
data.path = missing_filename;
data.force = force;

session = perf_session__new(&data, false, NULL);
session = perf_session__new(&data, NULL);
if (IS_ERR(session))
return PTR_ERR(session);
}
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 @@ -65,7 +65,7 @@ static int perf_session__list_build_ids(bool force, bool with_hits)
if (filename__fprintf_build_id(input_name, stdout) > 0)
goto out;

session = perf_session__new(&data, false, &build_id__mark_dso_hit_ops);
session = perf_session__new(&data, &build_id__mark_dso_hit_ops);
if (IS_ERR(session))
return PTR_ERR(session);

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-c2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -2790,7 +2790,7 @@ static int perf_c2c__report(int argc, const char **argv)
goto out;
}

session = perf_session__new(&data, 0, &c2c.tool);
session = perf_session__new(&data, &c2c.tool);
if (IS_ERR(session)) {
err = PTR_ERR(session);
pr_debug("Error creating perf session\n");
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ static int check_file_brstack(void)
int i;

data__for_each_file(i, d) {
d->session = perf_session__new(&d->data, false, &pdiff.tool);
d->session = perf_session__new(&d->data, &pdiff.tool);
if (IS_ERR(d->session)) {
pr_err("Failed to open %s\n", d->data.path);
return PTR_ERR(d->session);
Expand Down Expand Up @@ -1188,7 +1188,7 @@ static int __cmd_diff(void)
ret = -EINVAL;

data__for_each_file(i, d) {
d->session = perf_session__new(&d->data, false, &pdiff.tool);
d->session = perf_session__new(&d->data, &pdiff.tool);
if (IS_ERR(d->session)) {
ret = PTR_ERR(d->session);
pr_err("Failed to open %s\n", d->data.path);
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details
};
bool has_tracepoint = false;

session = perf_session__new(&data, 0, &tool);
session = perf_session__new(&data, &tool);
if (IS_ERR(session))
return PTR_ERR(session);

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ int cmd_inject(int argc, const char **argv)
}

data.path = inject.input_name;
inject.session = perf_session__new(&data, inject.output.is_pipe, &inject.tool);
inject.session = __perf_session__new(&data, inject.output.is_pipe, &inject.tool);
if (IS_ERR(inject.session)) {
ret = PTR_ERR(inject.session);
goto out_close_output;
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 @@ -1953,7 +1953,7 @@ int cmd_kmem(int argc, const char **argv)

data.path = input_name;

kmem_session = session = perf_session__new(&data, false, &perf_kmem);
kmem_session = session = perf_session__new(&data, &perf_kmem);
if (IS_ERR(session))
return PTR_ERR(session);

Expand Down
4 changes: 2 additions & 2 deletions tools/perf/builtin-kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ static int read_events(struct perf_kvm_stat *kvm)
};

kvm->tool = eops;
kvm->session = perf_session__new(&file, false, &kvm->tool);
kvm->session = perf_session__new(&file, &kvm->tool);
if (IS_ERR(kvm->session)) {
pr_err("Initializing perf session failed\n");
return PTR_ERR(kvm->session);
Expand Down Expand Up @@ -1447,7 +1447,7 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
/*
* perf session
*/
kvm->session = perf_session__new(&data, false, &kvm->tool);
kvm->session = perf_session__new(&data, &kvm->tool);
if (IS_ERR(kvm->session)) {
err = PTR_ERR(kvm->session);
goto out;
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 @@ -868,7 +868,7 @@ static int __cmd_report(bool display_info)
.force = force,
};

session = perf_session__new(&data, false, &eops);
session = perf_session__new(&data, &eops);
if (IS_ERR(session)) {
pr_err("Initializing perf session failed\n");
return PTR_ERR(session);
Expand Down
3 changes: 1 addition & 2 deletions tools/perf/builtin-mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,7 @@ static int report_raw_events(struct perf_mem *mem)
.force = mem->force,
};
int ret;
struct perf_session *session = perf_session__new(&data, false,
&mem->tool);
struct perf_session *session = perf_session__new(&data, &mem->tool);

if (IS_ERR(session))
return PTR_ERR(session);
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
signal(SIGUSR2, SIG_IGN);
}

session = perf_session__new(data, false, tool);
session = perf_session__new(data, tool);
if (IS_ERR(session)) {
pr_err("Perf session creation failed.\n");
return PTR_ERR(session);
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 @@ -1411,7 +1411,7 @@ int cmd_report(int argc, const char **argv)
data.force = symbol_conf.force;

repeat:
session = perf_session__new(&data, false, &report.tool);
session = perf_session__new(&data, &report.tool);
if (IS_ERR(session)) {
ret = PTR_ERR(session);
goto exit;
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/builtin-sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1804,7 +1804,7 @@ static int perf_sched__read_events(struct perf_sched *sched)
};
int rc = -1;

session = perf_session__new(&data, false, &sched->tool);
session = perf_session__new(&data, &sched->tool);
if (IS_ERR(session)) {
pr_debug("Error creating perf session");
return PTR_ERR(session);
Expand Down Expand Up @@ -3011,7 +3011,7 @@ static int perf_sched__timehist(struct perf_sched *sched)

symbol_conf.use_callchain = sched->show_callchain;

session = perf_session__new(&data, false, &sched->tool);
session = perf_session__new(&data, &sched->tool);
if (IS_ERR(session))
return PTR_ERR(session);

Expand Down
4 changes: 2 additions & 2 deletions tools/perf/builtin-script.c
Original file line number Diff line number Diff line change
Expand Up @@ -3294,7 +3294,7 @@ int find_scripts(char **scripts_array, char **scripts_path_array, int num,
char *temp;
int i = 0;

session = perf_session__new(&data, false, NULL);
session = perf_session__new(&data, NULL);
if (IS_ERR(session))
return PTR_ERR(session);

Expand Down Expand Up @@ -4007,7 +4007,7 @@ int cmd_script(int argc, const char **argv)
use_browser = 0;
}

session = perf_session__new(&data, false, &script.tool);
session = perf_session__new(&data, &script.tool);
if (IS_ERR(session))
return PTR_ERR(session);

Expand Down
4 changes: 2 additions & 2 deletions tools/perf/builtin-stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1996,7 +1996,7 @@ static int __cmd_record(int argc, const char **argv)
return -1;
}

session = perf_session__new(data, false, NULL);
session = perf_session__new(data, NULL);
if (IS_ERR(session)) {
pr_err("Perf session creation failed\n");
return PTR_ERR(session);
Expand Down Expand Up @@ -2168,7 +2168,7 @@ static int __cmd_report(int argc, const char **argv)
perf_stat.data.path = input_name;
perf_stat.data.mode = PERF_DATA_MODE_READ;

session = perf_session__new(&perf_stat.data, false, &perf_stat.tool);
session = perf_session__new(&perf_stat.data, &perf_stat.tool);
if (IS_ERR(session))
return PTR_ERR(session);

Expand Down
3 changes: 1 addition & 2 deletions tools/perf/builtin-timechart.c
Original file line number Diff line number Diff line change
Expand Up @@ -1598,8 +1598,7 @@ static int __cmd_timechart(struct timechart *tchart, const char *output_name)
.force = tchart->force,
};

struct perf_session *session = perf_session__new(&data, false,
&tchart->tool);
struct perf_session *session = perf_session__new(&data, &tchart->tool);
int ret = -EINVAL;

if (IS_ERR(session))
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,7 @@ int cmd_top(int argc, const char **argv)
signal(SIGWINCH, winch_sig);
}

top.session = perf_session__new(NULL, false, NULL);
top.session = perf_session__new(NULL, NULL);
if (IS_ERR(top.session)) {
status = PTR_ERR(top.session);
goto out_delete_evlist;
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 @@ -4236,7 +4236,7 @@ static int trace__replay(struct trace *trace)
/* add tid to output */
trace->multiple_threads = true;

session = perf_session__new(&data, false, &trace->tool);
session = perf_session__new(&data, &trace->tool);
if (IS_ERR(session))
return PTR_ERR(session);

Expand Down
4 changes: 2 additions & 2 deletions tools/perf/tests/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static int session_write_header(char *path)
.mode = PERF_DATA_MODE_WRITE,
};

session = perf_session__new(&data, false, NULL);
session = perf_session__new(&data, NULL);
TEST_ASSERT_VAL("can't get session", !IS_ERR(session));

if (!perf_pmu__has_hybrid()) {
Expand Down Expand Up @@ -77,7 +77,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)
int i;
struct aggr_cpu_id id;

session = perf_session__new(&data, false, NULL);
session = perf_session__new(&data, NULL);
TEST_ASSERT_VAL("can't get session", !IS_ERR(session));
cpu__setup_cpunode_map();

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/data-convert-bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ int bt_convert__perf2ctf(const char *input, const char *path,

err = -1;
/* perf.data session */
session = perf_session__new(&data, 0, &c.tool);
session = perf_session__new(&data, &c.tool);
if (IS_ERR(session))
return PTR_ERR(session);

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/data-convert-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ int bt_convert__perf2json(const char *input_name, const char *output_name,
goto err;
}

session = perf_session__new(&data, false, &c.tool);
session = perf_session__new(&data, &c.tool);
if (IS_ERR(session)) {
fprintf(stderr, "Error creating perf session!\n");
goto err_fclose;
Expand Down
5 changes: 3 additions & 2 deletions tools/perf/util/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ static int ordered_events__deliver_event(struct ordered_events *oe,
session->tool, event->file_offset);
}

struct perf_session *perf_session__new(struct perf_data *data,
bool repipe, struct perf_tool *tool)
struct perf_session *__perf_session__new(struct perf_data *data,
bool repipe,
struct perf_tool *tool)
{
int ret = -ENOMEM;
struct perf_session *session = zalloc(sizeof(*session));
Expand Down
12 changes: 10 additions & 2 deletions tools/perf/util/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,16 @@ struct decomp {

struct perf_tool;

struct perf_session *perf_session__new(struct perf_data *data,
bool repipe, struct perf_tool *tool);
struct perf_session *__perf_session__new(struct perf_data *data,
bool repipe,
struct perf_tool *tool);

static inline struct perf_session *perf_session__new(struct perf_data *data,
struct perf_tool *tool)
{
return __perf_session__new(data, false, tool);
}

void perf_session__delete(struct perf_session *session);

void perf_event_header__bswap(struct perf_event_header *hdr);
Expand Down

0 comments on commit 2681bd8

Please sign in to comment.