From: "Falcon, Thomas" <thomas.falcon@intel.com>
To: "namhyung@kernel.org" <namhyung@kernel.org>
Cc: "Liang, Kan" <kan.liang@intel.com>,
"alexander.shishkin@linux.intel.com"
<alexander.shishkin@linux.intel.com>,
"peterz@infradead.org" <peterz@infradead.org>,
"acme@kernel.org" <acme@kernel.org>,
"linux-perf-users@vger.kernel.org"
<linux-perf-users@vger.kernel.org>,
"mingo@redhat.com" <mingo@redhat.com>,
"Hunter, Adrian" <adrian.hunter@intel.com>,
"irogers@google.com" <irogers@google.com>,
"jolsa@kernel.org" <jolsa@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kan.liang@linux.intel.com" <kan.liang@linux.intel.com>,
"mark.rutland@arm.com" <mark.rutland@arm.com>
Subject: Re: [PATCH v4] perf script: Fix output type for dynamically allocated core PMU's
Date: Mon, 3 Mar 2025 22:13:39 +0000 [thread overview]
Message-ID: <def6d16033e732ebf158f6936be41794b95a811d.camel@intel.com> (raw)
In-Reply-To: <Z8YcOidenzGofq7R@google.com>
On Mon, 2025-03-03 at 13:16 -0800, Namhyung Kim wrote:
> Hello,
>
> On Wed, Feb 26, 2025 at 11:00:43AM -0600, Thomas Falcon wrote:
> > This patch was originally posted here:
> >
> > https://lore.kernel.org/all/20241213215421.661139-1-thomas.falcon@intel.com/
> >
> > I have rebased on top of Arnaldo's patch here:
> >
> > https://lore.kernel.org/all/Z2XCi3PgstSrV0SE@x1/
> >
> > The original commit message:
> > "
> > perf script output may show different fields on different core
> > PMU's
> > that exist on heterogeneous platforms. For example,
> >
> > perf record -e "{cpu_core/mem-loads-aux/,cpu_core/event=0xcd,\
> > umask=0x01,ldlat=3,name=MEM_UOPS_RETIRED.LOAD_LATENCY/}:upp"\
> > -c10000 -W -d -a -- sleep 1
> >
> > perf script:
> >
> > chromium-browse 46572 [002] 544966.882384:
> > 10000 cpu_core/MEM_UOPS_RETIRED.LOAD_LATENCY/: 7ffdf1391b0c 10268100142\
> > |OP LOAD|LVL L1 hit|SNP None|TLB L1 or L2 hit|LCK No|BLK N/A
> > 5 7 0 7fad7c47425d [unknown] (/usr/lib64/libglib-
> > 2.0.so.0.8000.3)
> >
> > perf record -e cpu_atom/event=0xd0,umask=0x05,ldlat=3,\
> > name=MEM_UOPS_RETIRED.LOAD_LATENCY/upp -c10000 -W -d -a -- sleep 1
> >
> > perf script:
> >
> > gnome-control-c 534224 [023] 544951.816227: 10000
> > cpu_atom/MEM_UOPS_RETIRED.LOAD_LATENCY/: 7f0aaaa0aae0 [unknown]
> > (/usr/lib64/libglib-2.0.so.0.8000.3)
> >
> > Some fields, such as data_src, are not included by default.
> >
> > The cause is that while one PMU may be assigned a type such as
> > PERF_TYPE_RAW, other core PMU's are dynamically allocated at boot
> > time.
> > If this value does not match an existing PERF_TYPE_X value,
> > output_type(perf_event_attr.type) will return OUTPUT_TYPE_OTHER.
> >
> > Instead search for a core PMU with a matching perf_event_attr type
> > and, if one is found, return PERF_TYPE_RAW to match output of other
> > core PMU's.
> > "
> >
> > Suggested-by: Kan Liang <kan.liang@intel.com>
> > Signed-off-by: Thomas Falcon <thomas.falcon@intel.com>
> > ---
> > v2: restrict pmu lookup to platforms with more than one core pmu
> > v3: only scan core pmu list
> > v4: rebase on top of Arnaldo's patch
> > ---
> > tools/perf/builtin-script.c | 22 ++++++++++++++++++++--
> > 1 file changed, 20 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-
> > script.c
> > index d797cec4f054..abc860d01420 100644
> > --- a/tools/perf/builtin-script.c
> > +++ b/tools/perf/builtin-script.c
> > @@ -398,10 +398,28 @@ static inline int output_type(unsigned int
> > type)
> > return OUTPUT_TYPE_OTHER;
> > }
> >
> > +static bool output_type_check_core_pmus(unsigned int type)
>
> How about renaming to is_core_pmu_type() ?
>
> > +{
> > + struct perf_pmu *pmu = NULL;
> > +
> > + if (perf_pmus__num_core_pmus() > 1) {
> > + while ((pmu = perf_pmus__scan_core(pmu)) != NULL)
> > {
> > + if (pmu->type == type)
> > + return true;
> > + }
> > + }
> > + return false;
>
> To be more generic, it could be
>
> return type == PERF_TYPE_RAW;
>
> > +}
> > +
> > static inline int evsel__output_type(struct evsel *evsel)
> > {
> > - if (evsel->script_output_type == OUTPUT_TYPE_UNSET)
> > - evsel->script_output_type = output_type(evsel-
> > >core.attr.type);
> > + if (evsel->script_output_type == OUTPUT_TYPE_UNSET) {
> > + if (output_type(evsel->core.attr.type) ==
> > OUTPUT_TYPE_OTHER &&
> > + output_type_check_core_pmus(evsel-
> > >core.attr.type))
> > + evsel->script_output_type = PERF_TYPE_RAW;
> > + else
> > + evsel->script_output_type =
> > output_type(evsel->core.attr.type);
> > + }
>
> It seems better to put this logic inside output_type().
>
> Thanks,
> Namhyung
>
Thanks, will send a new version soon.
Tom
> >
> > return evsel->script_output_type;
> > }
> > --
> > 2.48.1
> >
>
prev parent reply other threads:[~2025-03-03 22:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-26 17:00 [PATCH v4] perf script: Fix output type for dynamically allocated core PMU's Thomas Falcon
2025-03-03 21:16 ` Namhyung Kim
2025-03-03 22:13 ` Falcon, Thomas [this message]
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=def6d16033e732ebf158f6936be41794b95a811d.camel@intel.com \
--to=thomas.falcon@intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@intel.com \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--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