diff options
| author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-10-01 14:20:58 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-10-02 17:36:33 -0400 |
| commit | c75d98afa7bb059169587b838e0a25436b8d3e62 (patch) | |
| tree | b1751eb14ad6afa74b0eccd65bc20854f71397f9 /tools/perf | |
| parent | 0433ffbe47d66c5c561b54340ee47adf8826bcc4 (diff) | |
perf lock: 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-fx8sqc6r9u0i1u97ruy5ytjv@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
| -rw-r--r-- | tools/perf/builtin-lock.c | 90 |
1 files changed, 39 insertions, 51 deletions
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 7d6e09949880..6f5f328157aa 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c | |||
| @@ -823,12 +823,6 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused, | |||
| 823 | return 0; | 823 | return 0; |
| 824 | } | 824 | } |
| 825 | 825 | ||
| 826 | static struct perf_tool eops = { | ||
| 827 | .sample = process_sample_event, | ||
| 828 | .comm = perf_event__process_comm, | ||
| 829 | .ordered_samples = true, | ||
| 830 | }; | ||
| 831 | |||
| 832 | static const struct perf_evsel_str_handler lock_tracepoints[] = { | 826 | static const struct perf_evsel_str_handler lock_tracepoints[] = { |
| 833 | { "lock:lock_acquire", perf_evsel__process_lock_acquire, }, /* CONFIG_LOCKDEP */ | 827 | { "lock:lock_acquire", perf_evsel__process_lock_acquire, }, /* CONFIG_LOCKDEP */ |
| 834 | { "lock:lock_acquired", perf_evsel__process_lock_acquired, }, /* CONFIG_LOCKDEP, CONFIG_LOCK_STAT */ | 828 | { "lock:lock_acquired", perf_evsel__process_lock_acquired, }, /* CONFIG_LOCKDEP, CONFIG_LOCK_STAT */ |
| @@ -838,6 +832,11 @@ static const struct perf_evsel_str_handler lock_tracepoints[] = { | |||
| 838 | 832 | ||
| 839 | static int read_events(void) | 833 | static int read_events(void) |
| 840 | { | 834 | { |
| 835 | struct perf_tool eops = { | ||
| 836 | .sample = process_sample_event, | ||
| 837 | .comm = perf_event__process_comm, | ||
| 838 | .ordered_samples = true, | ||
| 839 | }; | ||
| 841 | session = perf_session__new(input_name, O_RDONLY, 0, false, &eops); | 840 | session = perf_session__new(input_name, O_RDONLY, 0, false, &eops); |
| 842 | if (!session) { | 841 | if (!session) { |
| 843 | pr_err("Initializing perf session failed\n"); | 842 | pr_err("Initializing perf session failed\n"); |
| @@ -878,53 +877,11 @@ static int __cmd_report(void) | |||
| 878 | return 0; | 877 | return 0; |
| 879 | } | 878 | } |
| 880 | 879 | ||
| 881 | static const char * const report_usage[] = { | ||
| 882 | "perf lock report [<options>]", | ||
| 883 | NULL | ||
| 884 | }; | ||
| 885 | |||
| 886 | static const struct option report_options[] = { | ||
| 887 | OPT_STRING('k', "key", &sort_key, "acquired", | ||
| 888 | "key for sorting (acquired / contended / wait_total / wait_max / wait_min)"), | ||
| 889 | /* TODO: type */ | ||
| 890 | OPT_END() | ||
| 891 | }; | ||
| 892 | |||
| 893 | static const char * const info_usage[] = { | ||
| 894 | "perf lock info [<options>]", | ||
| 895 | NULL | ||
| 896 | }; | ||
| 897 | |||
| 898 | static const struct option info_options[] = { | ||
| 899 | OPT_BOOLEAN('t', "threads", &info_threads, | ||
| 900 | "dump thread list in perf.data"), | ||
| 901 | OPT_BOOLEAN('m', "map", &info_map, | ||
| 902 | "map of lock instances (address:name table)"), | ||
| 903 | OPT_END() | ||
| 904 | }; | ||
| 905 | |||
| 906 | static const char * const lock_usage[] = { | ||
| 907 | "perf lock [<options>] {record|report|script|info}", | ||
| 908 | NULL | ||
| 909 | }; | ||
| 910 | |||
| 911 | static const struct option lock_options[] = { | ||
| 912 | OPT_STRING('i', "input", &input_name, "file", "input file name"), | ||
| 913 | OPT_INCR('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"), | ||
| 914 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"), | ||
| 915 | OPT_END() | ||
| 916 | }; | ||
| 917 | |||
| 918 | static const char *record_args[] = { | ||
| 919 | "record", | ||
| 920 | "-R", | ||
| 921 | "-f", | ||
| 922 | "-m", "1024", | ||
| 923 | "-c", "1", | ||
| 924 | }; | ||
| 925 | |||
| 926 | static int __cmd_record(int argc, const char **argv) | 880 | static int __cmd_record(int argc, const char **argv) |
| 927 | { | 881 | { |
| 882 | const char *record_args[] = { | ||
| 883 | "record", "-R", "-f", "-m", "1024", "-c", "1", | ||
| 884 | }; | ||
| 928 | unsigned int rec_argc, i, j; | 885 | unsigned int rec_argc, i, j; |
| 929 | const char **rec_argv; | 886 | const char **rec_argv; |
| 930 | 887 | ||
| @@ -963,6 +920,37 @@ static int __cmd_record(int argc, const char **argv) | |||
| 963 | 920 | ||
| 964 | int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused) | 921 | int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused) |
| 965 | { | 922 | { |
| 923 | const struct option info_options[] = { | ||
| 924 | OPT_BOOLEAN('t', "threads", &info_threads, | ||
| 925 | "dump thread list in perf.data"), | ||
| 926 | OPT_BOOLEAN('m', "map", &info_map, | ||
| 927 | "map of lock instances (address:name table)"), | ||
| 928 | OPT_END() | ||
| 929 | }; | ||
| 930 | const struct option lock_options[] = { | ||
| 931 | OPT_STRING('i', "input", &input_name, "file", "input file name"), | ||
| 932 | OPT_INCR('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"), | ||
| 933 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"), | ||
| 934 | OPT_END() | ||
| 935 | }; | ||
| 936 | const struct option report_options[] = { | ||
| 937 | OPT_STRING('k', "key", &sort_key, "acquired", | ||
| 938 | "key for sorting (acquired / contended / wait_total / wait_max / wait_min)"), | ||
| 939 | /* TODO: type */ | ||
| 940 | OPT_END() | ||
| 941 | }; | ||
| 942 | const char * const info_usage[] = { | ||
| 943 | "perf lock info [<options>]", | ||
| 944 | NULL | ||
| 945 | }; | ||
| 946 | const char * const lock_usage[] = { | ||
| 947 | "perf lock [<options>] {record|report|script|info}", | ||
| 948 | NULL | ||
| 949 | }; | ||
| 950 | const char * const report_usage[] = { | ||
| 951 | "perf lock report [<options>]", | ||
| 952 | NULL | ||
| 953 | }; | ||
| 966 | unsigned int i; | 954 | unsigned int i; |
| 967 | int rc = 0; | 955 | int rc = 0; |
| 968 | 956 | ||
