Skip to contentSkip to conversation

perf/x86/intel: Use early_initcall() to hook bts_init()

PATCH Superseded Dapeng Mi 1 participant 3 messages Jun 6, 2025 – Jul 11, 2025

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Dapeng Mi

author
#0 lore raw

PATCH 1/1 perf/x86/intel: Use early_initcall() to hook bts_init()

After the commit 'd971342d38bf ("perf/x86/intel: Decouple BTS
initialization from PEBS initialization")' is introduced, x86_pmu.bts
would initialized in bts_init() which is hooked by arch_initcall().

Whereas init_hw_perf_events() is hooked by early_initcall(). Once the core PMU is initialized, nmi watchdog initialization is called immediately before bts_init() is called. It leads to the BTS buffer is not really initialized since bts_init() is not called and x86_pmu.bts is still false at that time. Worse, BTS buffer would never be initialized then unless all core PMU events are freed and reserve_ds_buffers() is called again.

Thus aligning with init_hw_perf_events(), use early_initcall() to hook bts_init() to ensure x86_pmu.bts is initialized before nmi watchdog initialization.

Fixes d971342d38bf ("perf/x86/intel: Decouple BTS initialization from PEBS initialization")
---
 arch/x86/events/intel/bts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/intel/bts.c +1 -1
index 9560f693fac0..f0d9729ed255 100644
@@ -642,4 +642,4 @@ static __init int bts_init(void)
 
 	return perf_pmu_register(&bts_pmu, "intel_bts", -1);
 }
-arch_initcall(bts_init);
+early_initcall(bts_init);

base-commit: e7d952cc39fca34386ec9f15f68cb2eaac01b5ae

Signature · 1 line
2.43.0
author
#1 lore raw

Kindly ping...   Thanks.

Quoted 34 lines · Dapeng Mi

After the commit 'd971342d38bf ("perf/x86/intel: Decouple BTS
initialization from PEBS initialization")' is introduced, x86_pmu.bts
would initialized in bts_init() which is hooked by arch_initcall().

Whereas init_hw_perf_events() is hooked by early_initcall(). Once the core PMU is initialized, nmi watchdog initialization is called immediately before bts_init() is called. It leads to the BTS buffer is not really initialized since bts_init() is not called and x86_pmu.bts is still false at that time. Worse, BTS buffer would never be initialized then unless all core PMU events are freed and reserve_ds_buffers() is called again.

Thus aligning with init_hw_perf_events(), use early_initcall() to hook bts_init() to ensure x86_pmu.bts is initialized before nmi watchdog initialization.

Fixes d971342d38bf ("perf/x86/intel: Decouple BTS initialization from PEBS initialization")
---
 arch/x86/events/intel/bts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/intel/bts.c +1 -1
index 9560f693fac0..f0d9729ed255 100644
@@ -642,4 +642,4 @@ static __init int bts_init(void)
 
 	return perf_pmu_register(&bts_pmu, "intel_bts", -1);
 }
-arch_initcall(bts_init);
+early_initcall(bts_init);

base-commit: e7d952cc39fca34386ec9f15f68cb2eaac01b5ae

author
#2 lore raw
In reply to Dapeng Mi

Kindly ping.

@Peter, not sure you have bandwidth to review this change? Thanks.

Quoted 34 lines · Dapeng Mi

After the commit 'd971342d38bf ("perf/x86/intel: Decouple BTS
initialization from PEBS initialization")' is introduced, x86_pmu.bts
would initialized in bts_init() which is hooked by arch_initcall().

Whereas init_hw_perf_events() is hooked by early_initcall(). Once the core PMU is initialized, nmi watchdog initialization is called immediately before bts_init() is called. It leads to the BTS buffer is not really initialized since bts_init() is not called and x86_pmu.bts is still false at that time. Worse, BTS buffer would never be initialized then unless all core PMU events are freed and reserve_ds_buffers() is called again.

Thus aligning with init_hw_perf_events(), use early_initcall() to hook bts_init() to ensure x86_pmu.bts is initialized before nmi watchdog initialization.

Fixes d971342d38bf ("perf/x86/intel: Decouple BTS initialization from PEBS initialization")
---
 arch/x86/events/intel/bts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/intel/bts.c +1 -1
index 9560f693fac0..f0d9729ed255 100644
@@ -642,4 +642,4 @@ static __init int bts_init(void)
 
 	return perf_pmu_register(&bts_pmu, "intel_bts", -1);
 }
-arch_initcall(bts_init);
+early_initcall(bts_init);

base-commit: e7d952cc39fca34386ec9f15f68cb2eaac01b5ae