Re: [PATCH] perf vendor events: Initial json/events list for power10 platform

2021-04-18 Thread Paul A. Clarke
On Sat, Apr 17, 2021 at 02:48:50PM +0530, Kajol Jain wrote:
> Patch adds initial json/events for POWER10.

I was able to apply, build, and run perf with these changes,
and every new event at least ran successfully with
`perf stat`.

Pedantically, there is a lot of inconsistency as to whether
the `BriefDescription` ends with a period or not, and whether
there is an extra space at the end.

Regardless, LGTM.

Tested-by: Paul A. Clarke 
Reviewed-by: Paul A. Clarke 

PC


RE: [PATCH v2 0/6] perf arm64 metricgroup support

2021-04-06 Thread Paul A. Clarke
On Tue, Apr 06, 2021 at 12:02:36PM +0100, John Garry wrote:
> On 30/03/2021 07:41, kajoljain wrote:
> > On 3/30/21 2:37 AM, Paul A. Clarke wrote:
> > > On Fri, Mar 26, 2021 at 10:57:40AM +, John Garry wrote:
> > > > On 25/03/2021 20:39, Paul A. Clarke wrote:
> > > > > On Thu, Mar 25, 2021 at 06:33:12PM +0800, John Garry wrote:
> > > > > > Metric reuse support is added for pmu-events parse metric testcase.
> > > > > > This had been broken on power9 recentlty:
> > > > > > https://lore.kernel.org/lkml/20210324015418.gc8...@li-24c3614c-2adc-11b2-a85c-85f334518bdb.ibm.com/
> > > > > 
> > > > > Much better.  Before:
> > > > > --
> > > > > $ perf test -v 10 2>&1 | grep -i error | wc -l
> > > > > 112
> > > > > --
> > > > > After:
> > > > > --
> > > > > $ perf test -v 10 2>&1 | grep -i error | wc -l
> > > > > 17
> > > > > --
> > > > > 
> > > > > And these seem like different types of issues:
> > > > > --
> > > > > $ perf test -v 10 2>&1 | grep -i error
> > > > > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel 
> > > > > support?' help '(null)'
> > > > > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel 
> > > > > support?' help '(null)'
> > > > > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel 
> > > > > support?' help '(null)'
> > > > > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel 
> > > > > support?' help '(null)'
> > > > > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel 
> > > > > support?' help '(null)'
> > > > > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel 
> > > > > support?' help '(null)'
> > > > > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel 
> > > > > support?' help '(null)'
> > > > > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel 
> > > > > support?' help '(null)'
> > > > > Error string 'Cannot find PMU `nest_powerbus0_imc'. Missing kernel 
> > > > > support?' help '(null)'
> > > > > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel 
> > > > > support?' help '(null)'
> > > > > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel 
> > > > > support?' help '(null)'
> > > > > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel 
> > > > > support?' help '(null)'
> > > > > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel 
> > > > > support?' help '(null)'
> > > > > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel 
> > > > > support?' help '(null)'
> > > > > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel 
> > > > > support?' help '(null)'
> > > > > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel 
> > > > > support?' help '(null)'
> > > > > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel 
> > > > > support?' help '(null)'
> > > > > --
> > > > > 
> > > > 
> > > > This looks suspicious.
> > > > 
> > > > Firstly, does /sys/bus/event_source/devices/nest_mcs01_imc (or others,
> > > > above) exist on your system? I guess not.
> > > > 
> > > > Secondly, checking Documentation/powerpc/imc.rst, we have examples of:
> > > > nest_mcs01/PM_MCS01_64B_R...
> > > > 
> > > > So is the PMU name correct in the metric file for nest_mcs01_imc? 
> > > > Looking at
> > > > the kernel driver file, arch/powerpc/perf/imc-pmu.c, it seems to be 
> > > > correct.
> > > > Not sure.
> > > 
> > > I ran with a newer kernel, and the above errors disappeared, replaced with
> > > about 10 of:
> > > --
> > > Error string 'Cannot find PMU `hv_24x7'. Missing kernel support?' help 
> > > '(null)'
> > > --
> > > 
> > > ...but I was running without a hypervisor, so I tried the same kernel on a
> > > PowerVM-virtualized system and the "hv_24x7" messages went away, but the
> > > "nest" messages returned.  This may all be expected behavior... I confess
> > > I haven't followed these new perf capabilities closely.
> > > 
> > 
> > Hi Paul/John,
> > This is something expected. For nest-imc we need bare-metal system and 
> > for
> > hv-24x7 we need VM environment. Since you are checking this test in VM 
> > machine,
> > there nest events are not supported and hence we are getting this error.
> > 
> > Thanks,
> > Kajol Jain
> 
> Cool, so I hope that tested-by or similar can be provided :) [obviously
> pending any changes that come from reviews]

Certainly!

Tested-by: Paul A. Clarke 

PC


RE: [PATCH v2 0/6] perf arm64 metricgroup support

2021-03-29 Thread Paul A. Clarke
On Fri, Mar 26, 2021 at 10:57:40AM +, John Garry wrote:
> On 25/03/2021 20:39, Paul A. Clarke wrote:
> > On Thu, Mar 25, 2021 at 06:33:12PM +0800, John Garry wrote:
> > > Metric reuse support is added for pmu-events parse metric testcase.
> > > This had been broken on power9 recentlty:
> > > https://lore.kernel.org/lkml/20210324015418.gc8...@li-24c3614c-2adc-11b2-a85c-85f334518bdb.ibm.com/
> > 
> > Much better.  Before:
> > --
> > $ perf test -v 10 2>&1 | grep -i error | wc -l
> > 112
> > --
> > After:
> > --
> > $ perf test -v 10 2>&1 | grep -i error | wc -l
> > 17
> > --
> > 
> > And these seem like different types of issues:
> > --
> > $ perf test -v 10 2>&1 | grep -i error
> > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_powerbus0_imc'. Missing kernel 
> > support?' help '(null)'
> > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' 
> > help '(null)'
> > --
> > 
> 
> This looks suspicious.
> 
> Firstly, does /sys/bus/event_source/devices/nest_mcs01_imc (or others,
> above) exist on your system? I guess not.
> 
> Secondly, checking Documentation/powerpc/imc.rst, we have examples of:
> nest_mcs01/PM_MCS01_64B_R...
> 
> So is the PMU name correct in the metric file for nest_mcs01_imc? Looking at
> the kernel driver file, arch/powerpc/perf/imc-pmu.c, it seems to be correct.
> Not sure.

I ran with a newer kernel, and the above errors disappeared, replaced with
about 10 of:
--
Error string 'Cannot find PMU `hv_24x7'. Missing kernel support?' help '(null)'
--

...but I was running without a hypervisor, so I tried the same kernel on a
PowerVM-virtualized system and the "hv_24x7" messages went away, but the
"nest" messages returned.  This may all be expected behavior... I confess
I haven't followed these new perf capabilities closely.

It's extremely likely that none of these errors has anything to do with your
changes. :-)

PC


RE: [PATCH v2 0/6] perf arm64 metricgroup support

2021-03-26 Thread Paul A. Clarke
On Fri, Mar 26, 2021 at 10:57:40AM +, John Garry wrote:
> On 25/03/2021 20:39, Paul A. Clarke wrote:
> > On Thu, Mar 25, 2021 at 06:33:12PM +0800, John Garry wrote:
> > > Metric reuse support is added for pmu-events parse metric testcase.
> > > This had been broken on power9 recentlty:
> > > https://lore.kernel.org/lkml/20210324015418.gc8...@li-24c3614c-2adc-11b2-a85c-85f334518bdb.ibm.com/
> > 
> > Much better.  Before:
> > --
> > $ perf test -v 10 2>&1 | grep -i error | wc -l
> > 112
> > --
> > After:
> > --
> > $ perf test -v 10 2>&1 | grep -i error | wc -l
> > 17
> > --
> > 
> > And these seem like different types of issues:
> > --
> > $ perf test -v 10 2>&1 | grep -i error
> > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_powerbus0_imc'. Missing kernel 
> > support?' help '(null)'
> > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' 
> > help '(null)'
> > Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' 
> > help '(null)'
> > --
> > 
> 
> This looks suspicious.
> 
> Firstly, does /sys/bus/event_source/devices/nest_mcs01_imc (or others,
> above) exist on your system? I guess not.
> 
> Secondly, checking Documentation/powerpc/imc.rst, we have examples of:
> nest_mcs01/PM_MCS01_64B_R...
> 
> So is the PMU name correct in the metric file for nest_mcs01_imc? Looking at
> the kernel driver file, arch/powerpc/perf/imc-pmu.c, it seems to be correct.
> Not sure.

This may be caused by me testing a new perf on an older kernel. Let me retest.

PC


Re: [PATCH v2 0/6] perf arm64 metricgroup support

2021-03-25 Thread Paul A. Clarke
On Thu, Mar 25, 2021 at 06:33:12PM +0800, John Garry wrote:
> Metric reuse support is added for pmu-events parse metric testcase.
> This had been broken on power9 recentlty:
> https://lore.kernel.org/lkml/20210324015418.gc8...@li-24c3614c-2adc-11b2-a85c-85f334518bdb.ibm.com/

Much better.  Before:
--
$ perf test -v 10 2>&1 | grep -i error | wc -l
112
--
After:
--
$ perf test -v 10 2>&1 | grep -i error | wc -l
17
--

And these seem like different types of issues:
--
$ perf test -v 10 2>&1 | grep -i error
Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' help 
'(null)'
Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' help 
'(null)'
Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' help 
'(null)'
Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' help 
'(null)'
Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' help 
'(null)'
Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' help 
'(null)'
Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' help 
'(null)'
Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' help 
'(null)'
Error string 'Cannot find PMU `nest_powerbus0_imc'. Missing kernel support?' 
help '(null)'
Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' help 
'(null)'
Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' help 
'(null)'
Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' help 
'(null)'
Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' help 
'(null)'
Error string 'Cannot find PMU `nest_mcs01_imc'. Missing kernel support?' help 
'(null)'
Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' help 
'(null)'
Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' help 
'(null)'
Error string 'Cannot find PMU `nest_mcs23_imc'. Missing kernel support?' help 
'(null)'
--

(Added Kajol Jain to CC)

PC


RE: [PATCHv4 00/19] perf metric: Add support to reuse metric

2021-03-23 Thread Paul A. Clarke
On Tue, Mar 23, 2021 at 03:15:16PM +, John Garry wrote:
> On 23/03/2021 15:06, Paul A. Clarke wrote:
> > On Mon, Mar 22, 2021 at 11:36:23AM +, John Garry wrote:
> > > On 01/08/2020 12:40, Paul A. Clarke wrote:
> > > > > v4 changes:
> > > > > - removed acks from patch because it changed a bit
> > > > >   with the last fixes:
> > > > > perf metric: Collect referenced metrics in struct 
> > > > > metric_ref_node
> > > > > - fixed runtime metrics [Kajol Jain]
> > > > > - increased recursion depth [Paul A. Clarke]
> > > > > - changed patches due to dependencies:
> > > > > perf metric: Collect referenced metrics in struct 
> > > > > metric_ref_node
> > > > > perf metric: Add recursion check when processing nested 
> > > > > metrics
> > > > > perf metric: Rename struct egroup to metric
> > > > > perf metric: Rename group_list to metric_list
> > > > > 
> > > > > Also available in here:
> > > > > git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
> > > > > perf/metric
> > > > I built and ran from the above git branch, and things seem to work.
> > > > Indeed, I was able to apply my changes to exploit the new capabilities
> > > > via modifications to 
> > > > tools/perf/pmu-events/arch/powerpc/power9/metrics.json,
> > > > as I posted earlier (and will submit once this set gets merged).
> > > I was just wondering: Does perf subtest 10.3 work ok for you with the 
> > > metric
> > > reuse?
> > > 
> > > That's "Parsing of PMU event table metrics" subtest.
> > I confess I'm not sure what you are asking. Using the latest mainline
> > (84196390620ac0e5070ae36af84c137c6216a7dc), perf subtest 10.3 does
> > pass for me:
> > --
> > $ ./perf test 10
> > 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
> > --
> Since commit 8989f5f07605 ("perf stat: Update POWER9 metrics to utilize
> other metrics"), power9 has reused metrics.
> 
> And I am finding that subtest 10.3 caused problems when I tried to introduce
> metric reuse on arm64, so I was just asking you to check.
> 
> Now I am a bit confused...

I now understand your original request! :-)

The above test was run on a POWER8 system.

I do see failures on a POWER9 system:
--
$ ./perf test 10
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: Skip 
(some metrics failed)
10.4: Parsing of PMU event table metrics with fake PMUs : Ok
$ ./perf test --verbose 10 2>&1 | grep -i '^Parse event failed' | wc -l
112
--

PC


RE: [PATCHv4 00/19] perf metric: Add support to reuse metric

2021-03-23 Thread Paul A. Clarke
On Mon, Mar 22, 2021 at 11:36:23AM +, John Garry wrote:
> On 01/08/2020 12:40, Paul A. Clarke wrote:
> > > v4 changes:
> > >- removed acks from patch because it changed a bit
> > >  with the last fixes:
> > >perf metric: Collect referenced metrics in struct metric_ref_node
> > >- fixed runtime metrics [Kajol Jain]
> > >- increased recursion depth [Paul A. Clarke]
> > >- changed patches due to dependencies:
> > >perf metric: Collect referenced metrics in struct metric_ref_node
> > >perf metric: Add recursion check when processing nested metrics
> > >perf metric: Rename struct egroup to metric
> > >perf metric: Rename group_list to metric_list
> > > 
> > > Also available in here:
> > >git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
> > >perf/metric
> > I built and ran from the above git branch, and things seem to work.
> > Indeed, I was able to apply my changes to exploit the new capabilities
> > via modifications to tools/perf/pmu-events/arch/powerpc/power9/metrics.json,
> > as I posted earlier (and will submit once this set gets merged).

> I was just wondering: Does perf subtest 10.3 work ok for you with the metric
> reuse?
> 
> That's "Parsing of PMU event table metrics" subtest.

I confess I'm not sure what you are asking. Using the latest mainline
(84196390620ac0e5070ae36af84c137c6216a7dc), perf subtest 10.3 does
pass for me:
--
$ ./perf test 10
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
--

PC


[PATCH] [perf] powerpc: Remove unsupported metrics

2021-02-24 Thread Paul A. Clarke
Several metrics are defined based on unsupported / non-existent
events, and silently discarded.  Remove them for good code hygiene
and to avoid confusion.

Signed-off-by: Paul A. Clarke 
---
 .../arch/powerpc/power9/metrics.json  | 132 --
 1 file changed, 132 deletions(-)

diff --git a/tools/perf/pmu-events/arch/powerpc/power9/metrics.json 
b/tools/perf/pmu-events/arch/powerpc/power9/metrics.json
index f8784c608479..140402d2855f 100644
--- a/tools/perf/pmu-events/arch/powerpc/power9/metrics.json
+++ b/tools/perf/pmu-events/arch/powerpc/power9/metrics.json
@@ -1209,156 +1209,24 @@
 "MetricGroup": "instruction_stats_percent_per_ref",
 "MetricName": "inst_from_rmem_percent"
 },
-{
-"BriefDescription": "%L2 Modified CO Cache read Utilization (4 pclks 
per disp attempt)",
-"MetricExpr": "((PM_L2_CASTOUT_MOD/2)*4)/ PM_RUN_CYC * 100",
-"MetricGroup": "l2_stats",
-"MetricName": "l2_co_m_rd_util"
-},
-{
-"BriefDescription": "L2 dcache invalidates per run inst (per core)",
-"MetricExpr": "(PM_L2_DC_INV / 2) / PM_RUN_INST_CMPL * 100",
-"MetricGroup": "l2_stats",
-"MetricName": "l2_dc_inv_rate_percent"
-},
 {
 "BriefDescription": "Demand load misses as a % of L2 LD dispatches 
(per thread)",
 "MetricExpr": "PM_L1_DCACHE_RELOAD_VALID / (PM_L2_LD / 2) * 100",
 "MetricGroup": "l2_stats",
 "MetricName": "l2_dem_ld_disp_percent"
 },
