diff options
author | Jiri Olsa <jolsa@redhat.com> | 2012-07-03 18:00:44 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-07-05 10:31:13 -0400 |
commit | 1dc12760854a670d0366dcfd8ad179e3574c1712 (patch) | |
tree | ded10cc932dff47a07e90b94fbdb10c74bc8e9b0 | |
parent | cf3506dcc4a855d11af20bcb271ac921033ba0de (diff) |
perf tools: Split event symbols arrays to hw and sw parts
It'll be convenient in upcoming patch to access hw event symbols
strings via enum perf_hw_id indexes. In order not to duplicate
the data, creating two separate arrays:
event_symbols_hw for enum perf_hw_id events
event_symbols_sw for enum perf_sw_ids events
Changing the current event list code to follow the change.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1341352848-11833-7-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/parse-events.c | 174 |
1 files changed, 117 insertions, 57 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 1dc44dc69133..1aa721d7c10f 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -19,8 +19,6 @@ | |||
19 | #define MAX_NAME_LEN 100 | 19 | #define MAX_NAME_LEN 100 |
20 | 20 | ||
21 | struct event_symbol { | 21 | struct event_symbol { |
22 | u8 type; | ||
23 | u64 config; | ||
24 | const char *symbol; | 22 | const char *symbol; |
25 | const char *alias; | 23 | const char *alias; |
26 | }; | 24 | }; |
@@ -30,30 +28,86 @@ extern int parse_events_debug; | |||
30 | #endif | 28 | #endif |
31 | int parse_events_parse(void *data, void *scanner); | 29 | int parse_events_parse(void *data, void *scanner); |
32 | 30 | ||
33 | #define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x | 31 | static struct event_symbol event_symbols_hw[PERF_COUNT_HW_MAX] = { |
34 | #define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x | 32 | [PERF_COUNT_HW_CPU_CYCLES] = { |
35 | 33 | .symbol = "cpu-cycles", | |
36 | static struct event_symbol event_symbols[] = { | 34 | .alias = "cycles", |
37 | { CHW(CPU_CYCLES), "cpu-cycles", "cycles" }, | 35 | }, |
38 | { CHW(STALLED_CYCLES_FRONTEND), "stalled-cycles-frontend", "idle-cycles-frontend" }, | 36 | [PERF_COUNT_HW_INSTRUCTIONS] = { |
39 | { CHW(STALLED_CYCLES_BACKEND), "stalled-cycles-backend", "idle-cycles-backend" }, | 37 | .symbol = "instructions", |
40 | { CHW(INSTRUCTIONS), "instructions", "" }, | 38 | .alias = "", |
41 | { CHW(CACHE_REFERENCES), "cache-references", "" }, | 39 | }, |
42 | { CHW(CACHE_MISSES), "cache-misses", "" }, | 40 | [PERF_COUNT_HW_CACHE_REFERENCES] = { |
43 | { CHW(BRANCH_INSTRUCTIONS), "branch-instructions", "branches" }, | 41 | .symbol = "cache-references", |
44 | { CHW(BRANCH_MISSES), "branch-misses", "" }, | 42 | .alias = "", |
45 | { CHW(BUS_CYCLES), "bus-cycles", "" }, | 43 | }, |
46 | { CHW(REF_CPU_CYCLES), "ref-cycles", "" }, | 44 | [PERF_COUNT_HW_CACHE_MISSES] = { |
47 | 45 | .symbol = "cache-misses", | |
48 | { CSW(CPU_CLOCK), "cpu-clock", "" }, | 46 | .alias = "", |
49 | { CSW(TASK_CLOCK), "task-clock", "" }, | 47 | }, |
50 | { CSW(PAGE_FAULTS), "page-faults", "faults" }, | 48 | [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = { |
51 | { CSW(PAGE_FAULTS_MIN), "minor-faults", "" }, | 49 | .symbol = "branch-instructions", |
52 | { CSW(PAGE_FAULTS_MAJ), "major-faults", "" }, | 50 | .alias = "branches", |
53 | { CSW(CONTEXT_SWITCHES), "context-switches", "cs" }, | 51 | }, |
54 | { CSW(CPU_MIGRATIONS), "cpu-migrations", "migrations" }, | 52 | [PERF_COUNT_HW_BRANCH_MISSES] = { |
55 | { CSW(ALIGNMENT_FAULTS), "alignment-faults", "" }, | 53 | .symbol = "branch-misses", |
56 | { CSW(EMULATION_FAULTS), "emulation-faults", "" }, | 54 | .alias = "", |
55 | }, | ||
56 | [PERF_COUNT_HW_BUS_CYCLES] = { | ||
57 | .symbol = "bus-cycles", | ||
58 | .alias = "", | ||
59 | }, | ||
60 | [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = { | ||
61 | .symbol = "stalled-cycles-frontend", | ||
62 | .alias = "idle-cycles-frontend", | ||
63 | }, | ||
64 | [PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = { | ||
65 | .symbol = "stalled-cycles-backend", | ||
66 | .alias = "idle-cycles-backend", | ||
67 | }, | ||
68 | [PERF_COUNT_HW_REF_CPU_CYCLES] = { | ||
69 | .symbol = "ref-cycles", | ||
70 | .alias = "", | ||
71 | }, | ||
72 | }; | ||
73 | |||
74 | static struct event_symbol event_symbols_sw[PERF_COUNT_SW_MAX] = { | ||
75 | [PERF_COUNT_SW_CPU_CLOCK] = { | ||
76 | .symbol = "cpu-clock", | ||
77 | .alias = "", | ||
78 | }, | ||
79 | [PERF_COUNT_SW_TASK_CLOCK] = { | ||
80 | .symbol = "task-clock", | ||
81 | .alias = "", | ||
82 | }, | ||
83 | [PERF_COUNT_SW_PAGE_FAULTS] = { | ||
84 | .symbol = "page-faults", | ||
85 | .alias = "faults", | ||
86 | }, | ||
87 | [PERF_COUNT_SW_CONTEXT_SWITCHES] = { | ||
88 | .symbol = "context-switches", | ||
89 | .alias = "cs", | ||
90 | }, | ||
91 | [PERF_COUNT_SW_CPU_MIGRATIONS] = { | ||
92 | .symbol = "cpu-migrations", | ||
93 | .alias = "migrations", | ||
94 | }, | ||
95 | [PERF_COUNT_SW_PAGE_FAULTS_MIN] = { | ||
96 | .symbol = "minor-faults", | ||
97 | .alias = "", | ||
98 | }, | ||
99 | [PERF_COUNT_SW_PAGE_FAULTS_MAJ] = { | ||
100 | .symbol = "major-faults", | ||
101 | .alias = "", | ||
102 | }, | ||
103 | [PERF_COUNT_SW_ALIGNMENT_FAULTS] = { | ||
104 | .symbol = "alignment-faults", | ||
105 | .alias = "", | ||
106 | }, | ||
107 | [PERF_COUNT_SW_EMULATION_FAULTS] = { | ||
108 | .symbol = "emulation-faults", | ||
109 | .alias = "", | ||
110 | }, | ||
57 | }; | 111 | }; |
58 | 112 | ||
59 | #define __PERF_EVENT_FIELD(config, name) \ | 113 | #define __PERF_EVENT_FIELD(config, name) \ |
@@ -824,16 +878,13 @@ int is_valid_tracepoint(const char *event_string) | |||
824 | return 0; | 878 | return 0; |
825 | } | 879 | } |
826 | 880 | ||
827 | void print_events_type(u8 type) | 881 | static void __print_events_type(u8 type, struct event_symbol *syms, |
882 | unsigned max) | ||
828 | { | 883 | { |
829 | struct event_symbol *syms = event_symbols; | ||
830 | unsigned int i; | ||
831 | char name[64]; | 884 | char name[64]; |
885 | unsigned i; | ||
832 | 886 | ||
833 | for (i = 0; i < ARRAY_SIZE(event_symbols); i++, syms++) { | 887 | for (i = 0; i < max ; i++, syms++) { |
834 | if (type != syms->type) | ||
835 | continue; | ||
836 | |||
837 | if (strlen(syms->alias)) | 888 | if (strlen(syms->alias)) |
838 | snprintf(name, sizeof(name), "%s OR %s", | 889 | snprintf(name, sizeof(name), "%s OR %s", |
839 | syms->symbol, syms->alias); | 890 | syms->symbol, syms->alias); |
@@ -845,6 +896,14 @@ void print_events_type(u8 type) | |||
845 | } | 896 | } |
846 | } | 897 | } |
847 | 898 | ||
899 | void print_events_type(u8 type) | ||
900 | { | ||
901 | if (type == PERF_TYPE_SOFTWARE) | ||
902 | __print_events_type(type, event_symbols_sw, PERF_COUNT_SW_MAX); | ||
903 | else | ||
904 | __print_events_type(type, event_symbols_hw, PERF_COUNT_HW_MAX); | ||
905 | } | ||
906 | |||
848 | int print_hwcache_events(const char *event_glob) | 907 | int print_hwcache_events(const char *event_glob) |
849 | { | 908 | { |
850 | unsigned int type, op, i, printed = 0; | 909 | unsigned int type, op, i, printed = 0; |
@@ -872,26 +931,13 @@ int print_hwcache_events(const char *event_glob) | |||
872 | return printed; | 931 | return printed; |
873 | } | 932 | } |
874 | 933 | ||
875 | /* | 934 | static void print_symbol_events(const char *event_glob, unsigned type, |
876 | * Print the help text for the event symbols: | 935 | struct event_symbol *syms, unsigned max) |
877 | */ | ||
878 | void print_events(const char *event_glob) | ||
879 | { | 936 | { |
880 | unsigned int i, type, prev_type = -1, printed = 0, ntypes_printed = 0; | 937 | unsigned i, printed = 0; |
881 | struct event_symbol *syms = event_symbols; | ||
882 | char name[MAX_NAME_LEN]; | 938 | char name[MAX_NAME_LEN]; |
883 | 939 | ||
884 | printf("\n"); | 940 | for (i = 0; i < max; i++, syms++) { |
885 | printf("List of pre-defined events (to be used in -e):\n"); | ||
886 | |||
887 | for (i = 0; i < ARRAY_SIZE(event_symbols); i++, syms++) { | ||
888 | type = syms->type; | ||
889 | |||
890 | if (type != prev_type && printed) { | ||
891 | printf("\n"); | ||
892 | printed = 0; | ||
893 | ntypes_printed++; | ||
894 | } | ||
895 | 941 | ||
896 | if (event_glob != NULL && | 942 | if (event_glob != NULL && |
897 | !(strglobmatch(syms->symbol, event_glob) || | 943 | !(strglobmatch(syms->symbol, event_glob) || |
@@ -902,17 +948,31 @@ void print_events(const char *event_glob) | |||
902 | snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias); | 948 | snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias); |
903 | else | 949 | else |
904 | strncpy(name, syms->symbol, MAX_NAME_LEN); | 950 | strncpy(name, syms->symbol, MAX_NAME_LEN); |
905 | printf(" %-50s [%s]\n", name, | ||
906 | event_type_descriptors[type]); | ||
907 | 951 | ||
908 | prev_type = type; | 952 | printf(" %-50s [%s]\n", name, event_type_descriptors[type]); |
909 | ++printed; | 953 | |
954 | printed++; | ||
910 | } | 955 | } |
911 | 956 | ||
912 | if (ntypes_printed) { | 957 | if (printed) |
913 | printed = 0; | ||
914 | printf("\n"); | 958 | printf("\n"); |
915 | } | 959 | } |
960 | |||
961 | /* | ||
962 | * Print the help text for the event symbols: | ||
963 | */ | ||
964 | void print_events(const char *event_glob) | ||
965 | { | ||
966 | |||
967 | printf("\n"); | ||
968 | printf("List of pre-defined events (to be used in -e):\n"); | ||
969 | |||
970 | print_symbol_events(event_glob, PERF_TYPE_HARDWARE, | ||
971 | event_symbols_hw, PERF_COUNT_HW_MAX); | ||
972 | |||
973 | print_symbol_events(event_glob, PERF_TYPE_SOFTWARE, | ||
974 | event_symbols_sw, PERF_COUNT_SW_MAX); | ||
975 | |||
916 | print_hwcache_events(event_glob); | 976 | print_hwcache_events(event_glob); |
917 | 977 | ||
918 | if (event_glob != NULL) | 978 | if (event_glob != NULL) |