Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH] perf jevents: Add dynamic IIO PCIe bandwidth metrics for Intel
@ 2026-07-09 18:39 Chun-Tse Shao
  2026-07-09 21:33 ` Chun-Tse Shao
  0 siblings, 1 reply; 2+ messages in thread
From: Chun-Tse Shao @ 2026-07-09 18:39 UTC (permalink / raw)
  To: linux-perf-users, linux-kernel
  Cc: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
	jolsa, irogers, adrian.hunter, james.clark, Chun-Tse Shao

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.

Signed-off-by: Chun-Tse Shao <ctshao@google.com>
Assisted-by: Gemini:gemini-3.1-pro-preview
---
 tools/perf/pmu-events/intel_metrics.py | 52 ++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py
index bc2b920d3a0d..4f8a123a375d 100755
--- a/tools/perf/pmu-events/intel_metrics.py
+++ b/tools/perf/pmu-events/intel_metrics.py
@@ -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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-09 21:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-09 18:39 [PATCH] perf jevents: Add dynamic IIO PCIe bandwidth metrics for Intel Chun-Tse Shao
2026-07-09 21:33 ` Chun-Tse Shao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox