Commit 73bdc7159b0a83146fa8d1b8df7baf1cea992d4c
1 parent
c75d98afa7
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
perf timechart: Don't use globals where not needed to
Some variables were global but used in just one function, so move it to where it belongs. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-fapdrw3h3hz713w8h5eww596@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Showing 1 changed file with 41 additions and 59 deletions Side-by-side Diff
tools/perf/builtin-timechart.c
... | ... | @@ -38,9 +38,6 @@ |
38 | 38 | #define PWR_EVENT_EXIT -1 |
39 | 39 | |
40 | 40 | |
41 | -static const char *input_name; | |
42 | -static const char *output_name = "output.svg"; | |
43 | - | |
44 | 41 | static unsigned int numcpus; |
45 | 42 | static u64 min_freq; /* Lowest CPU frequency seen */ |
46 | 43 | static u64 max_freq; /* Highest CPU frequency seen */ |
47 | 44 | |
... | ... | @@ -968,16 +965,15 @@ |
968 | 965 | svg_close(); |
969 | 966 | } |
970 | 967 | |
971 | -static struct perf_tool perf_timechart = { | |
972 | - .comm = process_comm_event, | |
973 | - .fork = process_fork_event, | |
974 | - .exit = process_exit_event, | |
975 | - .sample = process_sample_event, | |
976 | - .ordered_samples = true, | |
977 | -}; | |
978 | - | |
979 | -static int __cmd_timechart(void) | |
968 | +static int __cmd_timechart(const char *input_name, const char *output_name) | |
980 | 969 | { |
970 | + struct perf_tool perf_timechart = { | |
971 | + .comm = process_comm_event, | |
972 | + .fork = process_fork_event, | |
973 | + .exit = process_exit_event, | |
974 | + .sample = process_sample_event, | |
975 | + .ordered_samples = true, | |
976 | + }; | |
981 | 977 | struct perf_session *session = perf_session__new(input_name, O_RDONLY, |
982 | 978 | 0, false, &perf_timechart); |
983 | 979 | int ret = -EINVAL; |
984 | 980 | |
... | ... | @@ -1005,40 +1001,25 @@ |
1005 | 1001 | return ret; |
1006 | 1002 | } |
1007 | 1003 | |
1008 | -static const char * const timechart_usage[] = { | |
1009 | - "perf timechart [<options>] {record}", | |
1010 | - NULL | |
1011 | -}; | |
1012 | - | |
1013 | -#ifdef SUPPORT_OLD_POWER_EVENTS | |
1014 | -static const char * const record_old_args[] = { | |
1015 | - "record", | |
1016 | - "-a", | |
1017 | - "-R", | |
1018 | - "-f", | |
1019 | - "-c", "1", | |
1020 | - "-e", "power:power_start", | |
1021 | - "-e", "power:power_end", | |
1022 | - "-e", "power:power_frequency", | |
1023 | - "-e", "sched:sched_wakeup", | |
1024 | - "-e", "sched:sched_switch", | |
1025 | -}; | |
1026 | -#endif | |
1027 | - | |
1028 | -static const char * const record_new_args[] = { | |
1029 | - "record", | |
1030 | - "-a", | |
1031 | - "-R", | |
1032 | - "-f", | |
1033 | - "-c", "1", | |
1034 | - "-e", "power:cpu_frequency", | |
1035 | - "-e", "power:cpu_idle", | |
1036 | - "-e", "sched:sched_wakeup", | |
1037 | - "-e", "sched:sched_switch", | |
1038 | -}; | |
1039 | - | |
1040 | 1004 | static int __cmd_record(int argc, const char **argv) |
1041 | 1005 | { |
1006 | +#ifdef SUPPORT_OLD_POWER_EVENTS | |
1007 | + const char * const record_old_args[] = { | |
1008 | + "record", "-a", "-R", "-f", "-c", "1", | |
1009 | + "-e", "power:power_start", | |
1010 | + "-e", "power:power_end", | |
1011 | + "-e", "power:power_frequency", | |
1012 | + "-e", "sched:sched_wakeup", | |
1013 | + "-e", "sched:sched_switch", | |
1014 | + }; | |
1015 | +#endif | |
1016 | + const char * const record_new_args[] = { | |
1017 | + "record", "-a", "-R", "-f", "-c", "1", | |
1018 | + "-e", "power:cpu_frequency", | |
1019 | + "-e", "power:cpu_idle", | |
1020 | + "-e", "sched:sched_wakeup", | |
1021 | + "-e", "sched:sched_switch", | |
1022 | + }; | |
1042 | 1023 | unsigned int rec_argc, i, j; |
1043 | 1024 | const char **rec_argv; |
1044 | 1025 | const char * const *record_args = record_new_args; |
1045 | 1026 | |
1046 | 1027 | |
... | ... | @@ -1077,27 +1058,28 @@ |
1077 | 1058 | return 0; |
1078 | 1059 | } |
1079 | 1060 | |
1080 | -static const struct option options[] = { | |
1081 | - OPT_STRING('i', "input", &input_name, "file", | |
1082 | - "input file name"), | |
1083 | - OPT_STRING('o', "output", &output_name, "file", | |
1084 | - "output file name"), | |
1085 | - OPT_INTEGER('w', "width", &svg_page_width, | |
1086 | - "page width"), | |
1087 | - OPT_BOOLEAN('P', "power-only", &power_only, | |
1088 | - "output power data only"), | |
1061 | +int cmd_timechart(int argc, const char **argv, | |
1062 | + const char *prefix __maybe_unused) | |
1063 | +{ | |
1064 | + const char *input_name; | |
1065 | + const char *output_name = "output.svg"; | |
1066 | + const struct option options[] = { | |
1067 | + OPT_STRING('i', "input", &input_name, "file", "input file name"), | |
1068 | + OPT_STRING('o', "output", &output_name, "file", "output file name"), | |
1069 | + OPT_INTEGER('w', "width", &svg_page_width, "page width"), | |
1070 | + OPT_BOOLEAN('P', "power-only", &power_only, "output power data only"), | |
1089 | 1071 | OPT_CALLBACK('p', "process", NULL, "process", |
1090 | 1072 | "process selector. Pass a pid or process name.", |
1091 | 1073 | parse_process), |
1092 | 1074 | OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", |
1093 | 1075 | "Look for files with symbols relative to this directory"), |
1094 | 1076 | OPT_END() |
1095 | -}; | |
1077 | + }; | |
1078 | + const char * const timechart_usage[] = { | |
1079 | + "perf timechart [<options>] {record}", | |
1080 | + NULL | |
1081 | + }; | |
1096 | 1082 | |
1097 | - | |
1098 | -int cmd_timechart(int argc, const char **argv, | |
1099 | - const char *prefix __maybe_unused) | |
1100 | -{ | |
1101 | 1083 | argc = parse_options(argc, argv, options, timechart_usage, |
1102 | 1084 | PARSE_OPT_STOP_AT_NON_OPTION); |
1103 | 1085 | |
... | ... | @@ -1110,6 +1092,6 @@ |
1110 | 1092 | |
1111 | 1093 | setup_pager(); |
1112 | 1094 | |
1113 | - return __cmd_timechart(); | |
1095 | + return __cmd_timechart(input_name, output_name); | |
1114 | 1096 | } |