From: Ian Rogers <irogers@google.com>
To: John Garry <john.g.garry@oracle.com>
Cc: acme@kernel.org, namhyung@kernel.org, jolsa@kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
renyu.zj@linux.alibaba.com, shangxiaojing@huawei.com,
zhangshaokun@hisilicon.com, qiangqing.zhang@nxp.com,
kjain@linux.ibm.com, kan.liang@linux.intel.com
Subject: Re: [PATCH RFC 4/9] perf jevents: Add sys_events_find_events_table()
Date: Fri, 30 Jun 2023 13:16:52 -0700 [thread overview]
Message-ID: <CAP-5=fUs=u3PKYP3mVDdzNB8+=GAHaEXG3SGfWJpMELYYqO_hA@mail.gmail.com> (raw)
In-Reply-To: <CAP-5=fXa24_LEiyni0Ncyfa5hKwC1GE6y-zi2u8M98M9SwHX+g@mail.gmail.com>
On Fri, Jun 30, 2023 at 12:00 PM Ian Rogers <irogers@google.com> wrote:
>
> On Wed, Jun 28, 2023 at 3:30 AM John Garry <john.g.garry@oracle.com> wrote:
> >
> > Add a function to get the events table associated with a metric table for
> > struct pmu_sys_events.
> >
> > We could also use something like:
> > struct pmu_sys_events *sys = container_of(metrics, struct pmu_sys_events,
> > metric_table);
> >
> > to lookup struct pmu_sys_events, but that relies on the user always passing
> > a sys events metric struct pointer, so this way is safer, but slower.
>
> If an event is specific to a particular PMU, shouldn't the metric name
> the PMU with the event? For example:
>
> MetricName: "IPC",
> MetricExpr: "instructions / cycles",
>
> Here instructions and cycles can wildcard match on BIG.little/hybrid
> systems and so we get an IPC metric for each PMU - although, I suspect
> this isn't currently quite working. We can also, and currently, do:
>
> MetricName: "IPC",
> MetricExpr: "cpu_atom@instructions@ / cpu_atom@cycles@",
> ...
> MetricName: "IPC",
> MetricExpr: "cpu_core@instructions@ / cpu_core@cycles@",
>
> The @ is used to avoid parsing confusion with / meaning divide. The
> PMUs for the events are explicitly listed here. We could say the PMU
> is implied but then it gets complex for uncore events, for metrics
> that mix core and uncore events.
So looking at the later patches, they are making it so the PMU doesn't
need to be specified, so I think it is the same issue as here. My
thought was that the PMU would always be required for metrics like
memory bandwidth per million instructions, ie >1 PMU. I know this
makes the metrics longer, I've tried to avoid writing json metrics and
have used Python to write them in my own work:
https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/pmu-events/metric.py?h=perf-tools-next#n411
Thanks,
Ian
> Thanks,
> Ian
>
>
> > Signed-off-by: John Garry <john.g.garry@oracle.com>
> > ---
> > tools/perf/pmu-events/empty-pmu-events.c | 6 ++++++
> > tools/perf/pmu-events/jevents.py | 11 +++++++++++
> > tools/perf/pmu-events/pmu-events.h | 3 +++
> > 3 files changed, 20 insertions(+)
> >
> > diff --git a/tools/perf/pmu-events/empty-pmu-events.c b/tools/perf/pmu-events/empty-pmu-events.c
> > index a630c617e879..ae431b6bdf91 100644
> > --- a/tools/perf/pmu-events/empty-pmu-events.c
> > +++ b/tools/perf/pmu-events/empty-pmu-events.c
> > @@ -290,6 +290,12 @@ int pmu_metrics_table_for_each_metric(const struct pmu_metrics_table *table, pmu
> > return 0;
> > }
> >
> > +const struct pmu_events_table *
> > +sys_events_find_events_table(__maybe_unused const struct pmu_metrics_table *metrics)
> > +{
> > + return NULL;
> > +}
> > +
> > const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu)
> > {
> > const struct pmu_events_table *table = NULL;
> > diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
> > index 80b569b8634b..947e8b1efa26 100755
> > --- a/tools/perf/pmu-events/jevents.py
> > +++ b/tools/perf/pmu-events/jevents.py
> > @@ -786,6 +786,17 @@ int pmu_metrics_table_for_each_metric(const struct pmu_metrics_table *table,
> > return 0;
> > }
> >
> > +const struct pmu_events_table *
> > +sys_events_find_events_table(const struct pmu_metrics_table *metrics)
> > +{
> > + for (const struct pmu_sys_events *tables = &pmu_sys_event_tables[0];
> > + tables->name; tables++) {
> > + if (&tables->metric_table == metrics)
> > + return &tables->event_table;
> > + }
> > + return NULL;
> > +}
> > +
> > const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu)
> > {
> > const struct pmu_events_table *table = NULL;
> > diff --git a/tools/perf/pmu-events/pmu-events.h b/tools/perf/pmu-events/pmu-events.h
> > index caf59f23cd64..a3642c08e39d 100644
> > --- a/tools/perf/pmu-events/pmu-events.h
> > +++ b/tools/perf/pmu-events/pmu-events.h
> > @@ -77,6 +77,9 @@ typedef int (*pmu_metric_iter_fn)(const struct pmu_metric *pm,
> > const struct pmu_metrics_table *table,
> > void *data);
> >
> > +const struct pmu_events_table *
> > +sys_events_find_events_table(const struct pmu_metrics_table *metrics);
> > +
> > int pmu_events_table_for_each_event(const struct pmu_events_table *table, pmu_event_iter_fn fn,
> > void *data);
> > int pmu_metrics_table_for_each_metric(const struct pmu_metrics_table *table, pmu_metric_iter_fn fn,
> > --
> > 2.35.3
> >
next prev parent reply other threads:[~2023-06-30 20:17 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-28 10:29 [PATCH RFC 0/9] perf tool: sys event metric support re-write John Garry
2023-06-28 10:29 ` [PATCH RFC 1/9] perf metrics: Delete metricgroup_add_iter_data.table John Garry
2023-06-30 17:22 ` Ian Rogers
2023-06-28 10:29 ` [PATCH RFC 2/9] perf metrics: Don't iter sys metrics if we already found a CPU match John Garry
2023-06-30 17:41 ` Ian Rogers
2023-07-03 13:09 ` John Garry
2023-07-12 5:40 ` Ian Rogers
2023-07-12 9:37 ` John Garry
2023-06-28 10:29 ` [PATCH RFC 3/9] perf metrics: Pass cpu and sys tables to metricgroup__add_metric() John Garry
2023-06-30 18:39 ` Ian Rogers
2023-07-03 15:20 ` John Garry
2023-06-28 10:29 ` [PATCH RFC 4/9] perf jevents: Add sys_events_find_events_table() John Garry
2023-06-30 19:00 ` Ian Rogers
2023-06-30 20:16 ` Ian Rogers [this message]
2023-07-03 15:15 ` John Garry
2023-07-12 6:05 ` Ian Rogers
2023-07-12 10:55 ` John Garry
2023-07-12 17:52 ` Ian Rogers
2023-07-13 15:06 ` John Garry
2023-07-13 21:35 ` Ian Rogers
2023-07-14 11:58 ` John Garry
2023-07-14 15:55 ` Ian Rogers
2023-07-17 7:41 ` John Garry
2023-07-17 21:39 ` Ian Rogers
2023-07-18 9:32 ` John Garry
2023-07-19 15:25 ` Ian Rogers
2023-07-19 15:36 ` John Garry
2023-07-19 15:49 ` Ian Rogers
2023-07-19 20:07 ` Arnaldo Carvalho de Melo
2023-06-28 10:29 ` [PATCH RFC 5/9] perf pmu: Refactor pmu_add_sys_aliases_iter_fn() John Garry
2023-06-28 10:29 ` [PATCH RFC 6/9] perf metrics: Add metricgroup_sys_metric_supported() John Garry
2023-06-28 10:29 ` [PATCH RFC 7/9] perf metrics: Test metric match in metricgroup__sys_event_iter() John Garry
2023-06-28 10:29 ` [PATCH RFC 8/9] perf metrics: Stop metricgroup__add_metric_sys_event_iter if already matched John Garry
2023-06-28 10:29 ` [PATCH RFC 9/9] perf vendor events arm64: Remove unnecessary metric Unit and Compat specifiers John Garry
2023-06-29 22:08 ` [PATCH RFC 0/9] perf tool: sys event metric support re-write Namhyung Kim
2023-06-30 9:35 ` John Garry
2023-06-30 21:07 ` Namhyung Kim
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='CAP-5=fUs=u3PKYP3mVDdzNB8+=GAHaEXG3SGfWJpMELYYqO_hA@mail.gmail.com' \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=john.g.garry@oracle.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=kjain@linux.ibm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=namhyung@kernel.org \
--cc=qiangqing.zhang@nxp.com \
--cc=renyu.zj@linux.alibaba.com \
--cc=shangxiaojing@huawei.com \
--cc=zhangshaokun@hisilicon.com \
/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).