[tip: perf/core] perf/x86/intel: Unwind cpuc state if PEBS buffer setup fails
"tip-bot2 for Dapeng Mi" <[email protected]>
| Newsgroups | org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <178654388461.442315.12524346721377197540.tip-bot2@tip-bot2> |
The following commit has been merged into the perf/core branch of tip: Commit-ID: 85182f902afda28ca7ae3408b72f31640a5cfc73 Gitweb: https://git.kernel.org/tip/85182f902afda28ca7ae3408b72f31640a5cfc73 Author: Dapeng Mi <[email protected]> AuthorDate: Fri, 17 Jul 2026 16:03:38 +08:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Mon, 10 Aug 2026 15:05:47 +02:00 perf/x86/intel: Unwind cpuc state if PEBS buffer setup fails intel_pmu_cpu_prepare() allocates per-CPU perf state first and then sets up the arch PEBS buffer. If alloc_arch_pebs_buf_on_cpu() fails, the previously allocated cpuc resources are left behind. Make the failure path call intel_cpuc_finish(cpuc) to release the per-CPU state allocated by intel_cpuc_prepare(). Signed-off-by: Dapeng Mi <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Thomas Falcon <[email protected]> Reviewed-by: Zide Chen <[email protected]> Link: https://patch.msgid.link/[email protected] --- arch/x86/events/intel/core.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index a991fc4..b47d2f0 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -5924,13 +5924,20 @@ err: static int intel_pmu_cpu_prepare(int cpu) { + struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu); int ret; - ret = intel_cpuc_prepare(&per_cpu(cpu_hw_events, cpu), cpu); + ret = intel_cpuc_prepare(cpuc, cpu); if (ret) return ret; - return alloc_arch_pebs_buf_on_cpu(cpu); + ret = alloc_arch_pebs_buf_on_cpu(cpu); + if (ret) { + intel_cpuc_finish(cpuc); + return ret; + } + + return 0; } static void flip_smm_bit(void *data)