perf tests: Add another metric parsing test
authorJiri Olsa <jolsa@kernel.org>
Wed, 3 Jun 2020 15:51:15 +0000 (12:51 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 22 Jun 2020 19:28:08 +0000 (16:28 -0300)
commite1c92a7fbbc5668510736624df3028accd6af0ea
treed8c337ef0adc2a6585dce8322d756ed160b621ed
parente46fc8d9dd352c88fec49b140008958d2dc1efe1
perf tests: Add another metric parsing test

The test goes through all metrics compiled for arch within pmu events
and try to parse them.

This test is different from 'test_parsing' in that we go through all the
events in the current arch, not just one defined for current CPU model.
Using 'fake_pmu' to parse events which do not have PMUs defined in the
system.

Say there's bad change in ivybridge metrics file, like:

  - a/tools/perf/pmu-events/arch/x86/ivybridge/ivb-metrics.json
  + b/tools/perf/pmu-events/arch/x86/ivybridge/ivb-metrics.json
  @@ -8,7 +8,7 @@
  -        "MetricExpr": "IDQ_UOPS_NOT_DELIVERED.CORE / (4 * ((
  +        "MetricExpr": "IDQ_UOPS_NOT_DELIVERED.CORE / / (4 *

the test fails with (on my kabylake laptop):

  $ perf test 'Parsing of PMU event table metrics with fake PMUs' -v
  parsing 'idq_uops_not_delivered.core / / (4 * (( ( cpu_clk_unh...
  syntax error, line 1
  expr__parse failed
  test child finished with -1
  ...

The test also defines its own list of metrics and tries to parse them.
It's handy for developing.

Committer notes:

Testing it:

  $ perf test fake
  10: PMU events                                            :
  10.4: Parsing of PMU event table metrics with fake PMUs   : FAILED!
  $ perf test -v fake |& tail
  parsing '(unc_p_freq_trans_cycles / unc_p_clockticks) * 100.'
  parsing '(unc_m_power_channel_ppd / unc_m_clockticks) * 100.'
  parsing '(unc_m_power_critical_throttle_cycles / unc_m_clockticks) * 100.'
  parsing '(unc_m_power_self_refresh / unc_m_clockticks) * 100.'
  parsing 'idq_uops_not_delivered.core / * (4 * cycles)'
  syntax error
  expr__parse failed
  test child finished with -1
  ---- end ----
  PMU events subtest 4: FAILED!
  $

And fix this error:

  tests/pmu-events.c:437:40: error: missing field 'idx' initializer [-Werror,-Wmissing-field-initializers]
        struct parse_events_error error = { 0 };

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20200602214741.1218986-5-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/tests/pmu-events.c