[PATCH v1 03/20] perf jevents: Add smi metric group for Intel models

Ian Rogers
2024-02-29T00:18:31Z

Allow duplicated metric to be dropped from json files.

Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/pmu-events/intel_metrics.py | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py
index 46866a25b166..20c25d142f24 100755
--- a/tools/perf/pmu-events/intel_metrics.py
+++ b/tools/perf/pmu-events/intel_metrics.py
@@ -2,7 +2,7 @@
# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
from metric import (d_ratio, has_event, max, Event, JsonEncodeMetric,
JsonEncodeMetricGroupDescriptions, LoadEvents, Metric,
- MetricGroup, Select)
+ MetricGroup, MetricRef, Select)
import argparse
import json
import math
@@ -62,9 +62,25 @@ def Rapl() -> MetricGroup:
description="Processor socket power consumption estimates")

+def Smi() -> MetricGroup:
+ aperf = Event('msr/aperf/')
+ cycles = Event('cycles')
+ smi_num = Event('msr/smi/')
+ smi_cycles = Select((aperf - cycles) / aperf, smi_num > 0, 0)
+ return MetricGroup('smi', [
+ Metric('smi_num', 'Number of SMI interrupts.',
+ smi_num, 'SMI#'),
+ # Note, the smi_cycles "Event" is really a reference to the metric.
+ Metric('smi_cycles',
+ 'Percentage of cycles spent in System Management Interrupts.',
+ smi_cycles, '100%', threshold=(MetricRef('smi_cycles') > 0.10))
+ ])
+
+
all_metrics = MetricGroup("", [
Idle(),
Rapl(),
+ Smi(),
])

if args.metricgroups:
--
2.44.0.278.ge034bb2e1d-goog