-{
-"BriefDescription": "L2 Icache invalidates per run inst (per core)",
-"MetricExpr": "(PM_L2_IC_INV / 2) / PM_RUN_INST_CMPL * 100",
-"MetricGroup": "l2_stats",
-"MetricName": "l2_ic_inv_rate_percent"
-},
-{
-"BriefDescription": "L2 Inst misses as a % of total L2 Inst dispatches 
(per thread)",
-"MetricExpr": "PM_L2_INST_MISS / PM_L2_INST * 100",
-"MetricGroup": "l2_stats",
-"MetricName": "l2_inst_miss_ratio_percent"
-},
-{
-"BriefDescription": "Average number of cycles between L2 Load hits",
-"MetricExpr": "(PM_L2_LD_HIT / PM_RUN_CYC) / 2",
-"MetricGroup": "l2_stats",
-"MetricName": "l2_ld_hit_frequency"
-},
-{
-"BriefDescription": "Average number of cycles between L2 Load misses",
-"MetricExpr": "(PM_L2_LD_MISS / PM_RUN_CYC) / 2",
-"MetricGroup": "l2_stats",
-"MetricName": "l2_ld_miss_frequency"
-},
-{
-"BriefDescription": "L2 Load misses as a % of total L2 Load dispatches 
(per thread)",
-"MetricExpr": "PM_L2_LD_MISS / PM_L2_LD * 100",
-"MetricGroup": "l2_stats",
-"MetricName": "l2_ld_miss_ratio_percent"
-},
-{
-"BriefDescription": "% L2 load disp attempts Cache read Utilization (4 
pclks per disp attempt)",
-"MetricExpr": "((PM_L2_RCLD_DISP/2)*4)/ PM_RUN_CYC * 100",
-"MetricGroup": "l2_stats",
-"MetricName": "l2_ld_rd_util"
-},
-{
-"BriefDescription": "L2 load misses that require a cache write (4 
pclks per disp attempt) % of pclks",
-"MetricExpr": "((( PM_L2_LD_DISP - PM_L2_LD_HIT)/2)*4)/ PM_RUN_CYC * 
100",
-"MetricGroup": "l2_stats",
-"MetricName": "l2_ldmiss_wr_util"
-},
-{
-"BriefDescription": "L2 local pump prediction success",
-"MetricExpr": "PM_L2_LOC_GUESS_CORRECT / (PM_L2_LOC_GUESS_CORRECT + 
PM_L2_LOC_GUESS_WRONG) * 100",
-"MetricGroup": "l2_stats",
-"MetricName": "l2_local_pred_correct_percent"
-},
-{
-"BriefDescription": "L2 COs that were in M,Me,Mu state as a % of all 
L2 COs",
-"MetricExpr": "PM_L2_CASTOUT_MOD / (PM_L2_CASTOUT_MOD + 
PM_L2_CASTOUT_SHR) * 100",
-"MetricGroup": "l2_stats",
-"MetricName": "l2_mod_co_percent"
-},
-{
-"BriefDescription": "% of L2 Load RC dispatch atampts that failed 
because of address collisions and cclass conf

Re: [RFC PATCH 0/7] Share events between metrics

2020-12-15 Thread Paul A. Clarke
On Thu, May 07, 2020 at 10:43:43PM -0700, Ian Rogers wrote:
> On Thu, May 7, 2020 at 2:47 PM Andi Kleen  wrote:
> >
> > > > - without this change events within a metric may get scheduled
> > > >   together, after they may appear as part of a larger group and be
> > > >   multiplexed at different times, lowering accuracy - however, less
> > > >   multiplexing may compensate for this.

Does mutiplexing somewhat related events at different times actually reduce
accuracy, or is it just more likely to give that appearance?

It seems that perf measurements are only useful if the workload is in a
fairly steady state.  If there is some wobbling, then measuring at the
same time is more accurate for the periods where the events are being
measured simultaneously, but may be far off for when they are not being
measured at all.  Spreading them out over a longer duration may actually
increase accuracy by sampling over more varied intervals.

Or, is the concern more about trying to time-slice the results in a 
fairly granular way and expecting accurate results then?

(Or, maybe my ignorance is showing again.  :-)

PC


Re: [PATCH] perf stat: update POWER9 metrics to utilize other metrics

2020-08-26 Thread Paul A. Clarke
On Wed, Aug 26, 2020 at 09:26:40AM -0700, Ian Rogers wrote:
> On Fri, Aug 14, 2020 at 5:43 AM Arnaldo Carvalho de Melo
>  wrote:
> > Em Fri, Aug 14, 2020 at 11:20:42AM +0530, kajoljain escreveu:
> > > On 8/14/20 9:13 AM, Ian Rogers wrote:
> > > > On Thu, Aug 13, 2020 at 3:21 PM Paul A. Clarke  wrote:
> > > >> These changes take advantage of the new capability added in
> > > >> merge commit 00e4db51259a5f936fec1424b884f029479d3981
> > > >> "Allow using computed metrics in calculating other metrics".
> > > >>
> > > >> The net is a simplification of the expressions for a handful
> > > >> of metrics, but no functional change.
> > > >>
> > > >> Signed-off-by: Paul A. Clarke 
> > >
> > >   The patch looks good to me.
> > >
> > > Reviewed-by: Kajol Jain
> >
> > Thanks, applied. Added Ian's Acked-by as well.
> 
> I've synced perf and testing on a remote machine (not easy for me to
> log into) I see failures in perf test "10.3: Parsing of PMU event
> table metrics" like:
> ...
> parsing metric: dfu_stall_cpi - dflong_stall_cpi
> Parse event failed metric 'dfu_other_stall_cpi' id 'dflong_stall_cpi'
> expr 'dfu_stall_cpi - dflong_stall_cpi'
> Error string 'parser error' help '(null)'
> Parse event failed metric 'dfu_other_stall_cpi' id 'dfu_stall_cpi'
> expr 'dfu_stall_cpi - dflong_stall_cpi'
> Error string 'parser error' help '(null)'
> ...
> 
> This may be that the test doesn't handle the metric in terms of metric
> addition and so I'll look for a fix. I thought I'd send a heads up in
> case you had already seen/addressed this. Is perf test on PowerPC
> clean for you at the moment?

I see these errors as well (on 5.9-rc2).  Each error seems to be for the
newer metrics that take advantage of the newer functionality, including
the metrics I changed recently, and Kajol's 24x7 and nest metrics.

Thanks for the heads up!  I confess I had not seen the errors only because
I wasn't looking.  :-/

PC


[PATCH] perf stat: update POWER9 metrics to utilize other metrics

2020-08-13 Thread Paul A. Clarke
These changes take advantage of the new capability added in
merge commit 00e4db51259a5f936fec1424b884f029479d3981
"Allow using computed metrics in calculating other metrics".

The net is a simplification of the expressions for a handful
of metrics, but no functional change.

Signed-off-by: Paul A. Clarke 
---
 .../arch/powerpc/power9/metrics.json  | 48 +--
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/tools/perf/pmu-events/arch/powerpc/power9/metrics.json 
b/tools/perf/pmu-events/arch/powerpc/power9/metrics.json
index 80816d6402e9..f8784c608479 100644
--- a/tools/perf/pmu-events/arch/powerpc/power9/metrics.json
+++ b/tools/perf/pmu-events/arch/powerpc/power9/metrics.json
@@ -60,7 +60,7 @@
 },
 {
 "BriefDescription": "Stalls due to short latency decimal floating 
ops.",
-"MetricExpr": "(PM_CMPLU_STALL_DFU - 
PM_CMPLU_STALL_DFLONG)/PM_RUN_INST_CMPL",
+"MetricExpr": "dfu_stall_cpi - dflong_stall_cpi",
 "MetricGroup": "cpi_breakdown",
 "MetricName": "dfu_other_stall_cpi"
 },
@@ -72,7 +72,7 @@
 },
 {
 "BriefDescription": "Completion stall by Dcache miss which resolved 
off node memory/cache",
-"MetricExpr": "(PM_CMPLU_STALL_DMISS_L3MISS - 
PM_CMPLU_STALL_DMISS_L21_L31 - PM_CMPLU_STALL_DMISS_LMEM - 
PM_CMPLU_STALL_DMISS_REMOTE)/PM_RUN_INST_CMPL",
+"MetricExpr": "dmiss_non_local_stall_cpi - dmiss_remote_stall_cpi",
 "MetricGroup": "cpi_breakdown",
 "MetricName": "dmiss_distant_stall_cpi"
 },
@@ -90,7 +90,7 @@
 },
 {
 "BriefDescription": "Completion stall due to cache miss that resolves 
in the L2 or L3 without conflict",
-"MetricExpr": "(PM_CMPLU_STALL_DMISS_L2L3 - 
PM_CMPLU_STALL_DMISS_L2L3_CONFLICT)/PM_RUN_INST_CMPL",
+"MetricExpr": "dmiss_l2l3_stall_cpi - dmiss_l2l3_conflict_stall_cpi",
 "MetricGroup": "cpi_breakdown",
 "MetricName": "dmiss_l2l3_noconflict_stall_cpi"
 },
@@ -114,7 +114,7 @@
 },
 {
 "BriefDescription": "Completion stall by Dcache miss which resolved 
outside of local memory",
-"MetricExpr": "(PM_CMPLU_STALL_DMISS_L3MISS - 
PM_CMPLU_STALL_DMISS_L21_L31 - PM_CMPLU_STALL_DMISS_LMEM)/PM_RUN_INST_CMPL",
+"MetricExpr": "dmiss_l3miss_stall_cpi - dmiss_l21_l31_stall_cpi - 
dmiss_lmem_stall_cpi",
 "MetricGroup": "cpi_breakdown",
 "MetricName": "dmiss_non_local_stall_cpi"
 },
@@ -126,7 +126,7 @@
 },
 {
 "BriefDescription": "Stalls due to short latency double precision 
ops.",
-"MetricExpr": "(PM_CMPLU_STALL_DP - 
PM_CMPLU_STALL_DPLONG)/PM_RUN_INST_CMPL",
+"MetricExpr": "dp_stall_cpi - dplong_stall_cpi",
 "MetricGroup": "cpi_breakdown",
 "MetricName": "dp_other_stall_cpi"
 },
@@ -155,7 +155,7 @@
 "MetricName": "emq_full_stall_cpi"
 },
 {
-"MetricExpr": "(PM_CMPLU_STALL_ERAT_MISS + 
PM_CMPLU_STALL_EMQ_FULL)/PM_RUN_INST_CMPL",
+"MetricExpr": "erat_miss_stall_cpi + emq_full_stall_cpi",
 "MetricGroup": "cpi_breakdown",
 "MetricName": "emq_stall_cpi"
 },
@@ -173,7 +173,7 @@
 },
 {
 "BriefDescription": "Completion stall due to execution units for other 
reasons.",
-"MetricExpr": "(PM_CMPLU_STALL_EXEC_UNIT - PM_CMPLU_STALL_FXU - 
PM_CMPLU_STALL_DP - PM_CMPLU_STALL_DFU - PM_CMPLU_STALL_PM - 
PM_CMPLU_STALL_CRYPTO - PM_CMPLU_STALL_VFXU - 
PM_CMPLU_STALL_VDP)/PM_RUN_INST_CMPL",
+"MetricExpr": "exec_unit_stall_cpi - scalar_stall_cpi - 
vector_stall_cpi",
 "MetricGroup": "cpi_breakdown",
 "MetricName": "exec_unit_other_stall_cpi"
 },
@@ -197,7 +197,7 @@
 },
 {
 "BriefDescription": "Stalls due to short latency integer ops",
-"MetricExpr": "(PM_CMPLU_STALL_FXU - 
PM_CMPLU_STALL_FXLONG)/PM_RUN_INST_CMPL",
+"MetricExpr": "fxu_stall_cpi - fxlong_stall_cpi",
 "MetricGroup": "cpi_breakdown",
 "MetricName": "fxu_other_stall_cpi"
 },
