Files
linux/tools/perf/pmu-events/common_metrics.py
Ian Rogers 82e53e7ae0 perf jevents: Add cycles breakdown metric for arm64/AMD/Intel
Breakdown cycles to user, kernel and guest. Add a common_metrics.py
file for such metrics.

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>
2026-01-28 15:18:46 -03:00

20 lines
956 B
Python

# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
from metric import (d_ratio, Event, Metric, MetricGroup)
def Cycles() -> MetricGroup:
cyc_k = Event("cpu\\-cycles:kHh") # exclude user and guest
cyc_g = Event("cpu\\-cycles:G") # exclude host
cyc_u = Event("cpu\\-cycles:uH") # exclude kernel, hypervisor and guest
cyc = cyc_k + cyc_g + cyc_u
return MetricGroup("lpm_cycles", [
Metric("lpm_cycles_total", "Total number of cycles", cyc, "cycles"),
Metric("lpm_cycles_user", "User cycles as a percentage of all cycles",
d_ratio(cyc_u, cyc), "100%"),
Metric("lpm_cycles_kernel", "Kernel cycles as a percentage of all cycles",
d_ratio(cyc_k, cyc), "100%"),
Metric("lpm_cycles_guest", "Hypervisor guest cycles as a percentage of all cycles",
d_ratio(cyc_g, cyc), "100%"),
], description="cycles breakdown per privilege level (users, kernel, guest)")