summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDapeng Mi <dapeng1.mi@linux.intel.com>2026-07-17 16:03:38 +0800
committerPeter Zijlstra <peterz@infradead.org>2026-08-10 15:05:47 +0200
commit85182f902afda28ca7ae3408b72f31640a5cfc73 (patch)
tree250a2d8a7aafdc9b18379ef6d43c5b17e31e8428
parent278a3731c9d08bc6ea489c1987c6b7a7020f5d2b (diff)
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 <dapeng1.mi@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Thomas Falcon <thomas.falcon@intel.com> Reviewed-by: Zide Chen <zide.chen@intel.com> Link: https://patch.msgid.link/20260717080342.1879573-5-dapeng1.mi@linux.intel.com
-rw-r--r--arch/x86/events/intel/core.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index a991fc4f1575..b47d2f00ac13 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)