@@ -221,7 +221,7 @@
 },
 {
 "BriefDescription": "Instruction Completion Table other stalls",
-"Met

Re: [PATCHv4 00/19] perf metric: Add support to reuse metric

2020-08-01 Thread Paul A. Clarke
On Wed, Jul 29, 2020 at 11:18:49AM +0200, Jiri Olsa wrote:
> this patchset is adding the support to reused metric in
> another metric.
> 
> For example, to define IPC by using CPI with change like:
> 
>  {
>  "BriefDescription": "Instructions Per Cycle (per Logical Processor)",
> -"MetricExpr": "INST_RETIRED.ANY / CPU_CLK_UNHALTED.THREAD",
> +"MetricExpr": "1/CPI",
>  "MetricGroup": "TopDownL1",
>  "MetricName": "IPC"
>  },
> 
> I won't be able to find all the possible places we could
> use this at, so I wonder you guys (who was asking for this)
> would try it and come up with comments if there's something
> missing or we could already use it at some places.
> 
> It's based on Arnaldo's tmp.perf/core.
> 
> v4 changes:
>   - removed acks from patch because it changed a bit
> with the last fixes:
>   perf metric: Collect referenced metrics in struct metric_ref_node
>   - fixed runtime metrics [Kajol Jain]
>   - increased recursion depth [Paul A. Clarke]
>   - changed patches due to dependencies:
>   perf metric: Collect referenced metrics in struct metric_ref_node
>   perf metric: Add recursion check when processing nested metrics
>   perf metric: Rename struct egroup to metric
>   perf metric: Rename group_list to metric_list
> 
> Also available in here:
>   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
>   perf/metric

I built and ran from the above git branch, and things seem to work.
Indeed, I was able to apply my changes to exploit the new capabilities
via modifications to tools/perf/pmu-events/arch/powerpc/power9/metrics.json,
as I posted earlier (and will submit once this set gets merged).

Tested-by: Paul A. Clarke 

One thing I noted, but which also occurs without these patches, is that
the perf metrics are not computed unless run as root:
--
$ perf stat --metrics br_misprediction_percent command

 Performance counter stats for 'command':

 1,823,530,051  pm_br_pred:u

 2,662,705  pm_br_mpred_cmpl:u  


$ /usr/bin/sudo perf stat --metrics br_misprediction_percent command

 Performance counter stats for 'command':

 1,824,655,269  pm_br_pred# 0.09 
br_misprediction_percent
 1,654,466  pm_br_mpred_cmpl
--

Is that expected?  I don't think it's always been that way.

PC


RE: [PATCHv3 00/19] perf metric: Add support to reuse metric

2020-07-23 Thread Paul A. Clarke
On Wed, Jul 22, 2020 at 08:11:58PM +0200, Jiri Olsa wrote:
> On Tue, Jul 21, 2020 at 09:48:48AM -0500, Paul A. Clarke wrote:
> > On Sun, Jul 19, 2020 at 08:13:01PM +0200, Jiri Olsa wrote:
> > > hi,
> > > this patchset is adding the support to reused metric in
> > > another metric.
> > > 
> > > For example, to define IPC by using CPI with change like:
> > > 
> > >  {
> > >  "BriefDescription": "Instructions Per Cycle (per Logical 
> > > Processor)",
> > > -"MetricExpr": "INST_RETIRED.ANY / CPU_CLK_UNHALTED.THREAD",
> > > +"MetricExpr": "1/CPI",
> > >  "MetricGroup": "TopDownL1",
> > >  "MetricName": "IPC"
> > >  },
> > > 
> > > I won't be able to find all the possible places we could
> > > use this at, so I wonder you guys (who was asking for this)
> > > would try it and come up with comments if there's something
> > > missing or we could already use it at some places.
> > > 
> > > It's based on Arnaldo's tmp.perf/core.
> > > 
> > > v3 changes:
> > >   - added some acks
> > >   - some patches got merged
> > >   - added missing zalloc include [John Garry]
> > >   - added ids array outside the egroup object [Ian]
> > >   - removed wrong m->has_constraint assignment [Ian]
> > >   - renamed 'list' to 'metric_list' [Ian]
> > >   - fixed group metric and added test for it [Paul A. Clarke]
> > >   - fixed memory leak [Arnaldo]
> > >   - using lowercase keys for metrics in hashmap, because jevents
> > > converts metric_expr to lowercase
> > > 
> > > Also available in here:
> > >   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
> > >   perf/metric
> > 
> > These changes seem to be mostly working for me.
> > 
> > I attempted to exploit the new capability in the metrics definitions in
> > tools/perf/pmu-events/arch/powerpc/power9/metrics.json.  Those changes
> > are included below.
> > 
> > The one problem I found is with the "cpi_breakdown" metric group, as it
> > no longer works:
> > ```
> > # perf stat --metrics cpi_breakdown ./command
> > Cannot find metric or group `cpi_breakdown'
> > ```
> > 
> > "cpi_breakdown" does show up in `perf list --metricgroup`, and all of the
> > (95!) metrics listed in that group are usable, so it's not obvious whether
> > my changes have a problem, or merely provoke one.
> 
> I underestimated the recursion depth setup for groups,
> your change is working for me with following change:
> 
> -#define RECURSION_ID_MAX 100
> +#define RECURSION_ID_MAX 1000

I just saw some odd behavior:
```
# perf stat --metrics cpi_breakdown --metrics cpi_breakdown --metric-only ./cmd
WARNING: grouped events cpus do not match, disabling group:
  anon group { raw 0x2d018 }
 
  anon group { raw 0x2d018 }   
  anon group { raw 0x2d018 }

  
  anon group { raw 0x2d018 }   
  anon group { raw 0x1006a }

  
  anon group { raw 0x400fa }

  
  anon group { raw 0x400fa }   
  anon group { raw 0x400fa }   
  anon group { raw 0x400fa }   
perf: util/evsel.c:1452: get_group_fd: Assertion `!(!leader->core.fd)' failed.  
   
Aborted (core dumped)
```

It happened both with and without my changes on binaries which were built
yesterday.  Three or four times in a row.

Oddly, it went away without any action on my part. Same commands a minute or so
later. I haven't seen this before.  I can't reproduce it now.  :-/

PC


RE: [PATCHv3 00/19] perf metric: Add support to reuse metric

2020-07-23 Thread Paul A. Clarke
On Wed, Jul 22, 2020 at 08:11:58PM +0200, Jiri Olsa wrote:
> On Tue, Jul 21, 2020 at 09:48:48AM -0500, Paul A. Clarke wrote:
> > On Sun, Jul 19, 2020 at 08:13:01PM +0200, Jiri Olsa wrote:
> > > hi,
> > > this patchset is adding the support to reused metric in
> > > another metric.
> > > 
> > > For example, to define IPC by using CPI with change like:
> > > 
> > >  {
> > >  "BriefDescription": "Instructions Per Cycle (per Logical 
> > > Processor)",
> > > -"MetricExpr": "INST_RETIRED.ANY / CPU_CLK_UNHALTED.THREAD",
> > > +"MetricExpr": "1/CPI",
> > >  "MetricGroup": "TopDownL1",
> > >  "MetricName": "IPC"
> > >  },
> > > 
> > > I won't be able to find all the possible places we could
> > > use this at, so I wonder you guys (who was asking for this)
> > > would try it and come up with comments if there's something
> > > missing or we could already use it at some places.
> > > 
> > > It's based on Arnaldo's tmp.perf/core.
> > > 
> > > v3 changes:
> > >   - added some acks
> > >   - some patches got merged
> > >   - added missing zalloc include [John Garry]
> > >   - added ids array outside the egroup object [Ian]
> > >   - removed wrong m->has_constraint assignment [Ian]
> > >   - renamed 'list' to 'metric_list' [Ian]
> > >   - fixed group metric and added test for it [Paul A. Clarke]
> > >   - fixed memory leak [Arnaldo]
> > >   - using lowercase keys for metrics in hashmap, because jevents
> > > converts metric_expr to lowercase
> > > 
> > > Also available in here:
> > >   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
> > >   perf/metric
> > 
> > These changes seem to be mostly working for me.
> > 
> > I attempted to exploit the new capability in the metrics definitions in
> > tools/perf/pmu-events/arch/powerpc/power9/metrics.json.  Those changes
> > are included below.
> > 
> > The one problem I found is with the "cpi_breakdown" metric group, as it
> > no longer works:
> > ```
> > # perf stat --metrics cpi_breakdown ./command
> > Cannot find metric or group `cpi_breakdown'
> > ```
> > 
> > "cpi_breakdown" does show up in `perf list --metricgroup`, and all of the
> > (95!) metrics listed in that group are usable, so it's not obvious whether
> > my changes have a problem, or merely provoke one.
> 
> I underestimated the recursion depth setup for groups,
> your change is working for me with following change:
> 
> -#define RECURSION_ID_MAX 100
> +#define RECURSION_ID_MAX 1000

That indeed addressed the issue.

Is there a point where that limit was being hit and the code silently fails?
If so, should that failure be less silent?

PC


Re: [PATCHv3 00/19] perf metric: Add support to reuse metric

2020-07-21 Thread Paul A. Clarke
On Sun, Jul 19, 2020 at 08:13:01PM +0200, Jiri Olsa wrote:
> hi,
> this patchset is adding the support to reused metric in
> another metric.
> 
> For example, to define IPC by using CPI with change like:
> 
>  {
>  "BriefDescription": "Instructions Per Cycle (per Logical Processor)",
> -"MetricExpr": "INST_RETIRED.ANY / CPU_CLK_UNHALTED.THREAD",
> +"MetricExpr": "1/CPI",
>  "MetricGroup": "TopDownL1",
>  "MetricName": "IPC"
>  },
> 
> I won't be able to find all the possible places we could
> use this at, so I wonder you guys (who was asking for this)
> would try it and come up with comments if there's something
> missing or we could already use it at some places.
> 
> It's based on Arnaldo's tmp.perf/core.
> 
> v3 changes:
>   - added some acks
>   - some patches got merged
>   - added missing zalloc include [John Garry]
>   - added ids array outside the egroup object [Ian]
>   - removed wrong m->has_constraint assignment [Ian]
>   - renamed 'list' to 'metric_list' [Ian]
>   - fixed group metric and added test for it [Paul A. Clarke]
>   - fixed memory leak [Arnaldo]
>   - using lowercase keys for metrics in hashmap, because jevents
> converts metric_expr to lowercase
> 
> Also available in here:
>   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
>   perf/metric

These changes seem to be mostly working for me.

I attempted to exploit the new capability in the metrics definitions in
tools/perf/pmu-events/arch/powerpc/power9/metrics.json.  Those changes
are included below.

The one problem I found is with the "cpi_breakdown" metric group, as it
no longer works:
```
# perf stat --metrics cpi_breakdown ./command
Cannot find metric or group `cpi_breakdown'
```

