struct perf_annotate {
        struct perf_tool tool;
-       char const *input_name;
        bool       force, use_tui, use_stdio;
        bool       full_paths;
        bool       print_line;
        struct perf_evsel *pos;
        u64 total_nr_samples;
 
-       session = perf_session__new(ann->input_name, O_RDONLY,
+       session = perf_session__new(input_name, O_RDONLY,
                                    ann->force, false, &ann->tool);
        if (session == NULL)
                return -ENOMEM;
                },
        };
        const struct option options[] = {
-       OPT_STRING('i', "input", &annotate.input_name, "file",
+       OPT_STRING('i', "input", &input_name, "file",
                    "input file name"),
        OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
                   "only consider symbols in these dsos"),
 
        return fprintf(fp, "%s\n", sbuild_id);
 }
 
-static int perf_session__list_build_ids(const char *input_name,
-                                       bool force, bool with_hits)
+static int perf_session__list_build_ids(bool force, bool with_hits)
 {
        struct perf_session *session;
 
        bool show_kernel = false;
        bool with_hits = false;
        bool force = false;
-       const char *input_name = NULL;
        const struct option options[] = {
        OPT_BOOLEAN('H', "with-hits", &with_hits, "Show only DSOs with hits"),
        OPT_STRING('i', "input", &input_name, "file", "input file name"),
        if (show_kernel)
                return sysfs__fprintf_build_id(stdout);
 
-       return perf_session__list_build_ids(input_name, force, with_hits);
+       return perf_session__list_build_ids(force, with_hits);
 }
 
 
 #define if_print(field) __if_print(&first, #field, pos->attr.field)
 
-static int __cmd_evlist(const char *input_name, struct perf_attr_details *details)
+static int __cmd_evlist(const char *file_name, struct perf_attr_details *details)
 {
        struct perf_session *session;
        struct perf_evsel *pos;
 
-       session = perf_session__new(input_name, O_RDONLY, 0, false, NULL);
+       session = perf_session__new(file_name, O_RDONLY, 0, false, NULL);
        if (session == NULL)
                return -ENOMEM;
 
 int cmd_evlist(int argc, const char **argv, const char *prefix __maybe_unused)
 {
        struct perf_attr_details details = { .verbose = false, };
-       const char *input_name = NULL;
        const struct option options[] = {
        OPT_STRING('i', "input", &input_name, "file", "Input file name"),
        OPT_BOOLEAN('F', "freq", &details.freq, "Show the sample frequency"),
 
        __sort_result(&root_caller_stat, &root_caller_sorted, &caller_sort);
 }
 
-static int __cmd_kmem(const char *input_name)
+static int __cmd_kmem(void)
 {
        int err = -EINVAL;
        struct perf_session *session;
 int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
 {
        const char * const default_sort_order = "frag,hit,bytes";
-       const char *input_name = NULL;
        const struct option kmem_options[] = {
        OPT_STRING('i', "input", &input_name, "file", "input file name"),
        OPT_CALLBACK_NOOPT(0, "caller", NULL, NULL,
                if (list_empty(&alloc_sort))
                        setup_sorting(&alloc_sort, default_sort_order);
 
-               return __cmd_kmem(input_name);
+               return __cmd_kmem();
        } else
                usage_with_options(kmem_usage, kmem_options);
 
 
        return NULL;
 }
 
-static const char *input_name;
-
 struct trace_lock_handler {
        int (*acquire_event)(struct perf_evsel *evsel,
                             struct perf_sample *sample);
 
 struct perf_report {
        struct perf_tool        tool;
        struct perf_session     *session;
-       char const              *input_name;
        bool                    force, use_tui, use_gtk, use_stdio;
        bool                    hide_unresolved;
        bool                    dont_use_callchains;
                .pretty_printing_style   = "normal",
        };
        const struct option options[] = {
-       OPT_STRING('i', "input", &report.input_name, "file",
+       OPT_STRING('i', "input", &input_name, "file",
                    "input file name"),
        OPT_INCR('v', "verbose", &verbose,
                    "be more verbose (show symbol address, etc)"),
        if (report.inverted_callchain)
                callchain_param.order = ORDER_CALLER;
 
-       if (!report.input_name || !strlen(report.input_name)) {
+       if (!input_name || !strlen(input_name)) {
                if (!fstat(STDIN_FILENO, &st) && S_ISFIFO(st.st_mode))
-                       report.input_name = "-";
+                       input_name = "-";
                else
-                       report.input_name = "perf.data";
+                       input_name = "perf.data";
        }
-       session = perf_session__new(report.input_name, O_RDONLY,
+       session = perf_session__new(input_name, O_RDONLY,
                                    report.force, false, &report.tool);
        if (session == NULL)
                return -ENOMEM;
 
        }
 
-       if (strcmp(report.input_name, "-") != 0)
+       if (strcmp(input_name, "-") != 0)
                setup_browser(true);
        else {
                use_browser = 0;
 
 
 struct perf_sched {
        struct perf_tool tool;
-       const char       *input_name;
        const char       *sort_order;
        unsigned long    nr_tasks;
        struct task_desc *pid_to_task[MAX_PID];
        };
        struct perf_session *session;
 
-       session = perf_session__new(sched->input_name, O_RDONLY, 0, false, &sched->tool);
+       session = perf_session__new(input_name, O_RDONLY, 0, false, &sched->tool);
        if (session == NULL) {
                pr_debug("No Memory for session\n");
                return -1;
        OPT_END()
        };
        const struct option sched_options[] = {
-       OPT_STRING('i', "input", &sched.input_name, "file",
+       OPT_STRING('i', "input", &input_name, "file",
                    "input file name"),
        OPT_INCR('v', "verbose", &verbose,
                    "be more verbose (show symbol address, etc)"),
 
 int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
 {
        bool show_full_info = false;
-       const char *input_name = NULL;
        char *rec_script_path = NULL;
        char *rep_script_path = NULL;
        struct perf_session *session;
 
        svg_close();
 }
 
-static int __cmd_timechart(const char *input_name, const char *output_name)
+static int __cmd_timechart(const char *output_name)
 {
        struct perf_tool perf_timechart = {
                .comm            = process_comm_event,
 int cmd_timechart(int argc, const char **argv,
                  const char *prefix __maybe_unused)
 {
-       const char *input_name;
        const char *output_name = "output.svg";
        const struct option options[] = {
        OPT_STRING('i', "input", &input_name, "file", "input file name"),
 
        setup_pager();
 
-       return __cmd_timechart(input_name, output_name);
+       return __cmd_timechart(output_name);
 }
 
 
 int use_browser = -1;
 static int use_pager = -1;
+const char *input_name;
 
 struct cmd_struct {
        const char *cmd;
 
        struct branch_entry     entries[0];
 };
 
+extern const char *input_name;
 extern bool perf_host, perf_guest;
 extern const char perf_version_string[];