[PATCH v6 1/9] x86/topology: Export topo_lookup_cpuid() for resctrl use

From: Chen Yu

Date: Sat Jul 25 2026 - 05:32:39 EST


Enhanced RDT (ERDT) enumerates its monitoring and control resources
through ACPI tables that identify each CPU by its x2APIC ID. To
associate this firmware-provided data with the kernel's per-CPU
structures, ERDT must translate those x2APIC IDs into logical CPU
numbers.

topo_lookup_cpuid() already performs this translation, but it is
static to topology.c and therefore not reachable from resctrl.

Export topo_lookup_cpuid() and add its declaration to asm/apic.h so
that ERDT can resolve x2APIC IDs from ACPI tables to logical CPU
numbers.

No functional change intended.

Signed-off-by: Chen Yu <yu.c.chen@xxxxxxxxx>
Tested-by: Hongyu Ning <hongyu.ning@xxxxxxxxxxxxxxx>
---
v5->v6:
Move this patch to the beginning of the series because it touches a
different subsystem than the rest of the series. (Reinette Chatre)
Order the commit tags per Documentation/process/maintainer-tip.rst.
(Reinette Chatre)
---
arch/x86/include/asm/apic.h | 1 +
arch/x86/kernel/cpu/topology.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index 9cd493d467d4..bb84651b14bd 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -54,6 +54,7 @@ static inline void x86_32_probe_apic(void) { }
#endif

extern u32 cpuid_to_apicid[];
+int topo_lookup_cpuid(u32 apic_id);

#define CPU_ACPIID_INVALID U32_MAX

diff --git a/arch/x86/kernel/cpu/topology.c b/arch/x86/kernel/cpu/topology.c
index 4913b64ec592..bcee70fb9277 100644
--- a/arch/x86/kernel/cpu/topology.c
+++ b/arch/x86/kernel/cpu/topology.c
@@ -92,7 +92,7 @@ static inline u32 topo_apicid(u32 apicid, enum x86_topology_domains dom)
return apicid & (UINT_MAX << x86_topo_system.dom_shifts[dom - 1]);
}

-static int topo_lookup_cpuid(u32 apic_id)
+int topo_lookup_cpuid(u32 apic_id)
{
int i;

--
2.25.1