From 00636c3b48e8acac2acd2601274c6eab4ecf8201 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Mon, 20 Mar 2017 13:17:07 -0700 Subject: perf pmu: Support MetricExpr header in JSON event list Add support for parsing the MetricExpr header in the JSON event lists and storing them in the alias structure. Used in the next patch. v2: Change DividedBy to MetricExpr v3: Really catch all uses of DividedBy Signed-off-by: Andi Kleen Acked-by: Jiri Olsa Link: http://lkml.kernel.org/r/20170320201711.14142-10-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/pmu.c | 9 ++++++--- tools/perf/util/pmu.h | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'tools/perf/util') diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 12f84dd2ac5d..c0d487b3b925 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -231,7 +231,8 @@ static int perf_pmu__parse_snapshot(struct perf_pmu_alias *alias, static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name, char *desc, char *val, char *long_desc, char *topic, - char *unit, char *perpkg) + char *unit, char *perpkg, + char *metric_expr) { struct perf_pmu_alias *alias; int ret; @@ -265,6 +266,7 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name, perf_pmu__parse_snapshot(alias, dir, name); } + alias->metric_expr = metric_expr ? strdup(metric_expr) : NULL; alias->desc = desc ? strdup(desc) : NULL; alias->long_desc = long_desc ? strdup(long_desc) : desc ? strdup(desc) : NULL; @@ -294,7 +296,7 @@ static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FI buf[ret] = 0; return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL, NULL, NULL, - NULL); + NULL, NULL); } static inline bool pmu_alias_info_file(char *name) @@ -564,7 +566,8 @@ static void pmu_add_cpu_aliases(struct list_head *head, const char *name) __perf_pmu__new_alias(head, NULL, (char *)pe->name, (char *)pe->desc, (char *)pe->event, (char *)pe->long_desc, (char *)pe->topic, - (char *)pe->unit, (char *)pe->perpkg); + (char *)pe->unit, (char *)pe->perpkg, + (char *)pe->metric_expr); } out: diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index 00852ddc7741..3dccb15f29e9 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -50,6 +50,7 @@ struct perf_pmu_alias { double scale; bool per_pkg; bool snapshot; + char *metric_expr; }; struct perf_pmu *perf_pmu__find(const char *name); -- cgit v1.2.3-59-g8ed1b