diff options
-rw-r--r-- | tools/perf/util/evsel.c | 29 | ||||
-rw-r--r-- | tools/perf/util/evsel.h | 2 | ||||
-rw-r--r-- | tools/perf/util/parse-events.c | 19 |
3 files changed, 34 insertions, 16 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 47f1fe2feab8..2da047331173 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -128,6 +128,31 @@ static int perf_evsel__hw_name(struct perf_evsel *evsel, char *bf, size_t size) | |||
128 | return r + perf_evsel__add_modifiers(evsel, bf + r, size - r); | 128 | return r + perf_evsel__add_modifiers(evsel, bf + r, size - r); |
129 | } | 129 | } |
130 | 130 | ||
131 | static const char *perf_evsel__sw_names[PERF_COUNT_SW_MAX] = { | ||
132 | "cpu-clock", | ||
133 | "task-clock", | ||
134 | "page-faults", | ||
135 | "context-switches", | ||
136 | "CPU-migrations", | ||
137 | "minor-faults", | ||
138 | "major-faults", | ||
139 | "alignment-faults", | ||
140 | "emulation-faults", | ||
141 | }; | ||
142 | |||
143 | const char *__perf_evsel__sw_name(u64 config) | ||
144 | { | ||
145 | if (config < PERF_COUNT_SW_MAX && perf_evsel__sw_names[config]) | ||
146 | return perf_evsel__sw_names[config]; | ||
147 | return "unknown-software"; | ||
148 | } | ||
149 | |||
150 | static int perf_evsel__sw_name(struct perf_evsel *evsel, char *bf, size_t size) | ||
151 | { | ||
152 | int r = scnprintf(bf, size, "%s", __perf_evsel__sw_name(evsel->attr.config)); | ||
153 | return r + perf_evsel__add_modifiers(evsel, bf + r, size - r); | ||
154 | } | ||
155 | |||
131 | const char *perf_evsel__hw_cache[PERF_COUNT_HW_CACHE_MAX] | 156 | const char *perf_evsel__hw_cache[PERF_COUNT_HW_CACHE_MAX] |
132 | [PERF_EVSEL__MAX_ALIASES] = { | 157 | [PERF_EVSEL__MAX_ALIASES] = { |
133 | { "L1-dcache", "l1-d", "l1d", "L1-data", }, | 158 | { "L1-dcache", "l1-d", "l1d", "L1-data", }, |
@@ -244,6 +269,10 @@ int perf_evsel__name(struct perf_evsel *evsel, char *bf, size_t size) | |||
244 | ret = perf_evsel__hw_cache_name(evsel, bf, size); | 269 | ret = perf_evsel__hw_cache_name(evsel, bf, size); |
245 | break; | 270 | break; |
246 | 271 | ||
272 | case PERF_TYPE_SOFTWARE: | ||
273 | ret = perf_evsel__sw_name(evsel, bf, size); | ||
274 | break; | ||
275 | |||
247 | default: | 276 | default: |
248 | /* | 277 | /* |
249 | * FIXME | 278 | * FIXME |
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 5bf946a05a6b..9ae64d9622bc 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
@@ -98,6 +98,8 @@ int __perf_evsel__hw_cache_type_op_res_name(u8 type, u8 op, u8 result, | |||
98 | int __perf_evsel__hw_cache_name(u64 config, char *bf, size_t size); | 98 | int __perf_evsel__hw_cache_name(u64 config, char *bf, size_t size); |
99 | 99 | ||
100 | const char *__perf_evsel__hw_name(u64 config); | 100 | const char *__perf_evsel__hw_name(u64 config); |
101 | const char *__perf_evsel__sw_name(u64 config); | ||
102 | |||
101 | int perf_evsel__name(struct perf_evsel *evsel, char *bf, size_t size); | 103 | int perf_evsel__name(struct perf_evsel *evsel, char *bf, size_t size); |
102 | 104 | ||
103 | int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads); | 105 | int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads); |
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index c8f8cf4a6920..641c4ac8a838 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -62,18 +62,6 @@ static struct event_symbol event_symbols[] = { | |||
62 | #define PERF_EVENT_TYPE(config) __PERF_EVENT_FIELD(config, TYPE) | 62 | #define PERF_EVENT_TYPE(config) __PERF_EVENT_FIELD(config, TYPE) |
63 | #define PERF_EVENT_ID(config) __PERF_EVENT_FIELD(config, EVENT) | 63 | #define PERF_EVENT_ID(config) __PERF_EVENT_FIELD(config, EVENT) |
64 | 64 | ||
65 | static const char *sw_event_names[PERF_COUNT_SW_MAX] = { | ||
66 | "cpu-clock", | ||
67 | "task-clock", | ||
68 | "page-faults", | ||
69 | "context-switches", | ||
70 | "CPU-migrations", | ||
71 | "minor-faults", | ||
72 | "major-faults", | ||
73 | "alignment-faults", | ||
74 | "emulation-faults", | ||
75 | }; | ||
76 | |||
77 | #define for_each_subsystem(sys_dir, sys_dirent, sys_next) \ | 65 | #define for_each_subsystem(sys_dir, sys_dirent, sys_next) \ |
78 | while (!readdir_r(sys_dir, &sys_dirent, &sys_next) && sys_next) \ | 66 | while (!readdir_r(sys_dir, &sys_dirent, &sys_next) && sys_next) \ |
79 | if (sys_dirent.d_type == DT_DIR && \ | 67 | if (sys_dirent.d_type == DT_DIR && \ |
@@ -218,7 +206,8 @@ const char *event_name(struct perf_evsel *evsel) | |||
218 | u64 config = evsel->attr.config; | 206 | u64 config = evsel->attr.config; |
219 | int type = evsel->attr.type; | 207 | int type = evsel->attr.type; |
220 | 208 | ||
221 | if (type == PERF_TYPE_RAW || type == PERF_TYPE_HARDWARE || type == PERF_TYPE_HW_CACHE) { | 209 | if (type == PERF_TYPE_RAW || type == PERF_TYPE_HARDWARE || |
210 | type == PERF_TYPE_SOFTWARE || type == PERF_TYPE_HW_CACHE) { | ||
222 | /* | 211 | /* |
223 | * XXX minimal fix, see comment on perf_evsen__name, this static buffer | 212 | * XXX minimal fix, see comment on perf_evsen__name, this static buffer |
224 | * will go away together with event_name in the next devel cycle. | 213 | * will go away together with event_name in the next devel cycle. |
@@ -252,9 +241,7 @@ const char *__event_name(int type, u64 config) | |||
252 | return buf; | 241 | return buf; |
253 | 242 | ||
254 | case PERF_TYPE_SOFTWARE: | 243 | case PERF_TYPE_SOFTWARE: |
255 | if (config < PERF_COUNT_SW_MAX && sw_event_names[config]) | 244 | return __perf_evsel__sw_name(config); |
256 | return sw_event_names[config]; | ||
257 | return "unknown-software"; | ||
258 | 245 | ||
259 | case PERF_TYPE_TRACEPOINT: | 246 | case PERF_TYPE_TRACEPOINT: |
260 | return tracepoint_id_to_name(config); | 247 | return tracepoint_id_to_name(config); |