From nobody Tue Sep 29 04:45:11 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07DF145A2B3; Wed, 12 Aug 2026 14:11:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786543892; cv=none; b=Qv8653Nmib3E7ZiEG8yk9/rUDDUGwUl0s4JJS9/4dLunrGvIq4AwJ9jgIzI5pS9MxeUIQNXFgH9ZtNl7msO+VHuNnRWVpqjVL4qxnIKed+yuc1wyjL25pN5PsgWyf+gY5eyLju+jcKi2mmoGPJeWfW4PUO4LkHc4+TNyzpvE734= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786543892; c=relaxed/simple; bh=81QKQ86ClLsMdMojeyXO8a+r+sMCR7o/0NrP620X4vQ=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=mMQPV2iW7f+6w0WX4t3vVInkEwmWAZiBMO8972PNWJjajXTYmKmmlsELNsvmEG8PPtdBxt1bap/she+pKM+XTXwJJ8AuRtTNmr1OFmemJlN7isS4VvC3qMKjRKAVwC5lb1R/vECnTLAsJCIJ6D4Mb+ODL7jSlrnBTIsGto/fZYQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=sxuJ9HQB; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=iEbjKsju; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="sxuJ9HQB"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="iEbjKsju" Date: Wed, 12 Aug 2026 14:11:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1786543889; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GRnBnHEktMcvQ/2F6+eGSQriYTGQgENa7h/cM+wckiw=; b=sxuJ9HQBSNGLBfC02DXxsX/Dr4AuU5IQDyvIgAyQYt9BuCbF4x4gnIF0y1n4EYENblsf07 KdW30sv86hU4a5Q525tiSNlAoeEBbMPDP9mXp0V4hyAwP/zktcLvdjajSz6lppXw73tg9v H8amDfhuqiXFbzbt/R/0uLqnEVTZ7F6TT4h0hufOtM9GK5Ex1VpD6z+O0SlH1JU0NAkK4Y zghIYv2Hg4UgLqrkA7bFsTs+7/LHQOqQUC680xtVhCMopXn7GeKGIuAmQLmvKVSV0nJDSh dUiMRPVf2oizDd8Cf3t2F/4TEm0cZsc2NDmAN82hBnBoAWKpNtrLx7zRpO5J8g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1786543889; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GRnBnHEktMcvQ/2F6+eGSQriYTGQgENa7h/cM+wckiw=; b=iEbjKsjuKhh2yHVCDamLfzkwL8LrpXESFBt/RR+b0alHqLILIidFms21nF0RQnagXLNRUb 5ejANWsOu93jLFBA== From: "tip-bot2 for Dapeng Mi" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/x86: Free hybrid state on PMU init failure Cc: Dapeng Mi , "Peter Zijlstra (Intel)" , Thomas Falcon , Zide Chen , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260717080342.1879573-3-dapeng1.mi@linux.intel.com> References: <20260717080342.1879573-3-dapeng1.mi@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178654388763.442315.16986886937303955682.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the perf/core branch of tip: Commit-ID: 96746e731e1626545e343974ca4673739dceb31b Gitweb: https://git.kernel.org/tip/96746e731e1626545e343974ca4673739= dceb31b Author: Dapeng Mi AuthorDate: Fri, 17 Jul 2026 16:03:36 +08:00 Committer: Peter Zijlstra CommitterDate: Mon, 10 Aug 2026 15:05:47 +02:00 perf/x86: Free hybrid state on PMU init failure If PMU initialization fails, for example in check_hw_exists(), hybrid state can be left partially initialized: x86_pmu.hybrid_pmu is not freed and perf_is_hybrid remains set. This can leak memory and leave stale hybrid state reachable after a failed init path. Add x86_pmu_free_hybrid() and use it on PMU init failure paths so all hybrid-related state is consistently reset. Signed-off-by: Dapeng Mi Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Thomas Falcon Reviewed-by: Zide Chen Link: https://patch.msgid.link/20260717080342.1879573-3-dapeng1.mi@linux.in= tel.com --- arch/x86/events/core.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 872d07a..6c63b27 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -2130,6 +2130,17 @@ void x86_pmu_show_pmu_cap(struct pmu *pmu) pr_info("... global_ctrl mask: %016llx\n", hybrid(pmu, intel_ctr= l)); } =20 +static void x86_pmu_free_hybrid(void) +{ + if (!x86_pmu.hybrid_pmu) + return; + + static_branch_disable(&perf_is_hybrid); + kfree(x86_pmu.hybrid_pmu); + x86_pmu.hybrid_pmu =3D NULL; + x86_pmu.num_hybrid_pmus =3D 0; +} + static int __init init_hw_perf_events(void) { struct x86_pmu_quirk *quirk; @@ -2258,9 +2269,6 @@ static int __init init_hw_perf_events(void) for (j =3D 0; j < i; j++) perf_pmu_unregister(&x86_pmu.hybrid_pmu[j].pmu); pr_warn("Failed to register hybrid PMUs\n"); - kfree(x86_pmu.hybrid_pmu); - x86_pmu.hybrid_pmu =3D NULL; - x86_pmu.num_hybrid_pmus =3D 0; goto out2; } } @@ -2276,6 +2284,7 @@ out: pmi_unregister: unregister_nmi_handler(NMI_LOCAL, "PMI"); out_bad_pmu: + x86_pmu_free_hybrid(); memset(&x86_pmu, 0, sizeof(x86_pmu)); return err; }