From: Lucas Stach <l.stach@pengutronix.de>
To: James Clark <james.clark@linaro.org>,
Ian Rogers <irogers@google.com>,
Namhyung Kim <namhyung@kernel.org>, Leo Yan <leo.yan@linux.dev>,
James Clark <james.clark@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>, Jiri Olsa <jolsa@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
patchwork-lst@pengutronix.de, linux-perf-users@vger.kernel.org,
kernel@pengutronix.de, Kan Liang <kan.liang@linux.intel.com>
Subject: Re: [PATCH] perf jevents: return potentially empty metrics table
Date: Mon, 15 Jul 2024 17:54:13 +0200 [thread overview]
Message-ID: <ac1d9124e497a1667e7cbc340f923cb4449764bb.camel@pengutronix.de> (raw)
In-Reply-To: <b3a4282a-91b6-49a0-83d1-470cc4873dc1@linaro.org>
Am Montag, dem 15.07.2024 um 16:12 +0100 schrieb James Clark:
>
> On 12/07/2024 10:54 pm, Ian Rogers wrote:
> > On Wed, Jul 3, 2024 at 3:33 PM Namhyung Kim <namhyung@kernel.org> wrote:
> > >
> > > Hello,
> > >
> > > On Mon, Jul 01, 2024 at 07:19:55PM +0200, Lucas Stach wrote:
> > > > Hi,
> > > >
> > > > has this patch fallen through the cracks? It fixes a functional
> > > > regression where the DDR controller metrics are completely unavailable
> > > > on all i.MX8M* systems and thus would be nice if someone could have a
> > > > look.
> > > >
> > > > Regards,
> > > > Lucas
> > > >
> > > > Am Freitag, dem 31.05.2024 um 21:44 +0200 schrieb Lucas Stach:
> > > > > Don't return NULL when a empty (num_pmus = 0) metrics table is encountered,
> > > > > as this causes many of the users to bail out, which will skip matching any
> > > > > potentially existing sys metrics later on. Instead return the empty table
> > > > > which will be handled properly by the iterators and allows matching to
> > > > > continue.
> > > > >
> > > > > This fixes metrics reporting on systems where only the sys, but not the
> > > > > core PMUs have metrics defined.
> > > > >
> > > > > Fixes: f20c15d13f01 ("perf pmu-events: Remember the perf_events_map for a PMU")
> > > > > Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> > >
> > > Looks ok to me. Ian?
> >
> > Sorry I missed this, I expect to see patches on LKML and so my email
> > filters placed this elsewhere.
> >
> > The change doesn't make sense. A search is requested with a PMU and
> > you return success (the table) when there is no PMU match. If this
> > behavior were expected then NULL should be passed as a PMU - this is
> > the behavior in util/pmu.c and ARM is the only architecture to pass a
> > PMU. The ARM pmu_metrics_table__find also specifically breaks
> > heterogeneous (BIG.little) systems and this change won't impact/fix
> > that. Perhaps there is some context I lack.
> >
The missing context is probably the call chain that I somehow omitted
and needed to piece together again right now. The issue I'm try to fix
here is perf stat not being able to measure metrics from a system-wide
PMU (the i.MX8M* ddrc) only.
The underlying issue is that when there is no non-systemwide PMU,
perf_pmu__find_metrics_table will return NULL after f20c15d13f01. This
causes metricgroup__parse_groups to drop out early. However, we need
this function to call the chain parse_groups() ->
metricgroup__add_metric_list -> metricgroup__add_metric, as only at
this point system wide metrics, like the ddrc, will be added to the
list.
It is correct to drop out early, as those functions can not be called
with a NULL parameter. Before f20c15d13f01 and after the patch
discussed here perf_pmu__find_metrics_table() will simply return a
table with 0 entries. The called functions are fine with this, as they
iterate the entries and the execution flow is able to reach the point
where the system wide events are added.
> > Thanks,
> > Ian
> >
>
> Yes it looks like the fix should possibly be higher up in the arm64
> pmu_metrics_table__find().
>
Maybe someone can figure out how to fix this in a better way higher up
the call chain with the description above. However, my fix looked quite
straight forward to me, as it simply restores the behavior before
f20c15d13f01.
> Which set of JSON files are you seeing the issue with exactly Lucas? I
> see that there are multiple versions of i.MX8M metrics.
>
It was first observed on a i.MX8MP, but the issue is also reproducible
on i.MX8MM. I guess it doesn't matter which SoC is used specifically,
the key point is that the sampling isn't able to match any specific
PMU, but there are still system wide metrics.
Regards,
Lucas
> James
>
> > > Thanks,
> > > Namhyung
> > >
> > >
> > > > > ---
> > > > > tools/perf/pmu-events/jevents.py | 2 +-
> > > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
> > > > > index e42efc16723e..0a1ed9ee1429 100755
> > > > > --- a/tools/perf/pmu-events/jevents.py
> > > > > +++ b/tools/perf/pmu-events/jevents.py
> > > > > @@ -1081,7 +1081,7 @@ const struct pmu_metrics_table *perf_pmu__find_metrics_table(struct perf_pmu *pm
> > > > > if (!map)
> > > > > return NULL;
> > > > >
> > > > > - if (!pmu)
> > > > > + if (!pmu || !map->metric_table.num_pmus)
> > > > > return &map->metric_table;
> > > > >
> > > > > for (size_t i = 0; i < map->metric_table.num_pmus; i++) {
> > > >
> >
next prev parent reply other threads:[~2024-07-15 15:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-31 19:44 [PATCH] perf jevents: return potentially empty metrics table Lucas Stach
2024-07-01 17:19 ` Lucas Stach
2024-07-03 22:33 ` Namhyung Kim
2024-07-12 21:54 ` Ian Rogers
2024-07-15 15:12 ` James Clark
2024-07-15 15:54 ` Lucas Stach [this message]
2024-07-15 21:43 ` Ian Rogers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ac1d9124e497a1667e7cbc340f923cb4449764bb.camel@pengutronix.de \
--to=l.stach@pengutronix.de \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=james.clark@arm.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=kernel@pengutronix.de \
--cc=leo.yan@linux.dev \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=patchwork-lst@pengutronix.de \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).