Re: [PATCH v2 06/18] perf s390 s390_cpumcfdg_dump: Don't scan all PMUs

From: Arnaldo Carvalho de Melo
Date: Fri Aug 25 2023 - 16:59:34 EST


Em Fri, Aug 25, 2023 at 04:39:22PM +0200, Thomas Richter escreveu:
> On 8/25/23 15:14, Ian Rogers wrote:
> > On Fri, Aug 25, 2023 at 1:20 AM Thomas Richter <tmricht@xxxxxxxxxxxxx> wrote:

> >> On 8/24/23 15:59, Arnaldo Carvalho de Melo wrote:
> >>> Em Wed, Aug 23, 2023 at 09:13:18PM -0700, Ian Rogers escreveu:
> >>>> Rather than scanning all PMUs for a counter name, scan the PMU
> >>>> associated with the evsel of the sample. This is done to remove a
> >>>> dependence on pmu-events.h.

> >>> I'm applying this one, and CCing the S/390 developers so that they can
> >>> try this and maybe provide an Acked-by/Tested-by,

> >> I have downloaded this patch set of 18 patches (using b4), but they do not
> >> apply on my git tree.

> >> Which git branch do I have to use to test this. Thanks a lot.

> > the changes are in the perf-tools-next tree:
> > https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/

> Unfurtunately this patch set fails again on s390.
> Here is the test output from the current 6.5.0rc7 kernel:
>
> # ./perf test 6 10 'perf all metricgroups test' 'perf all metrics test'
> 6: Parse event definition strings :
> 6.1: Test event parsing : Ok
> 6.2: Parsing of all PMU events from sysfs : Ok
> 6.3: Parsing of given PMU events from sysfs : Ok
> 6.4: Parsing of aliased events from sysfs : Skip (no aliases in sysfs)
> 6.5: Parsing of aliased events : Ok
> 6.6: Parsing of terms (event modifiers) : Ok
> 10: PMU events :
> 10.1: PMU event table sanity : Ok
> 10.2: PMU event map aliases : Ok
> 10.3: Parsing of PMU event table metrics : Ok
> 10.4: Parsing of PMU event table metrics with fake PMUs : Ok
> 10.5: Parsing of metric thresholds with fake PMUs : Ok
> 95: perf all metricgroups test : Ok
> 96: perf all metrics test : Ok
> #
>
> This looks good.

Reproduced:

# grep -E vendor_id\|^processor -m2 /proc/cpuinfo
vendor_id : IBM/S390
processor 0: version = 00, identification = 1A33E8, machine = 2964
#
# perf test 6 10 'perf all metricgroups test' 'perf all metrics test'
6: Parse event definition strings :
6.1: Test event parsing : Ok
6.2: Parsing of all PMU events from sysfs : Ok
6.3: Parsing of given PMU events from sysfs : Ok
6.4: Parsing of aliased events from sysfs : Skip (no aliases in sysfs)
6.5: Parsing of aliased events : Ok
6.6: Parsing of terms (event modifiers) : Ok
10: PMU events :
10.1: PMU event table sanity : Ok
10.2: PMU event map aliases : Ok
10.3: Parsing of PMU event table metrics : Ok
10.4: Parsing of PMU event table metrics with fake PMUs : Ok
10.5: Parsing of metric thresholds with fake PMUs : Ok
95: perf all metricgroups test : Ok
96: perf all metrics test : Ok
# perf -v
perf version 6.5.rc7.g6f0edbb833ec
#

> However when I use the check-out from perf-tools-next, I get this output:
> # ./perf test 6 10 'perf all metricgroups test' 'perf all metrics test'
> 6: Parse event definition strings :
> 6.1: Test event parsing : Ok
> 6.2: Parsing of all PMU events from sysfs : FAILED!
> 6.3: Parsing of given PMU events from sysfs : Ok
> 6.4: Parsing of aliased events from sysfs : Skip (no aliases in sysfs)
> 6.5: Parsing of aliased events : FAILED!
> 6.6: Parsing of terms (event modifiers) : Ok
> 10: PMU events :
> 10.1: PMU event table sanity : Ok
> 10.2: PMU event map aliases : FAILED!
> 10.3: Parsing of PMU event table metrics : Ok
> 10.4: Parsing of PMU event table metrics with fake PMUs : FAILED!
> 10.5: Parsing of metric thresholds with fake PMUs : Ok
> 93: perf all metricgroups test : FAILED!
> 94: perf all metrics test : FAILED!
> #
>
> So some tests are failing again.
>
> I am out for the next two weeks, Sumanth Korikkar (on to list) might be able to help.
> Thanks a lot.

