Commit 1fee2701 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo
Browse files

perf jevents: Add C-State metrics from the PCU PMU for Intel

Use occupancy events fixed in:

  https://lore.kernel.org/lkml/20240226201517.3540187-1-irogers@google.com/



Metrics are at the socket level referring to cores, not hyperthreads.

Signed-off-by: default avatarIan Rogers <irogers@google.com>
Tested-by: default avatarThomas 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 2166b44b
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -815,6 +815,35 @@ def IntelLdSt() -> Optional[MetricGroup]:
    ], description="Breakdown of load/store instructions")


def UncoreCState() -> Optional[MetricGroup]:
    try:
        pcu_ticks = Event("UNC_P_CLOCKTICKS")
        c0 = Event("UNC_P_POWER_STATE_OCCUPANCY.CORES_C0")
        c3 = Event("UNC_P_POWER_STATE_OCCUPANCY.CORES_C3")
        c6 = Event("UNC_P_POWER_STATE_OCCUPANCY.CORES_C6")
    except:
        return None

    num_cores = Literal("#num_cores") / Literal("#num_packages")

    max_cycles = pcu_ticks * num_cores
    total_cycles = c0 + c3 + c6

    # remove fused-off cores which show up in C6/C7.
    c6 = Select(max(c6 - (total_cycles - max_cycles), 0),
                total_cycles > max_cycles,
                c6)

    return MetricGroup("lpm_cstate", [
        Metric("lpm_cstate_c0", "C-State cores in C0/C1",
               d_ratio(c0, pcu_ticks), "cores"),
        Metric("lpm_cstate_c3", "C-State cores in C3",
               d_ratio(c3, pcu_ticks), "cores"),
        Metric("lpm_cstate_c6", "C-State cores in C6/C7",
               d_ratio(c6, pcu_ticks), "cores"),
    ])


def UncoreDir() -> Optional[MetricGroup]:
    try:
        m2m_upd = Event("UNC_M2M_DIRECTORY_UPDATE.ANY")
@@ -979,6 +1008,7 @@ def main() -> None:
        IntelMlp(),
        IntelPorts(),
        IntelSwpf(),
        UncoreCState(),
        UncoreDir(),
        UncoreMem(),
        UncoreMemBw(),