Re: [RFC 00/10] perf tools: Add support to reuse metric

From: John Garry
Date: Sat Jun 27 2020 - 04:15:04 EST


On 26/06/2020 20:47, Jiri Olsa wrote:
hi,
this patchset is adding the support to reused metric in another
metric. The metric needs to be referenced by 'metric:' prefix.


I notice that there is much repetition in the x86 metric JSONs between CPUs.

So I know it's not the same as what you propose here, but jevents standard arch events feature could be used to reduce the repetition.

I'm guessing that those metric JSONs are human generated, so would be suitable; unlike the regular JSONs, which are automated.

Thanks,
John

For example, to define IPC by using CPI with change like:

"BriefDescription": "Instructions Per Cycle (per Logical Processor)",
- "MetricExpr": "INST_RETIRED.ANY / CPU_CLK_UNHALTED.THREAD",
+ "MetricExpr": "1/metric:CPI",
"MetricGroup": "TopDownL1",
"MetricName": "IPC"

I won't be able to find all the possible places we could
use this at, so I wonder you guys (who was asking for this)
would try it and come up with comments if there's something
missing or we could already use it at some places.

It's based on Arnaldo's tmp.perf/core.

Also available in here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/metric

thanks,
jirka


---
Jiri Olsa (10):
perf tools: Rename expr__add_id to expr__add_val
perf tools: Add struct expr_parse_data to keep expr value
perf tools: Add expr__add_id function
perf tools: Change expr__get_id to return struct expr_parse_data
perf tools: Add expr__del_id function
perf tools: Collect other metrics in struct egroup
perf tools: Collect other metrics in struct metric_expr
perf tools: Add other metrics to hash data
perf tools: Compute other metrics
perf tests: Add cache_miss_cycles to metric parse test

tools/perf/pmu-events/arch/x86/skylake/skl-metrics.json | 2 +-
tools/perf/tests/expr.c | 7 ++--
tools/perf/tests/parse-metric.c | 33 +++++++++++++++++
tools/perf/tests/pmu-events.c | 4 +--
tools/perf/util/expr.c | 115 +++++++++++++++++++++++++++++++++++++++++++++-------------
tools/perf/util/expr.h | 24 +++++++++++--
tools/perf/util/expr.y | 34 ++++++++++++++----
tools/perf/util/metricgroup.c | 187 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
tools/perf/util/metricgroup.h | 6 ++++
tools/perf/util/stat-shadow.c | 23 +++++++-----
10 files changed, 374 insertions(+), 61 deletions(-)

.