Re: [PATCH v10 03/18] perf/x86/intel: Track common hybrid capabilities
From: Mi, Dapeng
Date: Tue Dec 01 2026 - 01:01:53 EST
Reviewed-by: Dapeng Mi <dapeng1.mi@xxxxxxxxxxxxxxx>
On 11/25/2026 5:38 AM, Zide Chen wrote:
> Now that intel_update_pmu_caps() updates intel_cap on hybrid_pmu[],
> the assignment in intel_pmu_init_hybrid() is obsolete and can be
> dropped. Additionally, ADL P-cores report perf_metrics correctly, so
> hardcoding perf_metrics for P-cores is not required.
>
> Intersect capabilities across all online PMU types. This clears all
> potentially inflated asymmetric features (such as rdpmc_metrics_clear)
> from x86_pmu.intel_cap when the BSP is a P-core.
>
> For erratum RPL018, set perf_metrics in the base x86_pmu.intel_cap
> on all-P-core systems to keep x86_pmu consistent and allow consumers
> like KVM to detect Topdown support.
>
> Opportunistically fix a typo in the comment.
>
> Fixes: f83d2f91d259 ("perf/x86/intel: Add Alder Lake Hybrid support")
> Signed-off-by: Zide Chen <zide.chen@xxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> ---
> v10: new patch.
> ---
> arch/x86/events/intel/core.c | 24 ++++++++++++++++--------
> 1 file changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
> index dbd84d82f36d..44bede63f0c6 100644
> --- a/arch/x86/events/intel/core.c
> +++ b/arch/x86/events/intel/core.c
> @@ -6280,11 +6280,23 @@ static void intel_update_pmu_caps(struct pmu *pmu)
>
> /*
> * Restore perf_metrics on platforms with broken
> - * perf_capablities.
> + * perf_capabilities.
> */
> if (intel_pmu_broken_perf_cap() &&
> - hybrid_pmu(pmu)->pmu_type == hybrid_big)
> + hybrid_pmu(pmu)->pmu_type == hybrid_big) {
> hybrid(pmu, intel_cap).perf_metrics = 1;
> + if (!cpu_feature_enabled(X86_FEATURE_HYBRID_CPU))
> + x86_pmu.intel_cap.perf_metrics = 1;
> + }
> +
> + /*
> + * For hybrid, x86_pmu.intel_cap tracks common capabilities
> + * across all online PMU types. A bitwise AND is safe because
> + * multi-bit PEBS/LBR format fields are identical across core
> + * types when supported, or zero if unsupported on a core.
> + */
> + x86_pmu.intel_cap.capabilities &=
> + hybrid(pmu, intel_cap).capabilities;
> }
> }
>
> @@ -7746,14 +7758,10 @@ static __always_inline int intel_pmu_init_hybrid(enum hybrid_pmu_type pmus)
> __EVENT_CONSTRAINT(0, pmu->cntr_mask64,
> 0, x86_pmu_num_counters(&pmu->pmu), 0, 0);
>
> - pmu->intel_cap.capabilities = x86_pmu.intel_cap.capabilities;
> - if (pmu->pmu_type & hybrid_small_tiny) {
> - pmu->intel_cap.perf_metrics = 0;
> + if (pmu->pmu_type & hybrid_small_tiny)
> pmu->mid_ack = true;
> - } else if (pmu->pmu_type & hybrid_big) {
> - pmu->intel_cap.perf_metrics = 1;
> + else if (pmu->pmu_type & hybrid_big)
> pmu->late_ack = true;
> - }
> }
>
> return 0;