perf jevents: Add smi metric group for Intel models

Allow duplicated metric to be dropped from JSON files.

Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Thomas Falcon <thomas.falcon@intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Benjamin Gray <bgray@linux.ibm.com>
Cc: Caleb Biggers <caleb.biggers@intel.com>
Cc: Edward Baker <edward.baker@intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Leo Yan <leo.yan@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Perry Taylor <perry.taylor@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Weilin Wang <weilin.wang@intel.com>
Cc: Xu Yang <xu.yang_2@nxp.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Ian Rogers 2026-01-27 10:44:46 -08:00 committed by Arnaldo Carvalho de Melo
parent 61b7b2ef64
commit 17d616b7d9

View File

@ -3,9 +3,9 @@
import argparse
import math
import os
from metric import (d_ratio, has_event, max, Event, JsonEncodeMetric,
from metric import (d_ratio, has_event, max, CheckPmu, Event, JsonEncodeMetric,
JsonEncodeMetricGroupDescriptions, LoadEvents, Metric,
MetricGroup, Select)
MetricGroup, MetricRef, Select)
# Global command line arguments.
_args = None
@ -56,6 +56,25 @@ def Rapl() -> MetricGroup:
description="Running Average Power Limit (RAPL) power consumption estimates")
def Smi() -> MetricGroup:
pmu = "<cpu_core or cpu_atom>" if CheckPmu("cpu_core") else "cpu"
aperf = Event('msr/aperf/')
cycles = Event('cycles')
smi_num = Event('msr/smi/')
smi_cycles = Select(Select((aperf - cycles) / aperf, smi_num > 0, 0),
has_event(aperf),
0)
return MetricGroup('smi', [
Metric('smi_num', 'Number of SMI interrupts.',
Select(smi_num, has_event(smi_num), 0), 'SMI#'),
# Note, the smi_cycles "Event" is really a reference to the metric.
Metric('smi_cycles',
'Percentage of cycles spent in System Management Interrupts. '
f'Requires /sys/bus/event_source/devices/{pmu}/freeze_on_smi to be 1.',
smi_cycles, '100%', threshold=(MetricRef('smi_cycles') > 0.10))
], description='System Management Interrupt metrics')
def main() -> None:
global _args
@ -83,6 +102,7 @@ def main() -> None:
all_metrics = MetricGroup("", [
Idle(),
Rapl(),
Smi(),
])
if _args.metricgroups: