]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/topology: Introduce topology_logical_core_id()
authorK Prateek Nayak <kprateek.nayak@amd.com>
Fri, 15 Nov 2024 06:07:58 +0000 (06:07 +0000)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 2 Dec 2024 11:01:35 +0000 (12:01 +0100)
On x86, topology_core_id() returns a unique core ID within the PKG
domain. Looking at match_smt() suggests that a core ID just needs to be
unique within a LLC domain. For use cases such as the core RAPL PMU,
there exists a need for a unique core ID across the entire system with
multiple PKG domains. Introduce topology_logical_core_id() to derive a
unique core ID across the system.

Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
Signed-off-by: Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: "Gautham R. Shenoy" <gautham.shenoy@amd.com>
Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name>
Link: https://lore.kernel.org/r/20241115060805.447565-3-Dhananjay.Ugwekar@amd.com
Documentation/arch/x86/topology.rst
arch/x86/include/asm/processor.h
arch/x86/include/asm/topology.h
arch/x86/kernel/cpu/debugfs.c
arch/x86/kernel/cpu/topology_common.c

index 7352ab89a55ae4fc79dfe7cee997e2345576d2fe..c12837e61bda53f4700c9944ba08d7c761b211fe 100644 (file)
@@ -135,6 +135,10 @@ Thread-related topology information in the kernel:
     The ID of the core to which a thread belongs. It is also printed in /proc/cpuinfo
     "core_id."
 
+  - topology_logical_core_id();
+
+    The logical core ID to which a thread belongs.
+
 
 
 System topology examples
index c0975815980c84ada5613111987239b70d9438cd..cfd8a559142166814bf15b9305a227c6b70537da 100644 (file)
@@ -98,6 +98,7 @@ struct cpuinfo_topology {
        // Logical ID mappings
        u32                     logical_pkg_id;
        u32                     logical_die_id;
+       u32                     logical_core_id;
 
        // AMD Node ID and Nodes per Package info
        u32                     amd_node_id;
index fd41103ad342c4419b0d886320f7dd4aaf7f218d..3973cb9bb2e69056d520cb08122420ac05ccaf97 100644 (file)
@@ -143,6 +143,7 @@ extern const struct cpumask *cpu_clustergroup_mask(int cpu);
 #define topology_logical_package_id(cpu)       (cpu_data(cpu).topo.logical_pkg_id)
 #define topology_physical_package_id(cpu)      (cpu_data(cpu).topo.pkg_id)
 #define topology_logical_die_id(cpu)           (cpu_data(cpu).topo.logical_die_id)
+#define topology_logical_core_id(cpu)          (cpu_data(cpu).topo.logical_core_id)
 #define topology_die_id(cpu)                   (cpu_data(cpu).topo.die_id)
 #define topology_core_id(cpu)                  (cpu_data(cpu).topo.core_id)
 #define topology_ppin(cpu)                     (cpu_data(cpu).ppin)
index 10719aba627680db91a54097bfb8f9266c8fde36..cacfd3f6abeffcea1ebdec5ca295590d573f68ad 100644 (file)
@@ -25,6 +25,7 @@ static int cpu_debug_show(struct seq_file *m, void *p)
        seq_printf(m, "cpu_type:            %s\n", get_topology_cpu_type_name(c));
        seq_printf(m, "logical_pkg_id:      %u\n", c->topo.logical_pkg_id);
        seq_printf(m, "logical_die_id:      %u\n", c->topo.logical_die_id);
+       seq_printf(m, "logical_core_id:     %u\n", c->topo.logical_core_id);
        seq_printf(m, "llc_id:              %u\n", c->topo.llc_id);
        seq_printf(m, "l2c_id:              %u\n", c->topo.l2c_id);
        seq_printf(m, "amd_node_id:         %u\n", c->topo.amd_node_id);
index 8277c64f88dbfd9983f1a826dbdebed072e8c087..b5a5e141146996be94930d093644a38041766660 100644 (file)
@@ -185,6 +185,7 @@ static void topo_set_ids(struct topo_scan *tscan, bool early)
        if (!early) {
                c->topo.logical_pkg_id = topology_get_logical_id(apicid, TOPO_PKG_DOMAIN);
                c->topo.logical_die_id = topology_get_logical_id(apicid, TOPO_DIE_DOMAIN);
+               c->topo.logical_core_id = topology_get_logical_id(apicid, TOPO_CORE_DOMAIN);
        }
 
        /* Package relative core ID */