[root@kernelqe3 linux]# git checkout perf-tools-next
git Switched to branch 'perf-tools-next'
Your branch is up to date with 'perf-tools-next/perf-tools-next'.
[root@kernelqe3 linux]# git log --oneline -5
eeb6b12992c4 (HEAD -> perf-tools-next, perf-tools-next/perf-tools-next) perf jevents: Don't append Unit to desc
f208b2c6f984 (perf-tools-next/tmp.perf-tools-next) perf scripts python gecko: Launch the profiler UI on the default browser with the appropriate URL
43803cb16f99 perf scripts python: Add support for input args in gecko script
f85d120c46e7 perf jevents: Sort strings in the big C string to reduce faults
8d4b6d37ea78 perf pmu: Lazily load sysfs aliases
[root@kernelqe3 linux]# make BUILD_BPF_SKEL=1 -C tools/perf O=/tmp/build/perf install-bin

[root@kernelqe3 linux]# perf -v
perf version 6.5.rc5.geeb6b12992c4
[root@kernelqe3 linux]# git log --oneline -1
eeb6b12992c4 (HEAD -> perf-tools-next, perf-tools-next/perf-tools-next) perf jevents: Don't append Unit to desc
[root@kernelqe3 linux]# perf test 6 10 'perf all metricgroups test' 'perf all metrics test'
6: Parse event definition strings :
6.1: Test event parsing : Ok
6.2: Parsing of all PMU events from sysfs : FAILED!
6.3: Parsing of given PMU events from sysfs : Ok
6.4: Parsing of aliased events from sysfs : Skip (no aliases in sysfs)
6.5: Parsing of aliased events : FAILED!
6.6: Parsing of terms (event modifiers) : Ok
10: PMU events :
10.1: PMU event table sanity : Ok
10.2: PMU event map aliases : FAILED!
10.3: Parsing of PMU event table metrics : Ok
10.4: Parsing of PMU event table metrics with fake PMUs : FAILED!
10.5: Parsing of metric thresholds with fake PMUs : Ok
93: perf all metricgroups test : FAILED!
94: perf all metrics test : FAILED!
[root@kernelqe3 linux]#

Bisecting the first problem:

10.2: PMU event map aliases : FAILED!

make: Leaving directory '/root/git/linux/tools/perf'
6: Parse event definition strings :
6.1: Test event parsing : Ok
6.2: Parsing of all PMU events from sysfs : Ok
6.3: Parsing of given PMU events from sysfs : Ok
6.4: Parsing of aliased events from sysfs : Skip (no aliases in sysfs)
6.5: Parsing of aliased events : Ok
6.6: Parsing of terms (event modifiers) : Ok
10: PMU events :
10.1: PMU event table sanity : Ok
10.2: PMU event map aliases : FAILED!
10.3: Parsing of PMU event table metrics : Ok
10.4: Parsing of PMU event table metrics with fake PMUs : Ok
10.5: Parsing of metric thresholds with fake PMUs : Ok
93: perf all metricgroups test : Ok
94: perf all metrics test : Ok
[root@kernelqe3 linux]# git bisect bad
2e255b4f9f41f137d9e3dc4fae3603a9c2c3dd28 is the first bad commit
commit 2e255b4f9f41f137d9e3dc4fae3603a9c2c3dd28
Author: Ian Rogers <irogers@xxxxxxxxxx>
Date: Wed Aug 23 21:13:16 2023 -0700

perf jevents: Group events by PMU

Prior to this change a cpuid would map to a list of events where the PMU
would be encoded alongside the event information. This change breaks
apart each group of events so that there is a group per PMU. A new table
is added with the PMU's name and the list of events, the original table
now holding an array of these per PMU tables.

These changes are to make it easier to get per PMU information about
events, rather than the current approach of scanning all events. The
perf binary size with BPF skeletons on x86 is reduced by about 1%. The
unidentified PMU is now always expanded to "cpu".

Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
Cc: Gaosheng Cui <cuigaosheng1@xxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: James Clark <james.clark@xxxxxxx>
Cc: Jing Zhang <renyu.zj@xxxxxxxxxxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: John Garry <john.g.garry@xxxxxxxxxx>
Cc: Kajol Jain <kjain@xxxxxxxxxxxxx>
Cc: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
Cc: Mark Rutland <mark.rutland@xxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Ravi Bangoria <ravi.bangoria@xxxxxxx>
Cc: Rob Herring <robh@xxxxxxxxxx>
Link: https://lore.kernel.org/r/20230824041330.266337-5-irogers@xxxxxxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>

tools/perf/pmu-events/jevents.py | 181 +++++++++++++++++++++++++++++----------
tools/perf/tests/pmu-events.c | 30 ++++---
2 files changed, 154 insertions(+), 57 deletions(-)
[root@kernelqe3 linux]#