[PATCH v8 27/52] perf jevents: Add uop cache hit/miss rates for AMD

Ian Rogers posted 52 patches 3 weeks, 4 days ago
There is a newer version of this series
[PATCH v8 27/52] perf jevents: Add uop cache hit/miss rates for AMD
Posted by Ian Rogers 3 weeks, 4 days ago
Add metrics giving ratio of uop cache hits to misses.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/pmu-events/amd_metrics.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py
index da50337557f5..b2e3e2883022 100755
--- a/tools/perf/pmu-events/amd_metrics.py
+++ b/tools/perf/pmu-events/amd_metrics.py
@@ -584,6 +584,23 @@ def AmdSwpf() -> Optional[MetricGroup]:
                        description="Software prefetch breakdown (CCX L3 = L3 of current thread, Loc CCX = CCX cache on some socket)")
 
 
+def AmdUopCache() -> Optional[MetricGroup]:
+    try:
+        op_cache_hit = Event("op_cache_hit_miss.op_cache_hit")
+        op_cache_miss = Event("op_cache_hit_miss.op_cache_miss")
+    except:
+        return None
+    op_cache_total = op_cache_hit + op_cache_miss
+    return MetricGroup("lpm_uop_cache", [
+        Metric("lpm_uop_cache_hit_ratio", "Uop cache full or partial hits rate",
+               d_ratio(op_cache_hit, op_cache_total),
+               "100%"),
+        Metric("lpm_uop_cache_miss_ratio", "Uop cache misses rate",
+               d_ratio(op_cache_miss, op_cache_total),
+               "100%"),
+    ], description="Micro-op (uop) hit and miss rates.")
+
+
 def AmdUpc() -> Metric:
     ops = Event("ex_ret_ops", "ex_ret_cops")
     upc = d_ratio(ops, smt_cycles)
@@ -675,6 +692,7 @@ def main() -> None:
         AmdLdSt(),
         AmdHwpf(),
         AmdSwpf(),
+        AmdUopCache(),
         AmdUpc(),
         Idle(),
         Rapl(),
-- 
2.51.2.1041.gc1ab5b90ca-goog
Re: [PATCH v8 27/52] perf jevents: Add uop cache hit/miss rates for AMD
Posted by Sandipan Das 1 week, 5 days ago
On 11/13/2025 8:50 AM, Ian Rogers wrote:
> Add metrics giving ratio of uop cache hits to misses.
> 
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  tools/perf/pmu-events/amd_metrics.py | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py
> index da50337557f5..b2e3e2883022 100755
> --- a/tools/perf/pmu-events/amd_metrics.py
> +++ b/tools/perf/pmu-events/amd_metrics.py
> @@ -584,6 +584,23 @@ def AmdSwpf() -> Optional[MetricGroup]:
>                         description="Software prefetch breakdown (CCX L3 = L3 of current thread, Loc CCX = CCX cache on some socket)")
>  
>  
> +def AmdUopCache() -> Optional[MetricGroup]:
> +    try:
> +        op_cache_hit = Event("op_cache_hit_miss.op_cache_hit")
> +        op_cache_miss = Event("op_cache_hit_miss.op_cache_miss")
> +    except:
> +        return None
> +    op_cache_total = op_cache_hit + op_cache_miss
> +    return MetricGroup("lpm_uop_cache", [
> +        Metric("lpm_uop_cache_hit_ratio", "Uop cache full or partial hits rate",
> +               d_ratio(op_cache_hit, op_cache_total),
> +               "100%"),
> +        Metric("lpm_uop_cache_miss_ratio", "Uop cache misses rate",
> +               d_ratio(op_cache_miss, op_cache_total),
> +               "100%"),
> +    ], description="Micro-op (uop) hit and miss rates.")
> +
> +
>  def AmdUpc() -> Metric:
>      ops = Event("ex_ret_ops", "ex_ret_cops")
>      upc = d_ratio(ops, smt_cycles)
> @@ -675,6 +692,7 @@ def main() -> None:
>          AmdLdSt(),
>          AmdHwpf(),
>          AmdSwpf(),
> +        AmdUopCache(),
>          AmdUpc(),
>          Idle(),
>          Rapl(),

Reviewed-by: Sandipan Das <sandipan.das@amd.com>