Skip to contentSkip to conversation

perf: arm_pmu: Fix build on arm if !CONFIG_GENERIC_ARCH_TOPOLOGY

PATCH In review Yicong Yang 2 participants 3 messages Nov 4, 2025 – Nov 5, 2025 Arm PMU profiling and debugging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf: arm_pmu: Fix build on arm if !CONFIG_GENERIC_ARCH_TOPOLOGY

The SMT implementation is retrieved by topology_core_has_smt() which depends on CONFIG_GENERIC_ARCH_TOPOLOGY. The config is optional on arm platforms so protect the usage with CONFIG_GENERIC_ARCH_TOPOLOGY.

Fixes c3d78c34ad00 ("perf: arm_pmuv3: Don't use PMCCNTR_EL0 on SMT cores")
---
 drivers/perf/arm_pmu.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/perf/arm_pmu.c +2 -0
index ae437791b5f8..f38bdeb906f0 100644
@@ -925,11 +925,13 @@ int armpmu_register(struct arm_pmu *pmu)
 	if (ret)
 		return ret;
 
+#ifdef CONFIG_GENERIC_ARCH_TOPOLOGY
 	/*
 	 * By this stage we know our supported CPUs on either DT/ACPI platforms,
 	 * detect the SMT implementation.
 	 */
 	pmu->has_smt = topology_core_has_smt(cpumask_first(&pmu->supported_cpus));
+#endif
 
 	if (!pmu->set_event_filter)
 		pmu->pmu.capabilities |= PERF_PMU_CAP_NO_EXCLUDE;
Signature · 1 line
2.50.1 (Apple Git-155)
maintainer
#1 lore raw
Quoted 32 lines · Yicong Yang

The SMT implementation is retrieved by topology_core_has_smt() which depends on CONFIG_GENERIC_ARCH_TOPOLOGY. The config is optional on arm platforms so protect the usage with CONFIG_GENERIC_ARCH_TOPOLOGY.

Fixes c3d78c34ad00 ("perf: arm_pmuv3: Don't use PMCCNTR_EL0 on SMT cores")
---
 drivers/perf/arm_pmu.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/perf/arm_pmu.c +2 -0
index ae437791b5f8..f38bdeb906f0 100644
@@ -925,11 +925,13 @@ int armpmu_register(struct arm_pmu *pmu)
 	if (ret)
 		return ret;
 
+#ifdef CONFIG_GENERIC_ARCH_TOPOLOGY
 	/*
 	 * By this stage we know our supported CPUs on either DT/ACPI platforms,
 	 * detect the SMT implementation.
 	 */
 	pmu->has_smt = topology_core_has_smt(cpumask_first(&pmu->supported_cpus));
+#endif
 
 	if (!pmu->set_event_filter)
 		pmu->pmu.capabilities |= PERF_PMU_CAP_NO_EXCLUDE;
Signature · 1 line
2.50.1 (Apple Git-155)

Wouldn't we be better off adding something like:

#else
static inline bool topology_core_has_smt(int cpu) { return false; } #endif /* CONFIG_GENERIC_ARCH_TOPOLOGY */

to the bottom of include/linux/arch_topology.h?

Will

#2 lore raw
Quoted 35 lines · Will Deacon
Quoted 32 lines · Yicong Yang

The SMT implementation is retrieved by topology_core_has_smt() which depends on CONFIG_GENERIC_ARCH_TOPOLOGY. The config is optional on arm platforms so protect the usage with CONFIG_GENERIC_ARCH_TOPOLOGY.

Fixes c3d78c34ad00 ("perf: arm_pmuv3: Don't use PMCCNTR_EL0 on SMT cores")
---
 drivers/perf/arm_pmu.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/perf/arm_pmu.c +2 -0
index ae437791b5f8..f38bdeb906f0 100644
@@ -925,11 +925,13 @@ int armpmu_register(struct arm_pmu *pmu)
 	if (ret)
 		return ret;
 
+#ifdef CONFIG_GENERIC_ARCH_TOPOLOGY
 	/*
 	 * By this stage we know our supported CPUs on either DT/ACPI platforms,
 	 * detect the SMT implementation.
 	 */
 	pmu->has_smt = topology_core_has_smt(cpumask_first(&pmu->supported_cpus));
+#endif
 
 	if (!pmu->set_event_filter)
 		pmu->pmu.capabilities |= PERF_PMU_CAP_NO_EXCLUDE;
Signature · 1 line
2.50.1 (Apple Git-155)

Wouldn't we be better off adding something like:

Quoted 5 lines

#else
static inline bool topology_core_has_smt(int cpu) { return false; } #endif /* CONFIG_GENERIC_ARCH_TOPOLOGY */

to the bottom of include/linux/arch_topology.h?

I was thinking so but found there's no !CONFIG_GENERIC_ARCH_TOPOLOGY
stubs for other functions. So I checked how this is handled in other places and follow in the same way [1]

but a stub will be neater here. will respin a version using the stub.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/kernel/smp.c?h=v6.18-rc4#n261

thanks.