aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/parse-events.c
diff options
context:
space:
mode:
authorWang Nan <wangnan0@huawei.com>2016-02-19 06:44:01 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-02-19 17:12:51 -0500
commit43d0b97817a41b274aaec0476e912dae3ae1f93d (patch)
treef865dd5a4fce34a7ad911bdfb30ee91f80c859d9 /tools/perf/util/parse-events.c
parent10bf358a1b79fa1311eb05ee31f2cefdcad01741 (diff)
perf tools: Enable config and setting names for legacy cache events
This patch allows setting config terms for legacy cache events. For example: # perf stat -e L1-icache-misses/name=valA/ -e branches/name=valB/ ls ... Performance counter stats for 'ls': 11299 valA 451605 valB 0.000779091 seconds time elapsed # perf record -e cache-misses/name=inh/ -e cache-misses/name=noinh,no-inherit/ bash # ls # exit [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.023 MB perf.data (131 samples) ] # perf report --stdio | grep -B 1 'Event count' # Samples: 105 of event 'inh' # Event count (approx.): 109118 -- # Samples: 26 of event 'noinh' # Event count (approx.): 48302 A test case is introduced to test this feature. Signed-off-by: Wang Nan <wangnan0@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Brendan Gregg <brendan.d.gregg@gmail.com> Cc: Cody P Schafer <dev@codyps.com> Cc: He Kuang <hekuang@huawei.com> Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kirill Smelkov <kirr@nexedi.com> Cc: Li Zefan <lizefan@huawei.com> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Zefan Li <lizefan@huawei.com> Cc: pi3orama@163.com Link: http://lkml.kernel.org/r/1455882283-79592-14-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/parse-events.c')
-rw-r--r--tools/perf/util/parse-events.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 75576e130e16..2996aa4207bd 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -350,11 +350,25 @@ static int parse_aliases(char *str, const char *names[][PERF_EVSEL__MAX_ALIASES]
350 return -1; 350 return -1;
351} 351}
352 352
353typedef int config_term_func_t(struct perf_event_attr *attr,
354 struct parse_events_term *term,
355 struct parse_events_error *err);
356static int config_term_common(struct perf_event_attr *attr,
357 struct parse_events_term *term,
358 struct parse_events_error *err);
359static int config_attr(struct perf_event_attr *attr,
360 struct list_head *head,
361 struct parse_events_error *err,
362 config_term_func_t config_term);
363
353int parse_events_add_cache(struct list_head *list, int *idx, 364int parse_events_add_cache(struct list_head *list, int *idx,
354 char *type, char *op_result1, char *op_result2) 365 char *type, char *op_result1, char *op_result2,
366 struct parse_events_error *error,
367 struct list_head *head_config)
355{ 368{
356 struct perf_event_attr attr; 369 struct perf_event_attr attr;
357 char name[MAX_NAME_LEN]; 370 LIST_HEAD(config_terms);
371 char name[MAX_NAME_LEN], *config_name;
358 int cache_type = -1, cache_op = -1, cache_result = -1; 372 int cache_type = -1, cache_op = -1, cache_result = -1;
359 char *op_result[2] = { op_result1, op_result2 }; 373 char *op_result[2] = { op_result1, op_result2 };
360 int i, n; 374 int i, n;
@@ -368,6 +382,7 @@ int parse_events_add_cache(struct list_head *list, int *idx,
368 if (cache_type == -1) 382 if (cache_type == -1)
369 return -EINVAL; 383 return -EINVAL;
370 384
385 config_name = get_config_name(head_config);
371 n = snprintf(name, MAX_NAME_LEN, "%s", type); 386 n = snprintf(name, MAX_NAME_LEN, "%s", type);
372 387
373 for (i = 0; (i < 2) && (op_result[i]); i++) { 388 for (i = 0; (i < 2) && (op_result[i]); i++) {
@@ -408,7 +423,16 @@ int parse_events_add_cache(struct list_head *list, int *idx,
408 memset(&attr, 0, sizeof(attr)); 423 memset(&attr, 0, sizeof(attr));
409 attr.config = cache_type | (cache_op << 8) | (cache_result << 16); 424 attr.config = cache_type | (cache_op << 8) | (cache_result << 16);
410 attr.type = PERF_TYPE_HW_CACHE; 425 attr.type = PERF_TYPE_HW_CACHE;
411 return add_event(list, idx, &attr, name, NULL); 426
427 if (head_config) {
428 if (config_attr(&attr, head_config, error,
429 config_term_common))
430 return -EINVAL;
431
432 if (get_config_terms(head_config, &config_terms))
433 return -ENOMEM;
434 }
435 return add_event(list, idx, &attr, config_name ? : name, &config_terms);
412} 436}
413 437
414static void tracepoint_error(struct parse_events_error *e, int err, 438static void tracepoint_error(struct parse_events_error *e, int err,