perf jevents: Add software prefetch (swpf) metric group for Intel

Add metrics that breakdown software prefetch instruction use.

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:50 -08:00 committed by Arnaldo Carvalho de Melo
parent 37d0b00a1a
commit 397fdb3a24

View File

@ -261,6 +261,71 @@ def IntelBr():
description="breakdown of retired branch instructions")
def IntelSwpf() -> Optional[MetricGroup]:
ins = Event("instructions")
try:
s_ld = Event("MEM_INST_RETIRED.ALL_LOADS",
"MEM_UOPS_RETIRED.ALL_LOADS")
s_nta = Event("SW_PREFETCH_ACCESS.NTA")
s_t0 = Event("SW_PREFETCH_ACCESS.T0")
s_t1 = Event("SW_PREFETCH_ACCESS.T1_T2")
s_w = Event("SW_PREFETCH_ACCESS.PREFETCHW")
except:
return None
all_sw = s_nta + s_t0 + s_t1 + s_w
swp_r = d_ratio(all_sw, interval_sec)
ins_r = d_ratio(ins, all_sw)
ld_r = d_ratio(s_ld, all_sw)
return MetricGroup("lpm_swpf", [
MetricGroup("lpm_swpf_totals", [
Metric("lpm_swpf_totals_exec", "Software prefetch instructions per second",
swp_r, "swpf/s"),
Metric("lpm_swpf_totals_insn_per_pf",
"Average number of instructions between software prefetches",
ins_r, "insn/swpf"),
Metric("lpm_swpf_totals_loads_per_pf",
"Average number of loads between software prefetches",
ld_r, "loads/swpf"),
]),
MetricGroup("lpm_swpf_bkdwn", [
MetricGroup("lpm_swpf_bkdwn_nta", [
Metric("lpm_swpf_bkdwn_nta_per_swpf",
"Software prefetch NTA instructions as a percent of all prefetch instructions",
d_ratio(s_nta, all_sw), "100%"),
Metric("lpm_swpf_bkdwn_nta_rate",
"Software prefetch NTA instructions per second",
d_ratio(s_nta, interval_sec), "insn/s"),
]),
MetricGroup("lpm_swpf_bkdwn_t0", [
Metric("lpm_swpf_bkdwn_t0_per_swpf",
"Software prefetch T0 instructions as a percent of all prefetch instructions",
d_ratio(s_t0, all_sw), "100%"),
Metric("lpm_swpf_bkdwn_t0_rate",
"Software prefetch T0 instructions per second",
d_ratio(s_t0, interval_sec), "insn/s"),
]),
MetricGroup("lpm_swpf_bkdwn_t1_t2", [
Metric("lpm_swpf_bkdwn_t1_t2_per_swpf",
"Software prefetch T1 or T2 instructions as a percent of all prefetch instructions",
d_ratio(s_t1, all_sw), "100%"),
Metric("lpm_swpf_bkdwn_t1_t2_rate",
"Software prefetch T1 or T2 instructions per second",
d_ratio(s_t1, interval_sec), "insn/s"),
]),
MetricGroup("lpm_swpf_bkdwn_w", [
Metric("lpm_swpf_bkdwn_w_per_swpf",
"Software prefetch W instructions as a percent of all prefetch instructions",
d_ratio(s_w, all_sw), "100%"),
Metric("lpm_swpf_bkdwn_w_rate",
"Software prefetch W instructions per second",
d_ratio(s_w, interval_sec), "insn/s"),
]),
]),
], description="Software prefetch instruction breakdown")
def main() -> None:
global _args
@ -291,6 +356,7 @@ def main() -> None:
Smi(),
Tsx(),
IntelBr(),
IntelSwpf(),
])
if _args.metricgroups: