Re: [External] : [RFC PATCH v2 1/6] perf vendor events arm64: Add topdown L1 metrics for neoverse-n2

Jing Zhang
2022-11-21T09:54:20Z

在 2022/11/15 下午7:19, John Garry 写道:
> On 15/11/2022 08:43, Jing Zhang wrote:
>> I didn't find out how to put the metric as an arch std event, it would be best if you could provide me with an example in the upstream code,
>> thank you very much.
>
> As things stand, I don't think it's supported. We only support regular events for std arch events (and not metrics).
>
> However we could expand support for metrics.
>
> For the example of hip08 and FRONTEND_BOUND, we would have:
>
> --->8---
>
> diff --git a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json
> index 6443a061e22a..5b1ca45224de 100644
> --- a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json
> +++ b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json
> @@ -1,10 +1,6 @@
>  [
>      {
> -        "MetricExpr": "FETCH_BUBBLE / (4 * CPU_CYCLES)",
> -        "PublicDescription": "Frontend bound L1 topdown metric",
> -        "BriefDescription": "Frontend bound L1 topdown metric",
> -        "MetricGroup": "TopDownL1",
> -        "MetricName": "frontend_bound"
> +        "ArchStdEvent": "FRONTEND_BOUND"
>      },
>      {
>          "MetricExpr": "(INST_SPEC - INST_RETIRED) / (4 * CPU_CYCLES)",
> diff --git a/tools/perf/pmu-events/arch/arm64/sbsa.json b/tools/perf/pmu-events/arch/arm64/sbsa.json
> new file mode 100644
> index 000000000000..10b9c0cccc40
> --- /dev/null
> +++ b/tools/perf/pmu-events/arch/arm64/sbsa.json
> @@ -0,0 +1,9 @@
> +[
> +    {
> +        "MetricExpr": "FETCH_BUBBLE / (4 * CPU_CYCLES)",
> +        "PublicDescription": "Frontend bound L1 topdown metric",
> +        "BriefDescription": "Frontend bound L1 topdown metric",
> +        "MetricGroup": "TopDownL1",
> +        "MetricName": "FRONTEND_BOUND"
> +    }
> +]
> diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
> index 0daa3e007528..77049853c0bf 100755
> --- a/tools/perf/pmu-events/jevents.py
> +++ b/tools/perf/pmu-events/jevents.py
> @@ -352,6 +352,8 @@ def preprocess_arch_std_files(archpath: str) -> None:
>        for event in read_json_events(item.path, topic=''):
>          if event.name:
>            _arch_std_events[event.name.lower()] = event
> +        if event.metric_name:
> +          _arch_std_events[event.metric_name.lower()] = event
>
>
>  def print_events_table_prefix(tblname: str) -> None:

Sorry for slow response.

I tried the method you provided, but it didn't work, is there any other steps I am missing?
Or is this method not currently supported?

diff --git a/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/metrics.json b/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/metrics
index 8ff1dfe..2ad30ec 100644
--- a/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/metrics.json
+++ b/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/metrics.json
@@ -1,10 +1,6 @@
[
{
- "MetricExpr": "(stall_slot_frontend - cpu_cycles) / (5 * cpu_cycles)",
- "PublicDescription": "Frontend bound L1 topdown metric",
- "BriefDescription": "Frontend bound L1 topdown metric",
- "MetricGroup": "TopDownL1",
- "MetricName": "frontend_bound"
+ "ArchStdEvent": "FRONTEND_BOUND"
},

diff --git a/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/pipeline.json b/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/pipeli
index f9fae15..e8536e2 100644
--- a/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/pipeline.json
+++ b/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/pipeline.json
@@ -6,9 +6,6 @@
{
"ArchStdEvent": "STALL_BACKEND_MEM"
- }
+ },
+ {
+ "MetricExpr": "(stall_slot_frontend - cpu_cycles) / (5 * cpu_cycles)",
+ "PublicDescription": "Frontend bound L1 topdown metric",
+ "BriefDescription": "Frontend bound L1 topdown metric",
+ "MetricGroup": "TopDownL1",
+ "MetricName": "FRONTEND_BOUND"
+ }
]

diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
index 0daa3e0..7704985 100755
--- a/tools/perf/pmu-events/jevents.py
+++ b/tools/perf/pmu-events/jevents.py
@@ -352,6 +352,8 @@ def preprocess_arch_std_files(archpath: str) -> None:
for event in read_json_events(item.path, topic=''):
if event.name:
_arch_std_events[event.name.lower()] = event
+ if event.metric_name:
+ _arch_std_events[event.metric_name.lower()] = event

#./perf stat -e FRONTEND_BOUND sleep 1
event syntax error: 'FRONTEND_BOUND'
\___ parser error
Run 'perf list' for a list of valid events

Usage: perf stat [<options>] [<command>]

-e, --event <event> event selector. use 'perf list' to list available events

diff --git a/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/pipeline.json b/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/pipeli
index f9fae15..1089ca0 100644
--- a/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/pipeline.json
+++ b/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/pipeline.json
@@ -6,18 +6,24 @@
"ArchStdEvent": "STALL_BACKEND"
},
{
- "ArchStdEvent": "STALL_SLOT_FRONTEND"
+ "ArchStdEvent": "STALL_SLOT_FRONTEND",
+ "MetricExpr": "STALL_SLOT_FRONTEND - CPU_CYCLES"
},
{

#./perf stat -e stall_slot_frontend sleep 1
Add CPU_CYCLES event to groups to get metric expression for stall_slot_frontend

Performance counter stats for 'sleep 1':

5,125,457 stall_slot_frontend //it's still the original value.

1.001017680 seconds time elapsed

0.001162000 seconds user
0.000000000 seconds sys

Thanks,
Jing