perf vendor events amd: Fix large metrics
PATCH v2 1/1 perf vendor events amd: Fix large metrics
There are cases where a metric requires more events than the number of available counters. E.g. AMD Zen, Zen 2 and Zen 3 processors have four data fabric counters but the "nps1_die_to_dram" metric has eight events. By default, the constituent events are placed in a group and since the events cannot be scheduled at the same time, the metric is not computed. The "all metrics" test also fails because of this.
Use the NO_GROUP_EVENTS constraint for such metrics which anyway expect the user to run perf with "--metric-no-group".
E.g.
$ sudo perf test -v 101
Before:
101: perf all metrics test :
--- start ---
test child forked, pid 37131
Testing branch_misprediction_ratio
Testing all_remote_links_outbound
Testing nps1_die_to_dram
Metric 'nps1_die_to_dram' not printed in:
Error:
Invalid event (dram_channel_data_controller_4) in per-thread mode, enable system wide with '-a'. Testing macro_ops_dispatched
Testing all_l2_cache_accesses
Testing all_l2_cache_hits
Testing all_l2_cache_misses
Testing ic_fetch_miss_ratio
Testing l2_cache_accesses_from_l2_hwpf
Testing l2_cache_misses_from_l2_hwpf
Testing op_cache_fetch_miss_ratio
Testing l3_read_miss_latency
Testing l1_itlb_misses
test child finished with -1
---- end ----
perf all metrics test: FAILED!
After:
101: perf all metrics test :
--- start ---
test child forked, pid 43766
Testing branch_misprediction_ratio
Testing all_remote_links_outbound
Testing nps1_die_to_dram
Testing macro_ops_dispatched
Testing all_l2_cache_accesses
Testing all_l2_cache_hits
Testing all_l2_cache_misses
Testing ic_fetch_miss_ratio
Testing l2_cache_accesses_from_l2_hwpf
Testing l2_cache_misses_from_l2_hwpf
Testing op_cache_fetch_miss_ratio
Testing l3_read_miss_latency
Testing l1_itlb_misses
test child finished with 0
---- end ----
perf all metrics test: Ok
---
Previous versions can be found at:
v1: https://lore.kernel.org/all/[email protected]/
Changes in v2:
- As suggested by Ian, use the NO_GROUP_EVENTS constraint instead of retrying the test scenario with --metric-no-group.
- Change the commit message accordingly.
tools/perf/pmu-events/arch/x86/amdzen1/recommended.json | 3 ++- tools/perf/pmu-events/arch/x86/amdzen2/recommended.json | 3 ++- tools/perf/pmu-events/arch/x86/amdzen3/recommended.json | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-)
tools/perf/pmu-events/arch/x86/amdzen1/recommended.json +2 -1
@@ -169,8 +169,9 @@ }, { "MetricName": "nps1_die_to_dram", - "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die) (may need --metric-no-group)", + "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die)", "MetricExpr": "dram_channel_data_controller_0 + dram_channel_data_controller_1 + dram_channel_data_controller_2 + dram_channel_data_controller_3 + dram_channel_data_controller_4 + dram_channel_data_controller_5 + dram_channel_data_controller_6 + dram_channel_data_controller_7", + "MetricConstraint": "NO_GROUP_EVENTS", "MetricGroup": "data_fabric", "PerPkg": "1", "ScaleUnit": "6.1e-5MiB"
tools/perf/pmu-events/arch/x86/amdzen2/recommended.json +2 -1
@@ -169,8 +169,9 @@ }, { "MetricName": "nps1_die_to_dram", - "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die) (may need --metric-no-group)", + "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die)", "MetricExpr": "dram_channel_data_controller_0 + dram_channel_data_controller_1 + dram_channel_data_controller_2 + dram_channel_data_controller_3 + dram_channel_data_controller_4 + dram_channel_data_controller_5 + dram_channel_data_controller_6 + dram_channel_data_controller_7", + "MetricConstraint": "NO_GROUP_EVENTS", "MetricGroup": "data_fabric", "PerPkg": "1", "ScaleUnit": "6.1e-5MiB"
tools/perf/pmu-events/arch/x86/amdzen3/recommended.json +2 -1
@@ -205,10 +205,11 @@ }, { "MetricName": "nps1_die_to_dram", - "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die) (may need --metric-no-group)", + "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die)", "MetricExpr": "dram_channel_data_controller_0 + dram_channel_data_controller_1 + dram_channel_data_controller_2 + dram_channel_data_controller_3 + dram_channel_data_controller_4 + dram_channel_data_controller_5 + dram_channel_data_controller_6 + dram_channel_data_controller_7", "MetricGroup": "data_fabric", "PerPkg": "1", + "MetricConstraint": "NO_GROUP_EVENTS", "ScaleUnit": "6.1e-5MiB" } ]
Signature · 1 line
2.34.1
Quoted 62 lines · Sandipan Das
There are cases where a metric requires more events than the number of available counters. E.g. AMD Zen, Zen 2 and Zen 3 processors have four data fabric counters but the "
nps1_die_to_dram" metric has eight events. By default, the constituent events are placed in a group and since the events cannot be scheduled at the same time, the metric is not computed. The "all metrics" test also fails because of this.Use the
NO_GROUP_EVENTSconstraint for such metrics which anyway expect the user to run perf with "--metric-no-group".E.g.
$ sudo perf test -v 101Before:
101: perf all metrics test :
--- start ---
test child forked, pid 37131
Testingbranch_misprediction_ratio
Testingall_remote_links_outbound
Testingnps1_die_to_dram
Metric 'nps1_die_to_dram' not printed in:
Error:
Invalid event (dram_channel_data_controller_4) in per-thread mode, enable system wide with '-a'. Testingmacro_ops_dispatched
Testingall_l2_cache_accesses
Testingall_l2_cache_hits
Testingall_l2_cache_misses
Testingic_fetch_miss_ratio
Testingl2_cache_accesses_from_l2_hwpf
Testingl2_cache_misses_from_l2_hwpf
Testingop_cache_fetch_miss_ratio
Testingl3_read_miss_latency
Testingl1_itlb_misses
test child finished with -1
---- end ----
perf all metrics test: FAILED!After:
101: perf all metrics test :
--- start ---
test child forked, pid 43766
Testingbranch_misprediction_ratio
Testingall_remote_links_outbound
Testingnps1_die_to_dram
Testingmacro_ops_dispatched
Testingall_l2_cache_accesses
Testingall_l2_cache_hits
Testingall_l2_cache_misses
Testingic_fetch_miss_ratio
Testingl2_cache_accesses_from_l2_hwpf
Testingl2_cache_misses_from_l2_hwpf
Testingop_cache_fetch_miss_ratio
Testingl3_read_miss_latency
Testingl1_itlb_misses
test child finished with 0
---- end ----
perf all metrics test: Ok
Quoted 3 lines
Reported-by Ayush Jain <[email protected]>Suggested-by Ian Rogers <[email protected]>Signed-off-by Sandipan Das <[email protected]>
Will there be a PMU driver fix so that the perf_event_open fails for the group? That way the weak group would work.
Thanks,
Ian
Quoted 65 lines
---
Previous versions can be found at:
v1: https://lore.kernel.org/all/[email protected]/Changes in v2:
- As suggested by Ian, use theNO_GROUP_EVENTSconstraint instead of retrying the test scenario with --metric-no-group.
- Change the commit message accordingly.tools/perf/pmu-events/arch/x86/amdzen1/recommended.json | 3 ++- tools/perf/pmu-events/arch/x86/amdzen2/recommended.json | 3 ++- tools/perf/pmu-events/arch/x86/amdzen3/recommended.json | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-)tools/perf/pmu-events/arch/x86/amdzen1/recommended.json +2
-1@@ -169,8 +169,9 @@ }, { "MetricName": "nps1_die_to_dram", - "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die) (may need --metric-no-group)", + "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die)", "MetricExpr": "dram_channel_data_controller_0 + dram_channel_data_controller_1 + dram_channel_data_controller_2 + dram_channel_data_controller_3 + dram_channel_data_controller_4 + dram_channel_data_controller_5 + dram_channel_data_controller_6 + dram_channel_data_controller_7", + "MetricConstraint": "NO_GROUP_EVENTS", "MetricGroup": "data_fabric", "PerPkg": "1", "ScaleUnit": "6.1e-5MiB"tools/perf/pmu-events/arch/x86/amdzen2/recommended.json +2
-1@@ -169,8 +169,9 @@ }, { "MetricName": "nps1_die_to_dram", - "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die) (may need --metric-no-group)", + "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die)", "MetricExpr": "dram_channel_data_controller_0 + dram_channel_data_controller_1 + dram_channel_data_controller_2 + dram_channel_data_controller_3 + dram_channel_data_controller_4 + dram_channel_data_controller_5 + dram_channel_data_controller_6 + dram_channel_data_controller_7", + "MetricConstraint": "NO_GROUP_EVENTS", "MetricGroup": "data_fabric", "PerPkg": "1", "ScaleUnit": "6.1e-5MiB"tools/perf/pmu-events/arch/x86/amdzen3/recommended.json +2
-2@@ -205,10 +205,11 @@ }, { "MetricName": "nps1_die_to_dram", - "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die) (may need --metric-no-group)", + "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die)", "MetricExpr": "dram_channel_data_controller_0 + dram_channel_data_controller_1 + dram_channel_data_controller_2 + dram_channel_data_controller_3 + dram_channel_data_controller_4 + dram_channel_data_controller_5 + dram_channel_data_controller_6 + dram_channel_data_controller_7", "MetricGroup": "data_fabric", "PerPkg": "1", + "MetricConstraint": "NO_GROUP_EVENTS", "ScaleUnit": "6.1e-5MiB" } ] --2.34.1
Hi Ian,
Quoted 63 lines · Ian Rogers
Quoted 62 lines · Sandipan Das
There are cases where a metric requires more events than the number of available counters. E.g. AMD Zen, Zen 2 and Zen 3 processors have four data fabric counters but the "
nps1_die_to_dram" metric has eight events. By default, the constituent events are placed in a group and since the events cannot be scheduled at the same time, the metric is not computed. The "all metrics" test also fails because of this.Use the
NO_GROUP_EVENTSconstraint for such metrics which anyway expect the user to run perf with "--metric-no-group".E.g.
$ sudo perf test -v 101Before:
101: perf all metrics test :
--- start ---
test child forked, pid 37131
Testingbranch_misprediction_ratio
Testingall_remote_links_outbound
Testingnps1_die_to_dram
Metric 'nps1_die_to_dram' not printed in:
Error:
Invalid event (dram_channel_data_controller_4) in per-thread mode, enable system wide with '-a'. Testingmacro_ops_dispatched
Testingall_l2_cache_accesses
Testingall_l2_cache_hits
Testingall_l2_cache_misses
Testingic_fetch_miss_ratio
Testingl2_cache_accesses_from_l2_hwpf
Testingl2_cache_misses_from_l2_hwpf
Testingop_cache_fetch_miss_ratio
Testingl3_read_miss_latency
Testingl1_itlb_misses
test child finished with -1
---- end ----
perf all metrics test: FAILED!After:
101: perf all metrics test :
--- start ---
test child forked, pid 43766
Testingbranch_misprediction_ratio
Testingall_remote_links_outbound
Testingnps1_die_to_dram
Testingmacro_ops_dispatched
Testingall_l2_cache_accesses
Testingall_l2_cache_hits
Testingall_l2_cache_misses
Testingic_fetch_miss_ratio
Testingl2_cache_accesses_from_l2_hwpf
Testingl2_cache_misses_from_l2_hwpf
Testingop_cache_fetch_miss_ratio
Testingl3_read_miss_latency
Testingl1_itlb_misses
test child finished with 0
---- end ----
perf all metrics test: Ok
Quoted 9 lines
Quoted 3 lines
Reported-by Ayush Jain <[email protected]>Suggested-by Ian Rogers <[email protected]>Signed-off-by Sandipan Das <[email protected]>Acked-by Ian Rogers <[email protected]>Will there be a PMU driver fix so that the
perf_event_openfails for the group? That way the weak group would work.
Yes, that's in our plan. Ravi (in CC) and I have discussed about adding group validation in the event_init() path.
- Sandipan
Em Thu, Jul 06, 2023 at 06:49:29AM -0700, Ian Rogers escreveu:
Quoted 63 lines · Sandipan Das
Quoted 62 lines
There are cases where a metric requires more events than the number of available counters. E.g. AMD Zen, Zen 2 and Zen 3 processors have four data fabric counters but the "
nps1_die_to_dram" metric has eight events. By default, the constituent events are placed in a group and since the events cannot be scheduled at the same time, the metric is not computed. The "all metrics" test also fails because of this.Use the
NO_GROUP_EVENTSconstraint for such metrics which anyway expect the user to run perf with "--metric-no-group".E.g.
$ sudo perf test -v 101Before:
101: perf all metrics test :
--- start ---
test child forked, pid 37131
Testingbranch_misprediction_ratio
Testingall_remote_links_outbound
Testingnps1_die_to_dram
Metric 'nps1_die_to_dram' not printed in:
Error:
Invalid event (dram_channel_data_controller_4) in per-thread mode, enable system wide with '-a'. Testingmacro_ops_dispatched
Testingall_l2_cache_accesses
Testingall_l2_cache_hits
Testingall_l2_cache_misses
Testingic_fetch_miss_ratio
Testingl2_cache_accesses_from_l2_hwpf
Testingl2_cache_misses_from_l2_hwpf
Testingop_cache_fetch_miss_ratio
Testingl3_read_miss_latency
Testingl1_itlb_misses
test child finished with -1
---- end ----
perf all metrics test: FAILED!After:
101: perf all metrics test :
--- start ---
test child forked, pid 43766
Testingbranch_misprediction_ratio
Testingall_remote_links_outbound
Testingnps1_die_to_dram
Testingmacro_ops_dispatched
Testingall_l2_cache_accesses
Testingall_l2_cache_hits
Testingall_l2_cache_misses
Testingic_fetch_miss_ratio
Testingl2_cache_accesses_from_l2_hwpf
Testingl2_cache_misses_from_l2_hwpf
Testingop_cache_fetch_miss_ratio
Testingl3_read_miss_latency
Testingl1_itlb_misses
test child finished with 0
---- end ----
perf all metrics test: Ok
Quoted 5 lines
Quoted 3 lines
Reported-by Ayush Jain <[email protected]>Suggested-by Ian Rogers <[email protected]>Signed-off-by Sandipan Das <[email protected]>Acked-by Ian Rogers <[email protected]>
Thanks, applied.
- Arnaldo
Quoted 71 lines
Will there be a PMU driver fix so that the
perf_event_openfails for the group? That way the weak group would work.Thanks,
IanQuoted 65 lines
---
Previous versions can be found at:
v1: https://lore.kernel.org/all/[email protected]/Changes in v2:
- As suggested by Ian, use theNO_GROUP_EVENTSconstraint instead of retrying the test scenario with --metric-no-group.
- Change the commit message accordingly.tools/perf/pmu-events/arch/x86/amdzen1/recommended.json | 3 ++- tools/perf/pmu-events/arch/x86/amdzen2/recommended.json | 3 ++- tools/perf/pmu-events/arch/x86/amdzen3/recommended.json | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-)tools/perf/pmu-events/arch/x86/amdzen1/recommended.json +2
-1@@ -169,8 +169,9 @@ }, { "MetricName": "nps1_die_to_dram", - "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die) (may need --metric-no-group)", + "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die)", "MetricExpr": "dram_channel_data_controller_0 + dram_channel_data_controller_1 + dram_channel_data_controller_2 + dram_channel_data_controller_3 + dram_channel_data_controller_4 + dram_channel_data_controller_5 + dram_channel_data_controller_6 + dram_channel_data_controller_7", + "MetricConstraint": "NO_GROUP_EVENTS", "MetricGroup": "data_fabric", "PerPkg": "1", "ScaleUnit": "6.1e-5MiB"tools/perf/pmu-events/arch/x86/amdzen2/recommended.json +2
-1@@ -169,8 +169,9 @@ }, { "MetricName": "nps1_die_to_dram", - "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die) (may need --metric-no-group)", + "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die)", "MetricExpr": "dram_channel_data_controller_0 + dram_channel_data_controller_1 + dram_channel_data_controller_2 + dram_channel_data_controller_3 + dram_channel_data_controller_4 + dram_channel_data_controller_5 + dram_channel_data_controller_6 + dram_channel_data_controller_7", + "MetricConstraint": "NO_GROUP_EVENTS", "MetricGroup": "data_fabric", "PerPkg": "1", "ScaleUnit": "6.1e-5MiB"tools/perf/pmu-events/arch/x86/amdzen3/recommended.json +2
-2@@ -205,10 +205,11 @@ }, { "MetricName": "nps1_die_to_dram", - "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die) (may need --metric-no-group)", + "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die)", "MetricExpr": "dram_channel_data_controller_0 + dram_channel_data_controller_1 + dram_channel_data_controller_2 + dram_channel_data_controller_3 + dram_channel_data_controller_4 + dram_channel_data_controller_5 + dram_channel_data_controller_6 + dram_channel_data_controller_7", "MetricGroup": "data_fabric", "PerPkg": "1", + "MetricConstraint": "NO_GROUP_EVENTS", "ScaleUnit": "6.1e-5MiB" } ] --2.34.1
Signature · 1 line
- Arnaldo
Quoted 65 lines · Arnaldo Carvalho de Melo
Em Thu, Jul 06, 2023 at 06:49:29AM -0700, Ian Rogers escreveu:
Quoted 63 lines · Sandipan Das
Quoted 62 lines
There are cases where a metric requires more events than the number of available counters. E.g. AMD Zen, Zen 2 and Zen 3 processors have four data fabric counters but the "
nps1_die_to_dram" metric has eight events. By default, the constituent events are placed in a group and since the events cannot be scheduled at the same time, the metric is not computed. The "all metrics" test also fails because of this.Use the
NO_GROUP_EVENTSconstraint for such metrics which anyway expect the user to run perf with "--metric-no-group".E.g.
$ sudo perf test -v 101Before:
101: perf all metrics test :
--- start ---
test child forked, pid 37131
Testingbranch_misprediction_ratio
Testingall_remote_links_outbound
Testingnps1_die_to_dram
Metric 'nps1_die_to_dram' not printed in:
Error:
Invalid event (dram_channel_data_controller_4) in per-thread mode, enable system wide with '-a'. Testingmacro_ops_dispatched
Testingall_l2_cache_accesses
Testingall_l2_cache_hits
Testingall_l2_cache_misses
Testingic_fetch_miss_ratio
Testingl2_cache_accesses_from_l2_hwpf
Testingl2_cache_misses_from_l2_hwpf
Testingop_cache_fetch_miss_ratio
Testingl3_read_miss_latency
Testingl1_itlb_misses
test child finished with -1
---- end ----
perf all metrics test: FAILED!After:
101: perf all metrics test :
--- start ---
test child forked, pid 43766
Testingbranch_misprediction_ratio
Testingall_remote_links_outbound
Testingnps1_die_to_dram
Testingmacro_ops_dispatched
Testingall_l2_cache_accesses
Testingall_l2_cache_hits
Testingall_l2_cache_misses
Testingic_fetch_miss_ratio
Testingl2_cache_accesses_from_l2_hwpf
Testingl2_cache_misses_from_l2_hwpf
Testingop_cache_fetch_miss_ratio
Testingl3_read_miss_latency
Testingl1_itlb_misses
test child finished with 0
---- end ----
perf all metrics test: Ok
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Reported-by Ayush Jain <[email protected]>Suggested-by Ian Rogers <[email protected]>Signed-off-by Sandipan Das <[email protected]>Acked-by Ian Rogers <[email protected]>Thanks, applied.
If I'm not too late..
Thanks,
Namhyung