diff options
author | Jaswinder Singh Rajput <jaswinder@kernel.org> | 2009-06-22 07:14:28 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-06-22 07:29:58 -0400 |
commit | 74d5b5889ea71a95d8924c08f8a7c6e2bdcbc0ba (patch) | |
tree | f03a43384906924cbc165aa2e45c06ebcff50ab4 /tools/perf/util | |
parent | 51e268423151fc7bb41945bde7843160b6a14c32 (diff) |
perf_counter tools: Introduce alias member in event_symbol
By introducing alias member in event_symbol :
1. duplicate lines are removed, like:
cpu-cycles and cycles
branch-instructions and branches
context-switches and cs
cpu-migrations and migrations
2. We can also add alias for another events.
Now ./perf list looks like :
List of pre-defined events (to be used in -e):
cpu-cycles OR cycles [Hardware event]
instructions [Hardware event]
cache-references [Hardware event]
cache-misses [Hardware event]
branch-instructions OR branches [Hardware event]
branch-misses [Hardware event]
bus-cycles [Hardware event]
cpu-clock [Software event]
task-clock [Software event]
page-faults [Software event]
faults [Software event]
minor-faults [Software event]
major-faults [Software event]
context-switches OR cs [Software event]
cpu-migrations OR migrations [Software event]
rNNN [raw hardware event descriptor]
Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <1245669268.17153.8.camel@localhost.localdomain>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/parse-events.c | 63 |
1 files changed, 38 insertions, 25 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 12abab3a0d63..f5695486ad3f 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -16,32 +16,29 @@ struct event_symbol { | |||
16 | u8 type; | 16 | u8 type; |
17 | u64 config; | 17 | u64 config; |
18 | char *symbol; | 18 | char *symbol; |
19 | char *alias; | ||
19 | }; | 20 | }; |
20 | 21 | ||
21 | #define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x | 22 | #define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x |
22 | #define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x | 23 | #define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x |
23 | 24 | ||
24 | static struct event_symbol event_symbols[] = { | 25 | static struct event_symbol event_symbols[] = { |
25 | { CHW(CPU_CYCLES), "cpu-cycles", }, | 26 | { CHW(CPU_CYCLES), "cpu-cycles", "cycles" }, |
26 | { CHW(CPU_CYCLES), "cycles", }, | 27 | { CHW(INSTRUCTIONS), "instructions", "" }, |
27 | { CHW(INSTRUCTIONS), "instructions", }, | 28 | { CHW(CACHE_REFERENCES), "cache-references", "" }, |
28 | { CHW(CACHE_REFERENCES), "cache-references", }, | 29 | { CHW(CACHE_MISSES), "cache-misses", "" }, |
29 | { CHW(CACHE_MISSES), "cache-misses", }, | 30 | { CHW(BRANCH_INSTRUCTIONS), "branch-instructions", "branches" }, |
30 | { CHW(BRANCH_INSTRUCTIONS), "branch-instructions", }, | 31 | { CHW(BRANCH_MISSES), "branch-misses", "" }, |
31 | { CHW(BRANCH_INSTRUCTIONS), "branches", }, | 32 | { CHW(BUS_CYCLES), "bus-cycles", "" }, |
32 | { CHW(BRANCH_MISSES), "branch-misses", }, | 33 | |
33 | { CHW(BUS_CYCLES), "bus-cycles", }, | 34 | { CSW(CPU_CLOCK), "cpu-clock", "" }, |
34 | 35 | { CSW(TASK_CLOCK), "task-clock", "" }, | |
35 | { CSW(CPU_CLOCK), "cpu-clock", }, | 36 | { CSW(PAGE_FAULTS), "page-faults", "" }, |
36 | { CSW(TASK_CLOCK), "task-clock", }, | 37 | { CSW(PAGE_FAULTS), "faults", "" }, |
37 | { CSW(PAGE_FAULTS), "page-faults", }, | 38 | { CSW(PAGE_FAULTS_MIN), "minor-faults", "" }, |
38 | { CSW(PAGE_FAULTS), "faults", }, | 39 | { CSW(PAGE_FAULTS_MAJ), "major-faults", "" }, |
39 | { CSW(PAGE_FAULTS_MIN), "minor-faults", }, | 40 | { CSW(CONTEXT_SWITCHES), "context-switches", "cs" }, |
40 | { CSW(PAGE_FAULTS_MAJ), "major-faults", }, | 41 | { CSW(CPU_MIGRATIONS), "cpu-migrations", "migrations" }, |
41 | { CSW(CONTEXT_SWITCHES), "context-switches", }, | ||
42 | { CSW(CONTEXT_SWITCHES), "cs", }, | ||
43 | { CSW(CPU_MIGRATIONS), "cpu-migrations", }, | ||
44 | { CSW(CPU_MIGRATIONS), "migrations", }, | ||
45 | }; | 42 | }; |
46 | 43 | ||
47 | #define __PERF_COUNTER_FIELD(config, name) \ | 44 | #define __PERF_COUNTER_FIELD(config, name) \ |
@@ -196,6 +193,19 @@ static int parse_generic_hw_symbols(const char *str, struct perf_counter_attr *a | |||
196 | return 0; | 193 | return 0; |
197 | } | 194 | } |
198 | 195 | ||
196 | static int check_events(const char *str, unsigned int i) | ||
197 | { | ||
198 | if (!strncmp(str, event_symbols[i].symbol, | ||
199 | strlen(event_symbols[i].symbol))) | ||
200 | return 1; | ||
201 | |||
202 | if (strlen(event_symbols[i].alias)) | ||
203 | if (!strncmp(str, event_symbols[i].alias, | ||
204 | strlen(event_symbols[i].alias))) | ||
205 | return 1; | ||
206 | return 0; | ||
207 | } | ||
208 | |||
199 | /* | 209 | /* |
200 | * Each event can have multiple symbolic names. | 210 | * Each event can have multiple symbolic names. |
201 | * Symbolic names are (almost) exactly matched. | 211 | * Symbolic names are (almost) exactly matched. |
@@ -235,9 +245,7 @@ static int parse_event_symbols(const char *str, struct perf_counter_attr *attr) | |||
235 | } | 245 | } |
236 | 246 | ||
237 | for (i = 0; i < ARRAY_SIZE(event_symbols); i++) { | 247 | for (i = 0; i < ARRAY_SIZE(event_symbols); i++) { |
238 | if (!strncmp(str, event_symbols[i].symbol, | 248 | if (check_events(str, i)) { |
239 | strlen(event_symbols[i].symbol))) { | ||
240 | |||
241 | attr->type = event_symbols[i].type; | 249 | attr->type = event_symbols[i].type; |
242 | attr->config = event_symbols[i].config; | 250 | attr->config = event_symbols[i].config; |
243 | 251 | ||
@@ -289,6 +297,7 @@ void print_events(void) | |||
289 | { | 297 | { |
290 | struct event_symbol *syms = event_symbols; | 298 | struct event_symbol *syms = event_symbols; |
291 | unsigned int i, type, prev_type = -1; | 299 | unsigned int i, type, prev_type = -1; |
300 | char name[40]; | ||
292 | 301 | ||
293 | fprintf(stderr, "\n"); | 302 | fprintf(stderr, "\n"); |
294 | fprintf(stderr, "List of pre-defined events (to be used in -e):\n"); | 303 | fprintf(stderr, "List of pre-defined events (to be used in -e):\n"); |
@@ -301,14 +310,18 @@ void print_events(void) | |||
301 | if (type != prev_type) | 310 | if (type != prev_type) |
302 | fprintf(stderr, "\n"); | 311 | fprintf(stderr, "\n"); |
303 | 312 | ||
304 | fprintf(stderr, " %-30s [%s]\n", syms->symbol, | 313 | if (strlen(syms->alias)) |
314 | sprintf(name, "%s OR %s", syms->symbol, syms->alias); | ||
315 | else | ||
316 | strcpy(name, syms->symbol); | ||
317 | fprintf(stderr, " %-40s [%s]\n", name, | ||
305 | event_type_descriptors[type]); | 318 | event_type_descriptors[type]); |
306 | 319 | ||
307 | prev_type = type; | 320 | prev_type = type; |
308 | } | 321 | } |
309 | 322 | ||
310 | fprintf(stderr, "\n"); | 323 | fprintf(stderr, "\n"); |
311 | fprintf(stderr, " %-30s [raw hardware event descriptor]\n", | 324 | fprintf(stderr, " %-40s [raw hardware event descriptor]\n", |
312 | "rNNN"); | 325 | "rNNN"); |
313 | fprintf(stderr, "\n"); | 326 | fprintf(stderr, "\n"); |
314 | 327 | ||