All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ayush Yaduvanshi <ayush37735@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Thomas Gleixner <tglx@kernel.org>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org
Cc: Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	James Clark <james.clark@linaro.org>,
	"H . Peter Anvin" <hpa@zytor.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ayush Yaduvanshi <ayush37735@gmail.com>
Subject: [PATCH 2/2] perf/x86/amd/ibs: Fix missing CPU hotplug cleanup and unchecked init return
Date: Fri, 13 Nov 2026 05:20:03 +0530	[thread overview]
Message-ID: <20261112235003.18608-3-ayush37735@gmail.com> (raw)
In-Reply-To: <20261112235003.18608-1-ayush37735@gmail.com>

Check the return value of cpuhp_setup_state() and remove the hotplug state
if perf_event_ibs_init() fails. Unregister syscore operations and reset
ibs_caps on initialization failure.

Signed-off-by: Ayush Yaduvanshi <ayush37735@gmail.com>
---
 arch/x86/events/amd/ibs.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
index 66e67e27224f..2518cc7a24a6 100644
--- a/arch/x86/events/amd/ibs.c
+++ b/arch/x86/events/amd/ibs.c
@@ -2129,6 +2129,7 @@ static int x86_pmu_amd_ibs_dying_cpu(unsigned int cpu)
 static __init int amd_ibs_init(void)
 {
 	u32 caps;
+	int ret;
 
 	caps = __get_ibs_caps();
 	if (!caps)
@@ -2156,12 +2157,27 @@ static __init int amd_ibs_init(void)
 	 * x86_pmu_amd_ibs_starting_cpu will be called from core on
 	 * all online cpus.
 	 */
-	cpuhp_setup_state(CPUHP_AP_PERF_X86_AMD_IBS_STARTING,
-			  "perf/x86/amd/ibs:starting",
-			  x86_pmu_amd_ibs_starting_cpu,
-			  x86_pmu_amd_ibs_dying_cpu);
+	ret = cpuhp_setup_state(CPUHP_AP_PERF_X86_AMD_IBS_STARTING,
+				"perf/x86/amd/ibs:starting",
+				x86_pmu_amd_ibs_starting_cpu,
+				x86_pmu_amd_ibs_dying_cpu);
+	if (ret)
+		goto err_pm;
+
+	ret = perf_event_ibs_init();
+	if (ret) {
+		cpuhp_remove_state(CPUHP_AP_PERF_X86_AMD_IBS_STARTING);
+		goto err_pm;
+	}
 
-	return perf_event_ibs_init();
+	return 0;
+
+err_pm:
+#ifdef CONFIG_PM
+	unregister_syscore(&perf_ibs_syscore);
+#endif
+	ibs_caps = 0;
+	return ret;
 }
 
 /* Since we need the pci subsystem to init ibs we can't do this earlier: */
-- 
2.53.0


  parent reply	other threads:[~2026-11-12 23:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 23:50 [PATCH 0/2] perf/x86/amd: Check CPU hotplug setup and unwind failures Ayush Yaduvanshi
2026-11-12 23:50 ` [PATCH 1/2] perf/x86/amd/power: Fix missing CPU hotplug setup check and cleanup Ayush Yaduvanshi
2026-11-13  0:04   ` sashiko-bot
2026-11-12 23:50 ` Ayush Yaduvanshi [this message]
2026-11-13  0:01   ` [PATCH 2/2] perf/x86/amd/ibs: Fix missing CPU hotplug cleanup and unchecked init return sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261112235003.18608-3-ayush37735@gmail.com \
    --to=ayush37735@gmail.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.