"cpi_breakdown" does show up in `perf list --metricgroup`, and all of the
(95!) metrics listed in that group are usable, so it's not obvious whether
my changes have a problem, or merely provoke one.

diff --git a/tools/perf/pmu-events/arch/powerpc/power9/metrics.json 
b/tools/perf/pmu-events/arch/powerpc/power9/metrics.json
index 80816d6402e9..f8784c608479 100644
--- a/tools/perf/pmu-events/arch/powerpc/power9/metrics.json
+++ b/tools/perf/pmu-events/arch/powerpc/power9/metrics.json
@@ -60,7 +60,7 @@
 },
 {
 "BriefDescription": "Stalls due to short latency decimal floating 
ops.",
-"MetricExpr": "(PM_CMPLU_STALL_DFU - 
PM_CMPLU_STALL_DFLONG)/PM_RUN_INST_CMPL",
+"MetricExpr": "dfu_stall_cpi - dflong_stall_cpi",
 "MetricGroup": "cpi_breakdown",
 "MetricName": "dfu_other_stall_cpi"
 },
@@ -72,7 +72,7 @@
 },
 {
 "BriefDescription": "Completion stall by Dcache miss which resolved 
off node memory/cache",
-"MetricExpr": "(PM_CMPLU_STALL_DMISS_L3MISS - 
PM_CMPLU_STALL_DMISS_L21_L31 - PM_CMPLU_STALL_DMISS_LMEM - 
PM_CMPLU_STALL_DMISS_REMOTE)/PM_RUN_INST_CMPL",
+"MetricExpr": "dmiss_non_local_stall_cpi - dmiss_remote_stall_cpi",
 "MetricGroup": "cpi_breakdown",
 "MetricName": "dmiss_distant_stall_cpi"
 },
@@ -90,7 +90,7 @@
 },
 {
 "BriefDescription": "Completion stall due to cache miss that resolves 
in the L2 or L3 without conflict",
-"MetricExpr": "(PM_CMPLU_STALL_DMISS_L2L3 - 
PM_CMPLU_STALL_DMISS_L2L3_CONFLICT)/PM_RUN_INST_CMPL",
+"MetricExpr": "dmiss_l2l3_stall_cpi - dmiss_l2l3_conflict_stall_cpi",
 "MetricGroup": "cpi_breakdown",
 "MetricName": "dmiss_l2l3_noconflict_stall_cpi"
 },
@@ -114,7 +114,7 @@
 },
 {
 "BriefDescription": "Completion stall by Dcache miss which resolved 
outside of local memory",
-"MetricExpr": "(PM_CMPLU_STALL_DMISS_L3MISS - 
PM_CMPLU_STALL_DMISS_L21_L31 - PM_CMPLU_STALL_DMISS_LMEM)/PM_RUN_INST_CMPL",
+"MetricExpr": "dmiss_l3miss_stall_cpi - dmiss_l21_l31_stall_cpi - 
dmiss_lmem_stall_cpi",
 "MetricGroup": "cpi_breakdown",
 "MetricName": "dmiss_non_local_stall_cpi"
 },
@@ -126,7 +126,7 @@
 },
 {
 "BriefDescription": "Stalls due to short latency double precision 
ops.",
-"MetricExpr": "(PM_CMPLU_STALL_DP - 
PM_CMPLU_STALL_DPLONG)/PM_RUN_INST_CMPL",
+"MetricExpr": "dp_stall_cpi - dplong_stall_cpi",
 "MetricGroup": "

RE: [PATCH 00/18] perf metric: Add support to reuse metric

2020-07-15 Thread Paul A. Clarke
On Wed, Jul 15, 2020 at 11:41:34PM +0200, Jiri Olsa wrote:
> On Wed, Jul 15, 2020 at 01:33:27PM -0500, Paul A. Clarke wrote:
> > On Sun, Jul 12, 2020 at 03:26:16PM +0200, Jiri Olsa wrote:
> > > hi,
> > > this patchset is adding the support to reused metric in another 
> > > metric. The metric needs to be referenced by 'metric:' prefix.
> > > 
> > > For example, to define IPC by using CPI with change like:
> > > 
> > >  "BriefDescription": "Instructions Per Cycle (per Logical 
> > > Processor)",
> > >  -   "MetricExpr": "INST_RETIRED.ANY / CPU_CLK_UNHALTED.THREAD",
> > >  +   "MetricExpr": "1/metric:CPI",
> > >  "MetricGroup": "TopDownL1",
> > >  "MetricName": "IPC"
> > > 
> > > I won't be able to find all the possible places we could
> > > use this at, so I wonder you guys (who was asking for this)
> > > would try it and come up with comments if there's something
> > > missing or we could already use it at some places.
> > > 
> > > It's based on Arnaldo's tmp.perf/core.
> > > 
> > > v2 changes:
> > >   - collected Ian's acks for few patches [Ian]
> > >   - renamed expr__add_id to expr__add_id_val [Ian]
> > >   - renamed expr_parse_data to expr_id_data [Ian]
> > >   - added recursion check [Ian]
> > >   - added metric test for DCache_L2 metric [Ian]
> > >   - added some renames as discussed in review [Ian]
> > > 
> > > Also available in here:
> > >   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
> > >   perf/metric
> > 
> > I'm having trouble testing this.
> > 
> > I checked out this tree, and am able to build with a JSON metrics definition
> > file which uses other metrics.  I put this aside, though, because of the
> > following issue.
> > 
> > I built the kernel from this same tree and booted it successfully.
> > However, the metrics are not working correctly.  (I may very well be
> > doing something wrong.)
> 
> if you'll share the metric change I can help debugging that

It fails as described below without any changes from me.

> > The base system is RHEL8, but it's now booted with the new kernel.
> > ```
> > # uname -a
> > Linux system 5.8.0-rc4-g7dd02cf0b #1 SMP Wed Jul 15 12:31:45 EDT 2020 
> > ppc64le ppc64le ppc64le GNU/Linux
> > # perf stat --metrics cpi_breakdown ./load
> > failed: way too many variables
> 
> hm, this ^^^ error string was removed in:
>   43fe337c86a9 perf expr: Migrate expr ids table to a hashmap
> 
> looks like you're not running the correct perf binary

I should've explained this better in my post, but there are two runs of
perf there.  The first is above, and is the perf that comes with the
distribution.  I'll repeat that here:
```
# perf --version
perf version 4.18.0-214.el8.ppc64le
# perf stat --metrics cpi_breakdown ./load >/dev/null 
failed: way too many variables  
 
 Performance counter stats for './load':
 

 
   818,130  pm_cmplu_stall_bru#  0.0 bru_stall_cpi  
  (0.45%)
 5,013,082,026  pm_run_inst_cmpl
  (0.45%)
 0  pm_cmplu_stall_crypto #  0.0 crypto_stall_cpi   
  (0.89%)
 6,580,655,094  pm_run_inst_cmpl
  (0.89%)
25,729,751  pm_cmplu_stall_dcache_miss #  0.0 
dcache_miss_stall_cpi(1.77%)
 6,690,035,175  pm_run_inst_cmpl
  (1.77%)
 0  pm_cmplu_stall_dflong #  0.0 dflong_stall_cpi   
  (1.77%)
 6,769,854,632  pm_run_inst_cmpl
  (1.77%)
 0  pm_cmplu_stall_dfu#  0.0 
dfu_other_stall_cpi  (0.89%)
[...and LOTS more...]
```

The second example in my previous post was from
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
branch perf/metric
```
commit 7dd02cf0b9f04ca5339fa97f9a2280ebdd60b1db (grafted, HEAD -> perf/metric, 
origin/perf/metric)
Author: Jiri Olsa 
Date:   Thu Jul 9 13:45:30 2020 +0200

perf metric: Rename group_list to list
```

This build of `perf` fails:
```
# ~/install/bin/perf --version
perf version 5.8.rc4.g7dd02cf0b9f0
# ~/install/bin/perf stat --metrics cpi_breakdown ./load >/dev/null

 Performance counter stats for './load':

 6,729,400,541  pm_run_inst_cmpl  # 0.00 bru_stall_cpi  

57,953  pm_cmplu_stall_bru  


   1.127319209 seconds time elapsed

   1.124906000 seconds user
   0.00089 seconds sys
