linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: "Falcon, Thomas" <thomas.falcon@intel.com>
Cc: "ravi.bangoria@amd.com" <ravi.bangoria@amd.com>,
	"alexander.shishkin@linux.intel.com"
	<alexander.shishkin@linux.intel.com>,
	"linux-perf-users@vger.kernel.org"
	<linux-perf-users@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"mark.rutland@arm.com" <mark.rutland@arm.com>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"Hunter, Adrian" <adrian.hunter@intel.com>,
	"namhyung@kernel.org" <namhyung@kernel.org>,
	"jolsa@kernel.org" <jolsa@kernel.org>,
	"kan.liang@linux.intel.com" <kan.liang@linux.intel.com>,
	"irogers@google.com" <irogers@google.com>
Subject: Re: [PATCH v3] perf script: Fix output type for dynamically allocated core PMU's
Date: Fri, 20 Dec 2024 17:37:25 -0300	[thread overview]
Message-ID: <Z2XVhey0Xg5yYoQa@x1> (raw)
In-Reply-To: <d730cfe63cdd46c137630d27de32e3b9c0ab6268.camel@intel.com>

On Fri, Dec 20, 2024 at 08:30:11PM +0000, Falcon, Thomas wrote:
> On Fri, 2024-12-20 at 16:16 -0300, Arnaldo Carvalho de Melo wrote:
> > On Fri, Dec 13, 2024 at 03:54:21PM -0600, Thomas Falcon wrote:
> > > 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
> > > ---
> > >  tools/perf/builtin-script.c | 16 ++++++++++++++++
> > >  1 file changed, 16 insertions(+)
> > > 
> > > diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-
> > > script.c
> > > index 9e47905f75a6..685232883f9c 100644
> > > --- a/tools/perf/builtin-script.c
> > > +++ b/tools/perf/builtin-script.c
> > > @@ -384,6 +384,19 @@ static int evsel_script__fprintf(struct
> > > evsel_script *es, FILE *fp)
> > >  		       st.st_size / 1024.0 / 1024.0, es->filename,
> > > es->samples);
> > >  }
> > >  
> > > +static bool output_type_many_core_pmus(unsigned int 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;
> > > +}
> > > +
> > >  static inline int output_type(unsigned int type)
> > >  {
> > >  	switch (type) {
> > > @@ -394,6 +407,9 @@ static inline int output_type(unsigned int
> > > type)
> > >  			return type;
> > >  	}
> > >  
> > > +	if (output_type_many_core_pmus(type))
> > > +		return PERF_TYPE_RAW;
> > > +
> > >  	return OUTPUT_TYPE_OTHER;
> > >  }
> > 
> > Can you please test the patch below so that we don't do this while
> > loop
> > in all calls to output_type when we have more than one core pmu?
> > 
> > I haven't tested this patch, so please see if your patch on top of it
> > produces the desired result.
> 
> Hi Arnaldo, it looks good to me.

Thanks, added an

Acked-by: Thomas Falcon <thomas.falcon@intel.com>

To that cset,

Doing some test build test accross a number of distros now, will push
that out and then try to see if your patch applies cleanly or do the
adjustment to apply it.

- Arnaldo

  reply	other threads:[~2024-12-20 20:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-13 21:54 [PATCH v3] perf script: Fix output type for dynamically allocated core PMU's Thomas Falcon
2024-12-16 15:38 ` Liang, Kan
2024-12-20 19:16 ` Arnaldo Carvalho de Melo
2024-12-20 20:30   ` Falcon, Thomas
2024-12-20 20:37     ` Arnaldo Carvalho de Melo [this message]
2025-02-24 18:57       ` Falcon, Thomas

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=Z2XVhey0Xg5yYoQa@x1 \
    --to=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@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 \
    --cc=ravi.bangoria@amd.com \
    --cc=thomas.falcon@intel.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).