x86/cpu: Add get_llc_id() helper function
authorKim Phillips <kim.phillips@amd.com>
Tue, 17 Aug 2021 22:10:46 +0000 (17:10 -0500)
committerIngo Molnar <mingo@kernel.org>
Thu, 26 Aug 2021 07:14:36 +0000 (09:14 +0200)
Factor out a helper function rather than export cpu_llc_id, which is
needed in order to be able to build the AMD uncore driver as a module.

Signed-off-by: Kim Phillips <kim.phillips@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20210817221048.88063-7-kim.phillips@amd.com
arch/x86/events/amd/uncore.c
arch/x86/include/asm/processor.h
arch/x86/kernel/cpu/amd.c
arch/x86/kernel/cpu/common.c

index 7fb50ad171e982035125c625398fc5f1115f3f7a..a01f9f1016d9b65df56e3ff8648f4511dcb2173c 100644 (file)
@@ -452,7 +452,7 @@ static int amd_uncore_cpu_starting(unsigned int cpu)
 
        if (amd_uncore_llc) {
                uncore = *per_cpu_ptr(amd_uncore_llc, cpu);
-               uncore->id = per_cpu(cpu_llc_id, cpu);
+               uncore->id = get_llc_id(cpu);
 
                uncore = amd_uncore_find_online_sibling(uncore, amd_uncore_llc);
                *per_cpu_ptr(amd_uncore_llc, cpu) = uncore;
index f3020c54e2cb3db1347a3e497770be8648f71b8a..33dd1575104e88666db8d516a6ce6abe3110d89e 100644 (file)
@@ -795,6 +795,8 @@ extern int set_tsc_mode(unsigned int val);
 
 DECLARE_PER_CPU(u64, msr_misc_features_shadow);
 
+extern u16 get_llc_id(unsigned int cpu);
+
 #ifdef CONFIG_CPU_SUP_AMD
 extern u32 amd_get_nodes_per_socket(void);
 extern u32 amd_get_highest_perf(void);
index b7c003013d4145457661a9715e1bcbff881d8a17..2131af9f2fa237517e64b56984634c8e94d53a73 100644 (file)
@@ -438,7 +438,7 @@ static void srat_detect_node(struct cpuinfo_x86 *c)
 
        node = numa_cpu_node(cpu);
        if (node == NUMA_NO_NODE)
-               node = per_cpu(cpu_llc_id, cpu);
+               node = get_llc_id(cpu);
 
        /*
         * On multi-fabric platform (e.g. Numascale NumaChip) a
index 64b805bd6a542ba2ad2a18f5fdb9e911f6dadb65..0f8885949e8c4b602fefc2eaf918d11a2957c051 100644 (file)
@@ -79,6 +79,12 @@ EXPORT_SYMBOL(smp_num_siblings);
 /* Last level cache ID of each logical CPU */
 DEFINE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id) = BAD_APICID;
 
+u16 get_llc_id(unsigned int cpu)
+{
+       return per_cpu(cpu_llc_id, cpu);
+}
+EXPORT_SYMBOL_GPL(get_llc_id);
+
 /* correctly size the local cpu masks */
 void __init setup_cpu_local_masks(void)
 {