perf jevents: Add dynamic IIO PCIe bandwidth metrics for Intel
PATCH 1/1 perf jevents: Add dynamic IIO PCIe bandwidth metrics for Intel
Generate per-IIO-device PCIe read and write bandwidth metrics (iio_bandwidth_read_per_device_0, etc.) grouped under iio_bandwidth_per_device for Sapphire Rapids and newer architectures in intel_metrics.py.
By using has_event() checks across up to 24 possible IIO stack indices, runtime perf automatically monitors only the IIO root complexes present on the system without failing on missing instances.
--- tools/perf/pmu-events/intel_metrics.py | 52 ++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
tools/perf/pmu-events/intel_metrics.py +52 -0
@@ -1132,6 +1132,57 @@ def UncoreUpiBw() -> Optional[MetricGroup]: ], description="UPI Bandwidth") +def UncoreIioBw() -> Optional[MetricGroup]: + if _args.model not in [ + "sapphirerapids", + "emeraldrapids", + "graniterapids", + "sierraforest", + "clearwaterforest", + ]: + return None + + # On multi-socket x86 servers, there can be multiple IIO stacks per socket. + # We generate metrics up to index 23 with has_event check so runtime perf + # only measures the IIO instances present on the system. + max_iios = 24 + metrics = [] + scale = 4 / 1_000_000 + for i in range(max_iios): + rd_event = Event( + f"uncore_iio_{i}/UNC_IIO_DATA_REQ_OF_CPU.MEM_READ.ALL_PARTS/" + ) + wr_event = Event( + f"uncore_iio_{i}/UNC_IIO_DATA_REQ_OF_CPU.MEM_WRITE.ALL_PARTS/" + ) + rd_bw = Select(d_ratio(rd_event, interval_sec), has_event(rd_event), 0) + wr_bw = Select(d_ratio(wr_event, interval_sec), has_event(wr_event), 0) + metrics.append( + MetricGroup( + f"iio_bandwidth_per_device_iio{i}", + [ + Metric( + f"iio_bandwidth_read_per_device_{i}", + f"IIO {i} read bandwidth", + rd_bw, + f"{scale}MB/s", + ), + Metric( + f"iio_bandwidth_write_per_device_{i}", + f"IIO {i} write bandwidth", + wr_bw, + f"{scale}MB/s", + ), + ], + ) + ) + return MetricGroup( + "iio_bandwidth_per_device", + metrics, + description="IIO Read/Write Bandwidth per root complex", + ) + + def main() -> None: global _args
@@ -1179,6 +1230,7 @@ def main() -> None: UncoreMemBw(), UncoreMemSat(), UncoreUpiBw(), + UncoreIioBw(), ]) if _args.metricgroups:
Signature · 1 line
2.55.0.795.g602f6c329a-goog
+ Perry for reviewing the metric.
Quoted 89 lines · Chun-Tse Shao
Generate per-IIO-device PCIe read and write bandwidth metrics (
iio_bandwidth_read_per_device_0, etc.) grouped underiio_bandwidth_per_devicefor Sapphire Rapids and newer architectures inintel_metrics.py.By using
has_event()checks across up to 24 possible IIO stack indices, runtime perf automatically monitors only the IIO root complexes present on the system without failing on missing instances.Signed-off-by Chun-Tse Shao <[email protected]>Assisted-by Gemini:gemini-3.1-pro-preview--- tools/perf/pmu-events/intel_metrics.py | 52 ++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)tools/perf/pmu-events/intel_metrics.py +52
-1@@ -1132,6 +1132,57 @@ def UncoreUpiBw() -> Optional[MetricGroup]: ], description="UPI Bandwidth") +def UncoreIioBw() -> Optional[MetricGroup]: + if _args.model not in [ + "sapphirerapids", + "emeraldrapids", + "graniterapids", + "sierraforest", + "clearwaterforest", + ]: + return None + + # On multi-socket x86 servers, there can be multiple IIO stacks per socket. + # We generate metrics up to index 23 with has_event check so runtime perf + # only measures the IIO instances present on the system. + max_iios = 24 + metrics = [] + scale = 4 / 1_000_000 + for i in range(max_iios): + rd_event = Event( + f"uncore_iio_{i}/UNC_IIO_DATA_REQ_OF_CPU.MEM_READ.ALL_PARTS/" + ) + wr_event = Event( + f"uncore_iio_{i}/UNC_IIO_DATA_REQ_OF_CPU.MEM_WRITE.ALL_PARTS/" + ) + rd_bw = Select(d_ratio(rd_event, interval_sec), has_event(rd_event), 0) + wr_bw = Select(d_ratio(wr_event, interval_sec), has_event(wr_event), 0) + metrics.append( + MetricGroup( + f"iio_bandwidth_per_device_iio{i}", + [ + Metric( + f"iio_bandwidth_read_per_device_{i}", + f"IIO {i} read bandwidth", + rd_bw, + f"{scale}MB/s", + ), + Metric( + f"iio_bandwidth_write_per_device_{i}", + f"IIO {i} write bandwidth", + wr_bw, + f"{scale}MB/s", + ), + ], + ) + ) + return MetricGroup( + "iio_bandwidth_per_device", + metrics, + description="IIO Read/Write Bandwidth per root complex", + ) + + def main() -> None: global _args@@ -1179,6 +1230,7 @@ def main() -> None: UncoreMemBw(), UncoreMemSat(), UncoreUpiBw(), + UncoreIioBw(), ]) if _args.metricgroups: --2.55.0.795.g602f6c329a-goog
Quoted 17 lines · Chun-Tse Shao
+ Perry for reviewing the metric.
Quoted 12 lines · Chun-Tse Shao
Generate per-IIO-device PCIe read and write bandwidth metrics (
iio_bandwidth_read_per_device_0, etc.) grouped underiio_bandwidth_per_devicefor Sapphire Rapids and newer architectures inintel_metrics.py.By using
has_event()checks across up to 24 possible IIO stack indices, runtime perf automatically monitors only the IIO root complexes present on the system without failing on missing instances.Signed-off-by Chun-Tse Shao <[email protected]>Assisted-by Gemini:gemini-3.1-pro-preview
Thanks,
Ian
Quoted 77 lines
Quoted 77 lines
--- tools/perf/pmu-events/intel_metrics.py | 52 ++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)tools/perf/pmu-events/intel_metrics.py +52
-1@@ -1132,6 +1132,57 @@ def UncoreUpiBw() -> Optional[MetricGroup]: ], description="UPI Bandwidth") +def UncoreIioBw() -> Optional[MetricGroup]: + if _args.model not in [ + "sapphirerapids", + "emeraldrapids", + "graniterapids", + "sierraforest", + "clearwaterforest", + ]: + return None + + # On multi-socket x86 servers, there can be multiple IIO stacks per socket. + # We generate metrics up to index 23 with has_event check so runtime perf + # only measures the IIO instances present on the system. + max_iios = 24 + metrics = [] + scale = 4 / 1_000_000 + for i in range(max_iios): + rd_event = Event( + f"uncore_iio_{i}/UNC_IIO_DATA_REQ_OF_CPU.MEM_READ.ALL_PARTS/" + ) + wr_event = Event( + f"uncore_iio_{i}/UNC_IIO_DATA_REQ_OF_CPU.MEM_WRITE.ALL_PARTS/" + ) + rd_bw = Select(d_ratio(rd_event, interval_sec), has_event(rd_event), 0) + wr_bw = Select(d_ratio(wr_event, interval_sec), has_event(wr_event), 0) + metrics.append( + MetricGroup( + f"iio_bandwidth_per_device_iio{i}", + [ + Metric( + f"iio_bandwidth_read_per_device_{i}", + f"IIO {i} read bandwidth", + rd_bw, + f"{scale}MB/s", + ), + Metric( + f"iio_bandwidth_write_per_device_{i}", + f"IIO {i} write bandwidth", + wr_bw, + f"{scale}MB/s", + ), + ], + ) + ) + return MetricGroup( + "iio_bandwidth_per_device", + metrics, + description="IIO Read/Write Bandwidth per root complex", + ) + + def main() -> None: global _args@@ -1179,6 +1230,7 @@ def main() -> None: UncoreMemBw(), UncoreMemSat(), UncoreUpiBw(), + UncoreIioBw(), ]) if _args.metricgroups: --2.55.0.795.g602f6c329a-goog
Quoted 17 lines · Ian Rogers
Quoted 15 lines · Chun-Tse Shao
+ Perry for reviewing the metric.
Quoted 10 lines · Chun-Tse Shao
Generate per-IIO-device PCIe read and write bandwidth metrics (
iio_bandwidth_read_per_device_0, etc.) grouped underiio_bandwidth_per_devicefor Sapphire Rapids and newer architectures inintel_metrics.py.By using
has_event()checks across up to 24 possible IIO stack indices, runtime perf automatically monitors only the IIO root complexes present on the system without failing on missing instances.
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Signed-off-by Chun-Tse Shao <[email protected]>Assisted-by Gemini:gemini-3.1-pro-previewReviewed-by Ian Rogers <[email protected]>Thanks,
Ian
Thank you Ian for reviewing the patch! I had an offline discussion with Intel and we found:
1. iio_bandwidth_read/write is only missing on EMR and Intel fixed that through event updates:
lore.kernel.org/[email protected]
2. -A option does not work well with uncore events and I have a wip fix for that: lore.kernel.org/[email protected]
The patch is no longer necessary.
-CT
Quoted 78 lines
Quoted 78 lines
Quoted 78 lines
--- tools/perf/pmu-events/intel_metrics.py | 52 ++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)tools/perf/pmu-events/intel_metrics.py +52
-1@@ -1132,6 +1132,57 @@ def UncoreUpiBw() -> Optional[MetricGroup]: ], description="UPI Bandwidth") +def UncoreIioBw() -> Optional[MetricGroup]: + if _args.model not in [ + "sapphirerapids", + "emeraldrapids", + "graniterapids", + "sierraforest", + "clearwaterforest", + ]: + return None + + # On multi-socket x86 servers, there can be multiple IIO stacks per socket. + # We generate metrics up to index 23 with has_event check so runtime perf + # only measures the IIO instances present on the system. + max_iios = 24 + metrics = [] + scale = 4 / 1_000_000 + for i in range(max_iios): + rd_event = Event( + f"uncore_iio_{i}/UNC_IIO_DATA_REQ_OF_CPU.MEM_READ.ALL_PARTS/" + ) + wr_event = Event( + f"uncore_iio_{i}/UNC_IIO_DATA_REQ_OF_CPU.MEM_WRITE.ALL_PARTS/" + ) + rd_bw = Select(d_ratio(rd_event, interval_sec), has_event(rd_event), 0) + wr_bw = Select(d_ratio(wr_event, interval_sec), has_event(wr_event), 0) + metrics.append( + MetricGroup( + f"iio_bandwidth_per_device_iio{i}", + [ + Metric( + f"iio_bandwidth_read_per_device_{i}", + f"IIO {i} read bandwidth", + rd_bw, + f"{scale}MB/s", + ), + Metric( + f"iio_bandwidth_write_per_device_{i}", + f"IIO {i} write bandwidth", + wr_bw, + f"{scale}MB/s", + ), + ], + ) + ) + return MetricGroup( + "iio_bandwidth_per_device", + metrics, + description="IIO Read/Write Bandwidth per root complex", + ) + + def main() -> None: global _args@@ -1179,6 +1230,7 @@ def main() -> None: UncoreMemBw(), UncoreMemSat(), UncoreUpiBw(), + UncoreIioBw(), ]) if _args.metricgroups: --2.55.0.795.g602f6c329a-goog