All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] perf/x86/amd: Check CPU hotplug setup and unwind failures
@ 2026-11-12 23:50 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-12 23:50 ` [PATCH 2/2] perf/x86/amd/ibs: Fix missing CPU hotplug cleanup and unchecked init return Ayush Yaduvanshi
  0 siblings, 2 replies; 5+ messages in thread
From: Ayush Yaduvanshi @ 2026-11-12 23:50 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Thomas Gleixner, Borislav Petkov, Dave Hansen, x86
  Cc: Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, James Clark, H . Peter Anvin, linux-perf-users,
	linux-kernel, Ayush Yaduvanshi

The AMD Power PMU and IBS drivers register CPU hotplug callbacks during
initialization. Both paths need to handle failures in later initialization
steps.

The Power PMU change checks the return value of cpuhp_setup_state() and
removes the hotplug state if perf_pmu_register() fails.

The IBS change checks cpuhp_setup_state(), removes the hotplug state if
perf_event_ibs_init() fails, unregisters the syscore operations registered
earlier, and clears ibs_caps on failure.

This series makes the initialization error paths unwind resources acquired
before failure.

Ayush Yaduvanshi (2):
  perf/x86/amd/power: Fix missing CPU hotplug setup check and cleanup
  perf/x86/amd/ibs: Fix missing CPU hotplug cleanup and unchecked init
    return

 arch/x86/events/amd/ibs.c   | 26 +++++++++++++++++++++-----
 arch/x86/events/amd/power.c |  9 ++++++---
 2 files changed, 27 insertions(+), 8 deletions(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] perf/x86/amd/power: Fix missing CPU hotplug setup check and cleanup
  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 ` Ayush Yaduvanshi
  2026-11-13  0:04   ` sashiko-bot
  2026-11-12 23:50 ` [PATCH 2/2] perf/x86/amd/ibs: Fix missing CPU hotplug cleanup and unchecked init return Ayush Yaduvanshi
  1 sibling, 1 reply; 5+ messages in thread
From: Ayush Yaduvanshi @ 2026-11-12 23:50 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Thomas Gleixner, Borislav Petkov, Dave Hansen, x86
  Cc: Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, James Clark, H . Peter Anvin, linux-perf-users,
	linux-kernel, Ayush Yaduvanshi

Check the return value of cpuhp_setup_state() and remove the hotplug
state if perf_pmu_register() fails.

Signed-off-by: Ayush Yaduvanshi <ayush37735@gmail.com>
---
 arch/x86/events/amd/power.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/events/amd/power.c b/arch/x86/events/amd/power.c
index 66197214b010..2627d5269b52 100644
--- a/arch/x86/events/amd/power.c
+++ b/arch/x86/events/amd/power.c
@@ -282,13 +282,16 @@ static int __init amd_power_pmu_init(void)
 	}
 
 
-	cpuhp_setup_state(CPUHP_AP_PERF_X86_AMD_POWER_ONLINE,
-			  "perf/x86/amd/power:online",
-			  power_cpu_init, power_cpu_exit);
+	ret = cpuhp_setup_state(CPUHP_AP_PERF_X86_AMD_POWER_ONLINE,
+				"perf/x86/amd/power:online",
+				power_cpu_init, power_cpu_exit);
+	if (ret)
+		return ret;
 
 	ret = perf_pmu_register(&pmu_class, "power", -1);
 	if (WARN_ON(ret)) {
 		pr_warn("AMD Power PMU registration failed\n");
+		cpuhp_remove_state(CPUHP_AP_PERF_X86_AMD_POWER_ONLINE);
 		return ret;
 	}
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] perf/x86/amd/ibs: Fix missing CPU hotplug cleanup and unchecked init return
  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-12 23:50 ` Ayush Yaduvanshi
  2026-11-13  0:01   ` sashiko-bot
  1 sibling, 1 reply; 5+ messages in thread
From: Ayush Yaduvanshi @ 2026-11-12 23:50 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Thomas Gleixner, Borislav Petkov, Dave Hansen, x86
  Cc: Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, James Clark, H . Peter Anvin, linux-perf-users,
	linux-kernel, Ayush Yaduvanshi

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] perf/x86/amd/ibs: Fix missing CPU hotplug cleanup and unchecked init return
  2026-11-12 23:50 ` [PATCH 2/2] perf/x86/amd/ibs: Fix missing CPU hotplug cleanup and unchecked init return Ayush Yaduvanshi
@ 2026-11-13  0:01   ` sashiko-bot
  0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-13  0:01 UTC (permalink / raw)
  To: Ayush Yaduvanshi; +Cc: linux-perf-users

> 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>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261112235003.18608-1-ayush37735@gmail.com?part=2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] perf/x86/amd/power: Fix missing CPU hotplug setup check and cleanup
  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
  0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-13  0:04 UTC (permalink / raw)
  To: Ayush Yaduvanshi; +Cc: linux-perf-users

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] perf/x86/amd/power: missing Fixes trailer for commit
  c6a84daa3498
--

commit f8ef67a4aa6a417d77c332568d6bad06f58d1c90
Author: Ayush Yaduvanshi <ayush37735@gmail.com>

> perf/x86/amd/power: Fix missing CPU hotplug setup check and cleanup
>
> Check the return value of cpuhp_setup_state() and remove the hotplug
> state if perf_pmu_register() fails.
>
> Signed-off-by: Ayush Yaduvanshi <ayush37735@gmail.com>

[Severity: Low]
This fixes the unchecked cpuhp_setup_state() call and missing error-path
cleanup introduced when the driver was converted to the hotplug state
machine.  Should this include:

  Fixes: c6a84daa3498 ("perf/x86/amd/power: Convert the hotplug notifier to state machine")

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261112235003.18608-1-ayush37735@gmail.com?part=1

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-13  0:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 2/2] perf/x86/amd/ibs: Fix missing CPU hotplug cleanup and unchecked init return Ayush Yaduvanshi
2026-11-13  0:01   ` sashiko-bot

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.