[PATCH 16/21] perf tools: Allow numeric event to change name via name term

From: Jiri Olsa
Date: Wed Sep 25 2013 - 08:53:35 EST


Allowing numeric event to change name via name term,
so it's possible to change following event name:

$ ./perf stat -e 'cycles:k,cycles/name=cycles_irq/k' kill
usage: kill [ -s signal | -p ] [ -a ] pid ...
kill -l [ signal ]

Performance counter stats for 'kill':

958,972 cycles:k # 0.000 GHz
958,972 cycles_irq # 0.000 GHz

0.001047556 seconds time elapsed

It'll be useful for aliasing/distinguishing events for
on/off toggling terms.

Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Cc: Corey Ashford <cjashfor@xxxxxxxxxxxxxxxxxx>
Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/util/parse-events.c | 37 ++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 9812531..1957849 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -583,6 +583,25 @@ do { \
#undef CHECK_TYPE_VAL
}

+static int parse_events__is_name_term(struct parse_events_term *term)
+{
+ return term->type_term == PARSE_EVENTS__TERM_TYPE_NAME;
+}
+
+static char *pmu_event_name(struct list_head *head_terms)
+{
+ struct parse_events_term *term;
+
+ if (!head_terms)
+ return NULL;
+
+ list_for_each_entry(term, head_terms, list)
+ if (parse_events__is_name_term(term))
+ return term->val.str;
+
+ return NULL;
+}
+
static int config_attr(struct perf_event_attr *attr,
struct list_head *head, int fail)
{
@@ -609,23 +628,7 @@ int parse_events_add_numeric(struct list_head *list, int *idx,
config_attr(&attr, head_config, 1))
return -EINVAL;

- return add_event(list, idx, &attr, NULL);
-}
-
-static int parse_events__is_name_term(struct parse_events_term *term)
-{
- return term->type_term == PARSE_EVENTS__TERM_TYPE_NAME;
-}
-
-static char *pmu_event_name(struct list_head *head_terms)
-{
- struct parse_events_term *term;
-
- list_for_each_entry(term, head_terms, list)
- if (parse_events__is_name_term(term))
- return term->val.str;
-
- return NULL;
+ return add_event(list, idx, &attr, pmu_event_name(terms));
}

int parse_events_add_pmu(struct list_head *list, int *idx,
--
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/