mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-05 09:36:39 -04:00
perf jevents: Add load store breakdown metrics ldst for Intel
Give breakdown of number of instructions. Use the counter mask (cmask) to show the number of cycles taken to retire the instructions. 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:
committed by
Arnaldo Carvalho de Melo
parent
7413633e25
commit
d80edef231
@@ -8,7 +8,7 @@ import re
|
||||
from typing import Optional
|
||||
from metric import (d_ratio, has_event, max, CheckPmu, Event, JsonEncodeMetric,
|
||||
JsonEncodeMetricGroupDescriptions, Literal, LoadEvents,
|
||||
Metric, MetricGroup, MetricRef, Select)
|
||||
Metric, MetricConstraint, MetricGroup, MetricRef, Select)
|
||||
|
||||
# Global command line arguments.
|
||||
_args = None
|
||||
@@ -525,6 +525,90 @@ def IntelSwpf() -> Optional[MetricGroup]:
|
||||
], description="Software prefetch instruction breakdown")
|
||||
|
||||
|
||||
def IntelLdSt() -> Optional[MetricGroup]:
|
||||
if _args.model in [
|
||||
"bonnell",
|
||||
"nehalemep",
|
||||
"nehalemex",
|
||||
"westmereep-dp",
|
||||
"westmereep-sp",
|
||||
"westmereex",
|
||||
]:
|
||||
return None
|
||||
LDST_LD = Event("MEM_INST_RETIRED.ALL_LOADS", "MEM_UOPS_RETIRED.ALL_LOADS")
|
||||
LDST_ST = Event("MEM_INST_RETIRED.ALL_STORES",
|
||||
"MEM_UOPS_RETIRED.ALL_STORES")
|
||||
LDST_LDC1 = Event(f"{LDST_LD.name}/cmask=1/")
|
||||
LDST_STC1 = Event(f"{LDST_ST.name}/cmask=1/")
|
||||
LDST_LDC2 = Event(f"{LDST_LD.name}/cmask=2/")
|
||||
LDST_STC2 = Event(f"{LDST_ST.name}/cmask=2/")
|
||||
LDST_LDC3 = Event(f"{LDST_LD.name}/cmask=3/")
|
||||
LDST_STC3 = Event(f"{LDST_ST.name}/cmask=3/")
|
||||
ins = Event("instructions")
|
||||
LDST_CYC = Event("CPU_CLK_UNHALTED.THREAD",
|
||||
"CPU_CLK_UNHALTED.CORE_P",
|
||||
"CPU_CLK_UNHALTED.THREAD_P")
|
||||
LDST_PRE = None
|
||||
try:
|
||||
LDST_PRE = Event("LOAD_HIT_PREFETCH.SWPF", "LOAD_HIT_PRE.SW_PF")
|
||||
except:
|
||||
pass
|
||||
LDST_AT = None
|
||||
try:
|
||||
LDST_AT = Event("MEM_INST_RETIRED.LOCK_LOADS")
|
||||
except:
|
||||
pass
|
||||
cyc = LDST_CYC
|
||||
|
||||
ld_rate = d_ratio(LDST_LD, interval_sec)
|
||||
st_rate = d_ratio(LDST_ST, interval_sec)
|
||||
pf_rate = d_ratio(LDST_PRE, interval_sec) if LDST_PRE else None
|
||||
at_rate = d_ratio(LDST_AT, interval_sec) if LDST_AT else None
|
||||
|
||||
ldst_ret_constraint = MetricConstraint.GROUPED_EVENTS
|
||||
if LDST_LD.name == "MEM_UOPS_RETIRED.ALL_LOADS":
|
||||
ldst_ret_constraint = MetricConstraint.NO_GROUP_EVENTS_NMI
|
||||
|
||||
return MetricGroup("lpm_ldst", [
|
||||
MetricGroup("lpm_ldst_total", [
|
||||
Metric("lpm_ldst_total_loads", "Load/store instructions total loads",
|
||||
ld_rate, "loads"),
|
||||
Metric("lpm_ldst_total_stores", "Load/store instructions total stores",
|
||||
st_rate, "stores"),
|
||||
]),
|
||||
MetricGroup("lpm_ldst_prcnt", [
|
||||
Metric("lpm_ldst_prcnt_loads", "Percent of all instructions that are loads",
|
||||
d_ratio(LDST_LD, ins), "100%"),
|
||||
Metric("lpm_ldst_prcnt_stores", "Percent of all instructions that are stores",
|
||||
d_ratio(LDST_ST, ins), "100%"),
|
||||
]),
|
||||
MetricGroup("lpm_ldst_ret_lds", [
|
||||
Metric("lpm_ldst_ret_lds_1", "Retired loads in 1 cycle",
|
||||
d_ratio(max(LDST_LDC1 - LDST_LDC2, 0), cyc), "100%",
|
||||
constraint=ldst_ret_constraint),
|
||||
Metric("lpm_ldst_ret_lds_2", "Retired loads in 2 cycles",
|
||||
d_ratio(max(LDST_LDC2 - LDST_LDC3, 0), cyc), "100%",
|
||||
constraint=ldst_ret_constraint),
|
||||
Metric("lpm_ldst_ret_lds_3", "Retired loads in 3 or more cycles",
|
||||
d_ratio(LDST_LDC3, cyc), "100%"),
|
||||
]),
|
||||
MetricGroup("lpm_ldst_ret_sts", [
|
||||
Metric("lpm_ldst_ret_sts_1", "Retired stores in 1 cycle",
|
||||
d_ratio(max(LDST_STC1 - LDST_STC2, 0), cyc), "100%",
|
||||
constraint=ldst_ret_constraint),
|
||||
Metric("lpm_ldst_ret_sts_2", "Retired stores in 2 cycles",
|
||||
d_ratio(max(LDST_STC2 - LDST_STC3, 0), cyc), "100%",
|
||||
constraint=ldst_ret_constraint),
|
||||
Metric("lpm_ldst_ret_sts_3", "Retired stores in 3 more cycles",
|
||||
d_ratio(LDST_STC3, cyc), "100%"),
|
||||
]),
|
||||
Metric("lpm_ldst_ld_hit_swpf", "Load hit software prefetches per second",
|
||||
pf_rate, "swpf/s") if pf_rate else None,
|
||||
Metric("lpm_ldst_atomic_lds", "Atomic loads per second",
|
||||
at_rate, "loads/s") if at_rate else None,
|
||||
], description="Breakdown of load/store instructions")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
global _args
|
||||
|
||||
@@ -556,6 +640,7 @@ def main() -> None:
|
||||
Tsx(),
|
||||
IntelBr(),
|
||||
IntelL2(),
|
||||
IntelLdSt(),
|
||||
IntelPorts(),
|
||||
IntelSwpf(),
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user