perf tools: Remove repipe argument from perf_session__new()
authorNamhyung Kim <namhyung@kernel.org>
Mon, 19 Jul 2021 22:31:49 +0000 (15:31 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 2 Aug 2021 13:06:51 +0000 (10:06 -0300)
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>
25 files changed:
tools/perf/bench/synthesize.c
tools/perf/builtin-annotate.c
tools/perf/builtin-buildid-cache.c
tools/perf/builtin-buildid-list.c
tools/perf/builtin-c2c.c
tools/perf/builtin-diff.c
tools/perf/builtin-evlist.c
tools/perf/builtin-inject.c
tools/perf/builtin-kmem.c
tools/perf/builtin-kvm.c
tools/perf/builtin-lock.c
tools/perf/builtin-mem.c
tools/perf/builtin-record.c
tools/perf/builtin-report.c
tools/perf/builtin-sched.c
tools/perf/builtin-script.c
tools/perf/builtin-stat.c
tools/perf/builtin-timechart.c
tools/perf/builtin-top.c
tools/perf/builtin-trace.c
tools/perf/tests/topology.c
tools/perf/util/data-convert-bt.c
tools/perf/util/data-convert-json.c
tools/perf/util/session.c
tools/perf/util/session.h

index b2924e3181dc3844fa14002463ea4579f5c32e4d..05f7c923c745b4e8d2acca73c4c50e0cc7be8ae3 100644 (file)
@@ -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);
@@ -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);
 
index cebb861be3e3c8f8ebf845ea665a15206e35a7b6..05eb098cb0e3bc2f5958cb0bc5b54f18093470af 100644 (file)
@@ -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);
 
index ecd0d3cb6f5c6f1dda1a93109ff11cc99e4208b5..0db3cfc04c47864fac89158025bedad3e4c34dff 100644 (file)
@@ -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);
        }
index 833405c27dae2abd66324422a54cb8f6fa0a88f3..cebadd63223453bb32b344143278ce6d3d89c259 100644 (file)
@@ -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);
 
index 6dea37f141b2565166efb516b4a8d4235b3264a7..a812f32cf5d952ec769082a11044e44ab61d9a66 100644 (file)
@@ -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");
index 80450c0e8f36976e43b1a99549e32e1d6ce781d5..d925096dd7f02120fdc18474dcc9dc98298f1665 100644 (file)
@@ -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);
@@ -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);
index 4617b32c9c978df5fca8c3ed93bf36a670bef9bc..b1076177c37ff440db9b82e94e7caf682402879b 100644 (file)
@@ -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);
 
index c88c61e7f8ccb6a7c3d48d4f501ef2ad55ca5306..ecad56357134c1aa40e73f92f6fab4df76de1657 100644 (file)
@@ -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;
index 0062445e8ead8bce19afd386c2d8b143051786ad..da03a341c63c8775b56ba3090f84af9bfe9e142b 100644 (file)
@@ -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);
 
index 1105c9e40a80f7f688d22a85986cec8ebc3a6656..aa1b127ffb5be047a882bb88c3d2eed233987101 100644 (file)
@@ -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);
@@ -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;
index 01326e3700099d632ed601a9a58f323cc872a3ad..d70131b7b1b1e3411894fa1f3803d6d5774cd531 100644 (file)
@@ -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);
index 0fd2a74dbacaa378883c63c0ae43ac197b713dd3..fcf65a59bea214ced6f60f18e6a68bfa37752b45 100644 (file)
@@ -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);
index 671a21c9ee4d7a5375bd433467dee1f0c813fe15..472cd12f10c6ba38a8dd109b7a8eab1dee2d2e3c 100644 (file)
@@ -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);
index dc0364f671b97d26f6f599d0e1026918511f6718..a0316ce910db61d83afe7f072d77c86e2ab8a6ea 100644 (file)
@@ -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;
index 1ff10d4bccf3ccebdbca287d4a43956b515bc9f7..635a6b5a9ec972d30ce1dae925bd27b05cad7f84 100644 (file)
@@ -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);
@@ -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);
 
index 064da7f3618d39d8bbd25c80a21f55c7d4243106..e2e165b53499dc35650d6c5bf51d6a2ef2cfefe3 100644 (file)
@@ -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);
 
@@ -4007,7 +4007,7 @@ script_found:
                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);
 
index 634375937db9632ed7cfcadb0c83c715cd656870..84de61795e67bbb982fcbc2f2e6c28fffe9e838c 100644 (file)
@@ -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);
@@ -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);
 
index 4e380e7b5230726493c6f6d0a4c0d4808ff20e43..43bf4d67edb0933ca3b3459042ee2980e04adc18 100644 (file)
@@ -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))
index 02f8bb5dbc0f078736bf54d465484531283894ed..a3ae9176a83e24532a7b5018535b17298a43da08 100644 (file)
@@ -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;
index 8f3582eb52543e4c1d760792d45435db21d7fad2..2bf21194c7b3959e4402d1173b34847432eef1b9 100644 (file)
@@ -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);
 
index b5efe675b321746e978ae56453390cde85e5f607..b9028e304ddd3c02d9b886aa2e77084d60ecff6d 100644 (file)
@@ -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()) {
@@ -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();
 
index cace349fb70015843b28bcd82ecb31beb507a248..aa862a26d95c435912587e546a8a83e0f213ed6c 100644 (file)
@@ -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);
 
index 355cd1948bdf006a37f3e18b93c09b9afad6a0a1..f1ab6edba446bb6159971abefc8f78379b309e10 100644 (file)
@@ -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;
index 51f72740291267c5409208bd0c8ba05578534ae1..073c731f8a1ace5b6c89e360d40b524fc5d13ad9 100644 (file)
@@ -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));
index e31ba4c92a6cf32c4e16f7ad6f959422f4eb332e..9d19d2a918c690fbe3b9e4a78cdebbe4460d6ca6 100644 (file)
@@ -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);