Re: [PATCH 3/7] perf/x86/intel: Clear cpuc->pmu on hybrid PMU init failure

From: Mi, Dapeng

Date: Fri Jul 10 2026 - 04:27:30 EST


Sashiko raises comments about this patch.
https://lore.kernel.org/all/20260710072619.5E3011F000E9@xxxxxxxxxxxxxxx/

The latter 2 comments are valid. Would send v2 to address these 2 comments.
Thanks.


On 7/10/2026 2:51 PM, Dapeng Mi wrote:
> When init_hybrid_pmu() fails at check_hw_exists(), cpuc->pmu may still
> point to the default static PMU.
>
> The CPU hotplug rollback then runs intel_pmu_cpu_dead(). On hybrid
> systems, that path may call hybrid_pmu(cpuc->pmu), which is not valid
> for the static PMU pointer and can result in incorrect hybrid state
> access.
>
> Fix this by resetting cpuc->pmu to NULL on hybrid PMU init failure.
>
> Signed-off-by: Dapeng Mi <dapeng1.mi@xxxxxxxxxxxxxxx>
> ---
> arch/x86/events/intel/core.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
> index b39c6ce0efb5..9d4774278b50 100644
> --- a/arch/x86/events/intel/core.c
> +++ b/arch/x86/events/intel/core.c
> @@ -6329,8 +6329,10 @@ static bool init_hybrid_pmu(int cpu)
>
> intel_pmu_check_hybrid_pmus(pmu);
>
> - if (!check_hw_exists(&pmu->pmu, pmu->cntr_mask, pmu->fixed_cntr_mask))
> + if (!check_hw_exists(&pmu->pmu, pmu->cntr_mask, pmu->fixed_cntr_mask)) {
> + cpuc->pmu = NULL;
> return false;
> + }
>
> pr_info("%s PMU driver: ", pmu->name);
>