summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2026-01-27 21:44:42 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2026-01-28 21:18:45 +0300
commit3563030d4f77856bd0a32492fbe9edc3d36248ec (patch)
tree78945c699b7680fd247899faa6e59dee5cb8f99a /tools
parentfb4c0581740d99029761f4ad84fc0dbc48913eea (diff)
downloadlinux-3563030d4f77856bd0a32492fbe9edc3d36248ec.tar.xz
perf jevents: Add context switch metrics for AMD
Metrics break down context switches for different kinds of instruction. Reviewed-by: Sandipan Das <sandipan.das@amd.com> Signed-off-by: Ian Rogers <irogers@google.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: Thomas Falcon <thomas.falcon@intel.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>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/perf/pmu-events/amd_metrics.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py
index b3de74babe40..83e77ccc059e 100755
--- a/tools/perf/pmu-events/amd_metrics.py
+++ b/tools/perf/pmu-events/amd_metrics.py
@@ -122,6 +122,38 @@ def AmdBr():
description="breakdown of retired branch instructions")
+def AmdCtxSw() -> MetricGroup:
+ cs = Event("context\\-switches")
+ metrics = [
+ Metric("lpm_cs_rate", "Context switches per second",
+ d_ratio(cs, interval_sec), "ctxsw/s")
+ ]
+
+ ev = Event("instructions")
+ metrics.append(Metric("lpm_cs_instr", "Instructions per context switch",
+ d_ratio(ev, cs), "instr/cs"))
+
+ ev = Event("cycles")
+ metrics.append(Metric("lpm_cs_cycles", "Cycles per context switch",
+ d_ratio(ev, cs), "cycles/cs"))
+
+ ev = Event("ls_dispatch.pure_ld", "ls_dispatch.ld_dispatch")
+ metrics.append(Metric("lpm_cs_loads", "Loads per context switch",
+ d_ratio(ev, cs), "loads/cs"))
+
+ ev = Event("ls_dispatch.pure_st", "ls_dispatch.store_dispatch")
+ metrics.append(Metric("lpm_cs_stores", "Stores per context switch",
+ d_ratio(ev, cs), "stores/cs"))
+
+ ev = Event("ex_ret_brn_tkn")
+ metrics.append(Metric("lpm_cs_br_taken", "Branches taken per context switch",
+ d_ratio(ev, cs), "br_taken/cs"))
+
+ return MetricGroup("lpm_cs", metrics,
+ description=("Number of context switches per second, instructions "
+ "retired & core cycles between context switches"))
+
+
def AmdDtlb() -> Optional[MetricGroup]:
global _zen_model
if _zen_model >= 4:
@@ -438,6 +470,7 @@ def main() -> None:
all_metrics = MetricGroup("", [
AmdBr(),
+ AmdCtxSw(),
AmdDtlb(),
AmdItlb(),
AmdLdSt(),