```

PC


Re: [PATCH 00/18] perf metric: Add support to reuse metric

2020-07-15 Thread Paul A. Clarke
On Sun, Jul 12, 2020 at 03:26:16PM +0200, Jiri Olsa wrote:
> hi,
> this patchset is adding the support to reused metric in another 
> metric. The metric needs to be referenced by 'metric:' prefix.
> 
> For example, to define IPC by using CPI with change like:
> 
>  "BriefDescription": "Instructions Per Cycle (per Logical Processor)",
>  -   "MetricExpr": "INST_RETIRED.ANY / CPU_CLK_UNHALTED.THREAD",
>  +   "MetricExpr": "1/metric:CPI",
>  "MetricGroup": "TopDownL1",
>  "MetricName": "IPC"
> 
> I won't be able to find all the possible places we could
> use this at, so I wonder you guys (who was asking for this)
> would try it and come up with comments if there's something
> missing or we could already use it at some places.
> 
> It's based on Arnaldo's tmp.perf/core.
> 
> v2 changes:
>   - collected Ian's acks for few patches [Ian]
>   - renamed expr__add_id to expr__add_id_val [Ian]
>   - renamed expr_parse_data to expr_id_data [Ian]
>   - added recursion check [Ian]
>   - added metric test for DCache_L2 metric [Ian]
>   - added some renames as discussed in review [Ian]
> 
> Also available in here:
>   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
>   perf/metric

I'm having trouble testing this.

I checked out this tree, and am able to build with a JSON metrics definition
file which uses other metrics.  I put this aside, though, because of the
following issue.

I built the kernel from this same tree and booted it successfully.
However, the metrics are not working correctly.  (I may very well be
doing something wrong.)

The base system is RHEL8, but it's now booted with the new kernel.
```
# uname -a
Linux system 5.8.0-rc4-g7dd02cf0b #1 SMP Wed Jul 15 12:31:45 EDT 2020 ppc64le 
ppc64le ppc64le GNU/Linux
# perf stat --metrics cpi_breakdown ./load
failed: way too many variables

 Performance counter stats for './load':

   569,884  pm_cmplu_stall_bru#  0.0 bru_stall_cpi  
  (0.66%)
 5,662,892,875  pm_run_inst_cmpl
  (0.66%)
 0  pm_cmplu_stall_crypto #  0.0 crypto_stall_cpi   
  (0.89%)
 6,728,401,038  pm_run_inst_cmpl
  (0.89%)
25,347,764  pm_cmplu_stall_dcache_miss #  0.0 
dcache_miss_stall_cpi(1.77%)
 6,727,267,383  pm_run_inst_cmpl
  (1.77%)
 0  pm_cmplu_stall_dflong #  0.0 dflong_stall_cpi   
  (1.77%)
 6,719,648,242  pm_run_inst_cmpl
  (1.77%)
 0  pm_cmplu_stall_dfu#  0.0 
dfu_other_stall_cpi  (0.89%)
[...and LOTS more output...]

# ~/install/bin/perf stat --metrics cpi_breakdown ./load

 Performance counter stats for './load':

 6,729,588,550  pm_run_inst_cmpl  # 0.00 bru_stall_cpi  

58,005  pm_cmplu_stall_bru  


   1.129524610 seconds time elapsed

   1.126914000 seconds user
   0.000955000 seconds sys

```

PC


[PATCH v2] perf config: Add stat.big-num support

2020-05-20 Thread Paul A. Clarke
From: "Paul A. Clarke" 

Add support for new "stat.big-num" boolean option.

This allows a user to set a default for "--no-big-num" for "perf stat"
commands.

--
$ perf config stat.big-num
$ perf stat --event cycles /bin/true

 Performance counter stats for '/bin/true':

   778,849  cycles
[...]
$ perf config stat.big-num=false
$ perf config stat.big-num
stat.big-num=false
$ perf stat --event cycles /bin/true

 Performance counter stats for '/bin/true':

769622  cycles
[...]
--

There is an interaction with "--field-separator" that must be
accommodated, such that specifying "--big-num --field-separator={x}"
still reports an invalid combination of options.

Documentation for perf-config and perf-stat updated.

Signed-off-by: Paul A. Clarke 
---
v2:
- Documentation updates for perf-config and perf-stat.
- Changed from using 0/1 to false/true in the examples and documentation.

Testing results with a matrix of:
- nothing in .perfconfig, stat.big-num=false, stat.big-num=true
- --field-separator not set, --field-separator=:
- no "--big-num", --big-num, --no-big-num

$ perf config stat.big-num
$ perf stat --event cycles /bin/true

 Performance counter stats for '/bin/true':

   778,849  cycles  


   0.000570037 seconds time elapsed

   0.000619000 seconds user
   0.0 seconds sys


$ perf stat --event cycles --big-num /bin/true

 Performance counter stats for '/bin/true':

   763,003  cycles  


   0.000546281 seconds time elapsed

   0.000597000 seconds user
   0.0 seconds sys


$ perf stat --event cycles --no-big-num /bin/true

 Performance counter stats for '/bin/true':

810753  cycles  


   0.000582670 seconds time elapsed

   0.000638000 seconds user
   0.0 seconds sys


$ perf stat --event cycles --field-separator=: /bin/true
759523::cycles:333196:100.00::
$ perf stat --event cycles --big-num --field-separator=: /bin/true
-B option not supported with -x

 Usage: perf stat [] []

-B, --big-num print large numbers with thousands' separators
-x, --field-separator 
  print counts with custom separator
$ perf stat --event cycles --no-big-num --field-separator=: /bin/true
782610::cycles:343606:100.00::
$ perf config stat.big-num=false
$ perf config stat.big-num
stat.big-num=false
$ perf stat --event cycles /bin/true

 Performance counter stats for '/bin/true':

769622  cycles  


   0.000545743 seconds time elapsed

   0.00060 seconds user
   0.0 seconds sys


$ perf stat --event cycles --big-num /bin/true

 Performance counter stats for '/bin/true':

   788,694  cycles  


   0.000565276 seconds time elapsed

   0.000622000 seconds user
   0.0 seconds sys


$ perf stat --event cycles --no-big-num /bin/true

 Performance counter stats for '/bin/true':

808283  cycles  


   0.000575508 seconds time elapsed

   0.000632000 seconds user
   0.0 seconds sys


$ perf stat --event cycles --field-separator=: /bin/true
809296::cycles:355486:100.00::
$ perf stat --event cycles --big-num --field-separator=: /bin/true
-B option not supported with -x

 Usage: perf stat [] []

-B, --big-num print large numbers with thousands' separators
-x, --field-separator 
  print counts with custom separator
$ perf stat --event cycles --no-big-num --field-separator=: /bin/true
795679::cycles:349824:100.00::
$ perf config stat.big-num=true
$ perf config stat.big-num
stat.big-num=true
$ perf stat --event cycles /bin/true

 Performance counter stats for '/bin/true':

   823,114  cycles  


   0.000577809 seconds time elapsed

   0.000643000 seconds user
   0.0 seconds sys


$ perf stat --event cycles --big-num /bin/true

 Performance counter stats for '/bin/true':

   778,824  cycles  


   0.000551584 seconds time elapsed

   0.000603000 seconds user
   0.0 seconds sys


$ perf stat --event cycles --no-big-num /bin/true

 Performance counter stats for '/bin/true':

789190  cycles  


   0.000574797 seconds time elapsed

   0.000637000 seconds user
   0.0 seconds sys


$ perf stat --event cycles --field-separator=: /bin/true
780405::cycles:343394:100.00::
$ perf stat --event cycles --big-num --field-se

[PATCH] perf config: Add stat.big-num support

2020-05-20 Thread Paul A. Clarke
From: "Paul A. Clarke" 

Add support for new "stat.big-num" boolean option.

This allows a user to set a default for "--no-big-num" for "perf stat"
commands.

$ perf config stat.big-num
$ perf stat --event cycles /bin/true

 Performance counter stats for '/bin/true':

   803,684  cycles  

[...]
$ perf config stat.big-num=0
$ perf config stat.big-num
stat.big-num=0
$ perf stat --event cycles /bin/true

 Performance counter stats for '/bin/true':

790448  cycles  

[...]

There is an interaction with "--field-separator" that must be
accommodated, such that specifying "--big-num --field-separator={x}"
still reports an invalid combination of options.

Signed-off-by: Paul A. Clarke 
---
Testing results with a matrix of:
- nothing in .perfconfig, stat.big-num=0, stat.big-num=1
- --field-separator not set, --field-separator=:
- no "--big-num", --big-num, --no-big-num

$ perf config stat.big-num
$ perf stat --event cycles /bin/true

 Performance counter stats for '/bin/true':

   803,684  cycles  


   0.000592761 seconds time elapsed

   0.000672000 seconds user
   0.0 seconds sys


$ perf stat --event cycles --big-num /bin/true

 Performance counter stats for '/bin/true':

   809,599  cycles  


   0.000576090 seconds time elapsed

   0.000627000 seconds user
   0.0 seconds sys


$ perf stat --event cycles --no-big-num /bin/true

 Performance counter stats for '/bin/true':

793870  cycles  


   0.000574928 seconds time elapsed

   0.000625000 seconds user
   0.0 seconds sys


$ perf stat --event cycles --field-separator=: /bin/true
790255::cycles:346960:100.00::
$ perf stat --event cycles --big-num --field-separator=: /bin/true
-B option not supported with -x

 Usage: perf stat [] []

-B, --big-num print large numbers with thousands' separators
-x, --field-separator 
  print counts with custom separator
$ perf stat --event cycles --no-big-num --field-separator=: /bin/true
764548::cycles:335938:100.00::
$ perf config stat.big-num=0
$ perf config stat.big-num
stat.big-num=0
$ perf stat --event cycles /bin/true

 Performance counter stats for '/bin/true':

790448  cycles  


   0.000567659 seconds time elapsed

   0.000619000 seconds user
   0.0 seconds sys


$ perf stat --event cycles --big-num /bin/true

 Performance counter stats for '/bin/true':

   751,377  cycles  


   0.000534888 seconds time elapsed

   0.000587000 seconds user
   0.0 seconds sys


$ perf stat --event cycles --no-big-num /bin/true

 Performance counter stats for '/bin/true':

803738  cycles  


   0.000576151 seconds time elapsed

   0.000657000 seconds user
   0.0 seconds sys


$ perf stat --event cycles --field-separator=: /bin/true
774897::cycles:339986:100.00::
$ perf stat --event cycles --big-num --field-separator=: /bin/true
-B option not supported with -x

 Usage: perf stat [] []

-B, --big-num print large numbers with thousands' separators
-x, --field-separator 
  print counts with custom separator
$ perf stat --event cycles --no-big-num --field-separator=: /bin/true
814619::cycles:358260:100.00::
$ perf config stat.big-num=1
$ perf config stat.big-num
stat.big-num=1
$ perf stat --event cycles /bin/true

 Performance counter stats for '/bin/true':

   787,680  cycles  


   0.000555401 seconds time elapsed

   0.000623000 seconds user
   0.0 seconds sys


$ perf stat --event cycles --big-num /bin/true

 Performance counter stats for '/bin/true':

   783,287  cycles  


   0.000562255 seconds time elapsed

   0.000636000 seconds user
   0.0 seconds sys


$ perf stat --event cycles --no-big-num /bin/true

 Performance counter stats for '/bin/true':

748802  cycles  


   0.000525658 seconds time elapsed

   0.000586000 seconds user
   0.0 seconds sys


$ perf stat --event cycles --field-separator=: /bin/true
785868::cycles:344508:100.00::
$ perf stat --event cycles --big-num --field-separator=: /bin/true
-B option not supported with -x

 Usage: perf stat [] []

-B, --big-num pr

[PATCH] perf stat: POWER9 metrics: expand "ICT" acronym

2020-05-19 Thread Paul A. Clarke
From: "Paul A. Clarke" 

Uses of "ICT" and "Ict" are expanded to "Instruction Completion Table".

Signed-off-by: Paul A. Clarke 
---
 .../arch/powerpc/power9/metrics.json  | 20 +--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/tools/perf/pmu-events/arch/powerpc/power9/metrics.json 
b/tools/perf/pmu-events/arch/powerpc/power9/metrics.json
index f371104dcbe3..80816d6402e9 100644
--- a/tools/perf/pmu-events/arch/powerpc/power9/metrics.json
+++ b/tools/perf/pmu-events/arch/powerpc/power9/metrics.json
@@ -208,19 +208,19 @@
 "MetricName": "fxu_stall_cpi"
 },
 {
-"BriefDescription": "Ict empty for this thread due to branch mispred",
+"BriefDescription": "Instruction Completion Table empty for this 
thread due to branch mispred",
 "MetricExpr": "PM_ICT_NOSLOT_BR_MPRED/PM_RUN_INST_CMPL",
 "MetricGroup": "cpi_breakdown",
 "MetricName": "ict_noslot_br_mpred_cpi"
 },
 {
-"BriefDescription": "Ict empty for this thread due to Icache Miss and 
branch mispred",
+"BriefDescription": "Instruction Completion Table empty for this 
thread due to Icache Miss and branch mispred",
 "MetricExpr": "PM_ICT_NOSLOT_BR_MPRED_ICMISS/PM_RUN_INST_CMPL",
 "MetricGroup": "cpi_breakdown",
 "MetricName": "ict_noslot_br_mpred_icmiss_cpi"
 },
 {
-"BriefDescription": "ICT other stalls",
+"BriefDescription": "Instruction Completion Table other stalls",
 "MetricExpr": "(PM_ICT_NOSLOT_CYC - PM_ICT_NOSLOT_IC_MISS - 
PM_ICT_NOSLOT_BR_MPRED_ICMISS - PM_ICT_NOSLOT_BR_MPRED - 
PM_ICT_NOSLOT_DISP_HELD)/PM_RUN_INST_CMPL",
 "MetricGroup": "cpi_breakdown",
 "MetricName": "ict_noslot_cyc_other_cpi"
@@ -232,13 +232,13 @@
 "MetricName": "ict_noslot_disp_held_cpi"
 },
 {
-"BriefDescription": "Ict empty for this thread due to dispatch holds 
because the History Buffer was full. Could be GPR/VSR/VMR/FPR/CR/XVF",
+"BriefDescription": "Instruction Completion Table empty for this 
thread due to dispatch holds because the History Buffer was full. Could be 
GPR/VSR/VMR/FPR/CR/XVF",
 "MetricExpr": "PM_ICT_NOSLOT_DISP_HELD_HB_FULL/PM_RUN_INST_CMPL",
 "MetricGroup": "cpi_breakdown",
 "MetricName": "ict_noslot_disp_held_hb_full_cpi"
 },
 {
-"BriefDescription": "Ict empty for this thread due to dispatch hold on 
this thread due to Issue q full, BRQ full, XVCF Full, Count cache, Link, Tar 
full",
+"BriefDescription": "Instruction Completion Table empty for this 
thread due to dispatch hold on this thread due to Issue q full, BRQ full, XVCF 
Full, Count cache, Link, Tar full",
 "MetricExpr": "PM_ICT_NOSLOT_DISP_HELD_ISSQ/PM_RUN_INST_CMPL",
 "MetricGroup": "cpi_breakdown",
 "MetricName": "ict_noslot_disp_held_issq_cpi"
@@ -268,19 +268,19 @@
 "MetricName": "ict_noslot_ic_l2_cpi"
 },
 {
-"BriefDescription": "Ict empty for this thread due to icache misses 
that were sourced from the local L3",
+"BriefDescription": "Instruction Completion Table empty for this 
thread due to icache misses that were sourced from the local L3",
 "MetricExpr": "PM_ICT_NOSLOT_IC_L3/PM_RUN_INST_CMPL",
 "MetricGroup": "cpi_breakdown",
 "MetricName": "ict_noslot_ic_l3_cpi"
 },
 {
-"BriefDescription": "Ict empty for this thread due to icache misses 
that were sourced from beyond the local L3. The source could be 
local/remote/distant memory or another core's cache",
+"BriefDescription": "Instruction Completion Table empty for this 
thread due to icache misses that were sourced from beyond the local L3. The 
source could be local/remote/distant memory or another core's cache",
 "MetricExpr": "PM_ICT_NOSLOT_IC_L3MISS/PM_RUN_INST_CMPL",
 "MetricGroup": "cpi_breakdown",
 "MetricName": "ict_noslot_ic_l3miss_cpi"
 },
 {
-"BriefDescription": "Ict empty for this thread due to Icache Miss",
+"BriefDescription": "Instruction Completion Table empty for this 
thread due to

metric expressions including metrics?

2020-05-18 Thread Paul A. Clarke
I'm curious how hard it would be to define metrics using other metrics,
in the metrics definition files.

Currently, to my understanding, every metric definition must be an
expresssion based solely on arithmetic combinations of hardware events.

Some metrics are hierarchical in nature such that a higher-level metric
can be defined as an arithmetic expression of two other metrics, e.g.

cache_miss_cycles_per_instruction =
  data_cache_miss_cycles_per_instruction +
  instruction_cache_miss_cycles_per_instruction

This would need to be defined something like:
dcache_miss_cpi = "dcache_miss_cycles / instructions"
icache_miss_cpi = "icache_miss_cycles / instructions"
cache_miss_cpi = "(dcache_miss_cycles + icache_miss_cycles) / instructions"

Could the latter definition be simplified to:
cache_miss_cpi = "dcache_miss_cpi + icache_miss_cpi"

With multi-level caches and NUMA hierarchies, some of these higher-level
metrics can involve a lot of hardware events.

Given the recent activity in this area, I'm curious if this has been
considered and already on a wish/to-do list, or found onerous.

Regards,
Paul Clarke


Re: [PATCH 2/2] perf: Add missing metrics to POWER9 'cpi_breakdown'

2020-05-14 Thread Paul A. Clarke
On Wed, May 13, 2020 at 06:28:31PM +1000, Michael Ellerman wrote:
> "Paul A. Clarke"  writes:
> > Add the following metrics to the POWER9 'cpi_breakdown' metricgroup:
> > - ict_noslot_br_mpred_cpi
> > - ict_noslot_br_mpred_icmiss_cpi
> > - ict_noslot_cyc_other_cpi
> > - ict_noslot_disp_held_cpi
> > - ict_noslot_disp_held_hb_full_cpi
> > - ict_noslot_disp_held_issq_cpi
> > - ict_noslot_disp_held_other_cpi
> > - ict_noslot_disp_held_sync_cpi
> > - ict_noslot_disp_held_tbegin_cpi
> > - ict_noslot_ic_l2_cpi
> > - ict_noslot_ic_l3_cpi
> > - ict_noslot_ic_l3miss_cpi
> > - ict_noslot_ic_miss_cpi
> >
> > Signed-off-by: Paul A. Clarke 
> > ---
> >  .../arch/powerpc/power9/metrics.json  | 143 ++
> >  1 file changed, 78 insertions(+), 65 deletions(-)
> >
> > diff --git a/tools/perf/pmu-events/arch/powerpc/power9/metrics.json 
> > b/tools/perf/pmu-events/arch/powerpc/power9/metrics.json
> > index 811c2a8c1c9e..6169351a72c8 100644
> > --- a/tools/perf/pmu-events/arch/powerpc/power9/metrics.json
> > +++ b/tools/perf/pmu-events/arch/powerpc/power9/metrics.json
> > @@ -207,6 +207,84 @@
> >  "MetricGroup": "cpi_breakdown",
> >  "MetricName": "fxu_stall_cpi"
> >  },
> > +{
> > +"BriefDescription": "Ict empty for this thread due to branch 
> > mispred",
> 
> I think you're just moving this, not adding it. But ICT is an acronym,
> so it should be spelled ICT not Ict.
> 
> It might be worth expanding it too?

This was 98% produced through automated means, translating an existing
XML file to perf's JSON format.

I've gotten the upstream XML file changed to include the "ICT" metrics
in the "cpi_breakdown" group already, and can request the changes you
suggest also be incorporated.

For the time being, can we move forward with the patch as-is?

PC


[PATCH 2/2] perf: Add missing metrics to POWER9 'cpi_breakdown'

2020-05-07 Thread Paul A. Clarke
From: "Paul A. Clarke" 

Add the following metrics to the POWER9 'cpi_breakdown' metricgroup:
- ict_noslot_br_mpred_cpi
- ict_noslot_br_mpred_icmiss_cpi
- ict_noslot_cyc_other_cpi
- ict_noslot_disp_held_cpi
- ict_noslot_disp_held_hb_full_cpi
- ict_noslot_disp_held_issq_cpi
- ict_noslot_disp_held_other_cpi
- ict_noslot_disp_held_sync_cpi
- ict_noslot_disp_held_tbegin_cpi
- ict_noslot_ic_l2_cpi
- ict_noslot_ic_l3_cpi
- ict_noslot_ic_l3miss_cpi
- ict_noslot_ic_miss_cpi

Signed-off-by: Paul A. Clarke 
---
 .../arch/powerpc/power9/metrics.json  | 143 ++
 1 file changed, 78 insertions(+), 65 deletions(-)

diff --git a/tools/perf/pmu-events/arch/powerpc/power9/metrics.json 
b/tools/perf/pmu-events/arch/powerpc/power9/metrics.json
index 811c2a8c1c9e..6169351a72c8 100644
--- a/tools/perf/pmu-events/arch/powerpc/power9/metrics.json
+++ b/tools/perf/pmu-events/arch/powerpc/power9/metrics.json
@@ -207,6 +207,84 @@
 "MetricGroup": "cpi_breakdown",
 "MetricName": "fxu_stall_cpi"
 },
+{
+"BriefDescription": "Ict empty for this thread due to branch mispred",
+"MetricExpr": "PM_ICT_NOSLOT_BR_MPRED/PM_RUN_INST_CMPL",
+"MetricGroup": "cpi_breakdown",
+"MetricName": "ict_noslot_br_mpred_cpi"
+},
+{
+"BriefDescription": "Ict empty for this thread due to Icache Miss and 
branch mispred",
+"MetricExpr": "PM_ICT_NOSLOT_BR_MPRED_ICMISS/PM_RUN_INST_CMPL",
+"MetricGroup": "cpi_breakdown",
+"MetricName": "ict_noslot_br_mpred_icmiss_cpi"
+},
+{
+"BriefDescription": "ICT other stalls",
+"MetricExpr": "(PM_ICT_NOSLOT_CYC - PM_ICT_NOSLOT_IC_MISS - 
PM_ICT_NOSLOT_BR_MPRED_ICMISS - PM_ICT_NOSLOT_BR_MPRED - 
PM_ICT_NOSLOT_DISP_HELD)/PM_RUN_INST_CMPL",
+"MetricGroup": "cpi_breakdown",
+"MetricName": "ict_noslot_cyc_other_cpi"
+},
+{
+"BriefDescription": "Cycles in which the NTC instruciton is held at 
dispatch for any reason",
+"MetricExpr": "PM_ICT_NOSLOT_DISP_HELD/PM_RUN_INST_CMPL",
+"MetricGroup": "cpi_breakdown",
+"MetricName": "ict_noslot_disp_held_cpi"
+},
+{
+"BriefDescription": "Ict empty for this thread due to dispatch holds 
because the History Buffer was full. Could be GPR/VSR/VMR/FPR/CR/XVF",
+"MetricExpr": "PM_ICT_NOSLOT_DISP_HELD_HB_FULL/PM_RUN_INST_CMPL",
+"MetricGroup": "cpi_breakdown",
+"MetricName": "ict_noslot_disp_held_hb_full_cpi"
+},
+{
+"BriefDescription": "Ict empty for this thread due to dispatch hold on 
this thread due to Issue q full, BRQ full, XVCF Full, Count cache, Link, Tar 
full",
+"MetricExpr": "PM_ICT_NOSLOT_DISP_HELD_ISSQ/PM_RUN_INST_CMPL",
+"MetricGroup": "cpi_breakdown",
+"MetricName": "ict_noslot_disp_held_issq_cpi"
+},
+{
+"BriefDescription": "ICT_NOSLOT_DISP_HELD_OTHER_CPI",
+"MetricExpr": "(PM_ICT_NOSLOT_DISP_HELD - 
PM_ICT_NOSLOT_DISP_HELD_HB_FULL - PM_ICT_NOSLOT_DISP_HELD_SYNC - 
PM_ICT_NOSLOT_DISP_HELD_TBEGIN - 
PM_ICT_NOSLOT_DISP_HELD_ISSQ)/PM_RUN_INST_CMPL",
+"MetricGroup": "cpi_breakdown",
+"MetricName": "ict_noslot_disp_held_other_cpi"
+},
+{
+"BriefDescription": "Dispatch held due to a synchronizing instruction 
at dispatch",
+"MetricExpr": "PM_ICT_NOSLOT_DISP_HELD_SYNC/PM_RUN_INST_CMPL",
+"MetricGroup": "cpi_breakdown",
+"MetricName": "ict_noslot_disp_held_sync_cpi"
+},
+{
+"BriefDescription": "the NTC instruction is being held at dispatch 
because it is a tbegin instruction and there is an older tbegin in the pipeline 
that must complete before the younger tbegin can dispatch",
+"MetricExpr": "PM_ICT_NOSLOT_DISP_HELD_TBEGIN/PM_RUN_INST_CMPL",
+"MetricGroup": "cpi_breakdown",
+"MetricName": "ict_noslot_disp_held_tbegin_cpi"
+},
+{
+"BriefDescription": "ICT_NOSLOT_IC_L2_CPI",
+"MetricExpr": "(PM_ICT_NOSLOT_IC_MISS - PM_ICT_NOSLOT_IC_L3 - 
PM_ICT_NOSLOT_IC_L3MISS)/PM_RUN_INST_CMPL",
+"MetricGroup": "cpi_breakdown",
+"Metric

[PATCH 0/2] perf: Fix POWER9 cpi_breakdown metricgroup

2020-05-07 Thread Paul A. Clarke
From: "Paul A. Clarke" 

The recent patches posted by Ian Rogers motivated a deeper dive into
the POWER9 perf metrics, which uncovered some additional issues:

- 'lsu_other_stall_cpi' doesn't work at all
- All of the "ICT" metrics are missing from the metricgroup

Paul A. Clarke (2):
  perf: Fix POWER9 metric 'lsu_other_stall_cpi'
  perf: Add missing metrics to POWER9 'cpi_breakdown'

 .../arch/powerpc/power9/metrics.json  | 143 ++
 tools/perf/util/expr.h|   2 +-
 2 files changed, 79 insertions(+), 66 deletions(-)

-- 
2.18.2



[PATCH 1/2] perf: Fix POWER9 metric 'lsu_other_stall_cpi'

2020-05-07 Thread Paul A. Clarke
From: "Paul A. Clarke" 

The metric definition is too long for the current value of EXPR_MAX_OTHER.
Increase the value EXPR_MAX_OTHER sufficiently to allow
'lsu_other_stall_cpi' to build properly.

Before:
--
$ perf list | grep lsu_other
  lsu_other_stall_cpi
# perf stat -a --metrics lsu_other_stall_cpi /bin/sleep 1
Cannot find metric or group `lsu_other_stall_cpi'

 Usage: perf stat [] []

-M, --metrics 
  monitor specified metrics or metric groups (separated 
by ,)
--

After:
--
# perf stat -a --metrics lsu_other_stall_cpi /bin/sleep 1

 Performance counter stats for 'system wide':

   438,086,889  pm_cmplu_stall_lsu# 1.74 lsu_other_stall_cpi
[...]
--

Signed-off-by: Paul A. Clarke 
---
 tools/perf/util/expr.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/expr.h b/tools/perf/util/expr.h
index 87d627bb699b..a0991959cca4 100644
--- a/tools/perf/util/expr.h
+++ b/tools/perf/util/expr.h
@@ -2,7 +2,7 @@
 #ifndef PARSE_CTX_H
 #define PARSE_CTX_H 1
 
-#define EXPR_MAX_OTHER 20
+#define EXPR_MAX_OTHER 28
 #define MAX_PARSE_ID EXPR_MAX_OTHER
 
 struct expr_parse_id {
-- 
2.18.2