x86/cpu: Move cpu_core_id into topology info
authorThomas Gleixner <tglx@linutronix.de>
Mon, 14 Aug 2023 08:18:34 +0000 (10:18 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 10 Oct 2023 12:38:17 +0000 (14:38 +0200)
Rename it to core_id and stick it to the other ID fields.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Juergen Gross <jgross@suse.com>
Tested-by: Sohil Mehta <sohil.mehta@intel.com>
Tested-by: Michael Kelley <mikelley@microsoft.com>
Tested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Zhang Rui <rui.zhang@intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20230814085112.566519388@linutronix.de
arch/x86/include/asm/processor.h
arch/x86/include/asm/topology.h
arch/x86/kernel/amd_nb.c
arch/x86/kernel/cpu/amd.c
arch/x86/kernel/cpu/common.c
arch/x86/kernel/cpu/hygon.c
arch/x86/kernel/cpu/proc.c
arch/x86/kernel/cpu/topology.c
arch/x86/kernel/smpboot.c

index 662e9736c3d095df0650f03eeb5d62f88a90dcd3..a63760284cbab9d295691b60e9da08893eb2f53a 100644 (file)
@@ -89,6 +89,9 @@ struct cpuinfo_topology {
 
        // Physical die ID on AMD, Relative on Intel
        u32                     die_id;
+
+       // Core ID relative to the package
+       u32                     core_id;
 };
 
 struct cpuinfo_x86 {
@@ -143,7 +146,6 @@ struct cpuinfo_x86 {
        /* Logical processor id: */
        u16                     logical_proc_id;
        /* Core id: */
-       u16                     cpu_core_id;
        u16                     logical_die_id;
        /* Index into per_cpu list: */
        u16                     cpu_index;
index cf43b51e2162afb97ed8bd85b7dc408702ded442..7fa567c1f593010604163618f7c57b40ad8cc6d9 100644 (file)
@@ -109,7 +109,7 @@ extern const struct cpumask *cpu_clustergroup_mask(int cpu);
 #define topology_physical_package_id(cpu)      (cpu_data(cpu).topo.pkg_id)
 #define topology_logical_die_id(cpu)           (cpu_data(cpu).logical_die_id)
 #define topology_die_id(cpu)                   (cpu_data(cpu).topo.die_id)
-#define topology_core_id(cpu)                  (cpu_data(cpu).cpu_core_id)
+#define topology_core_id(cpu)                  (cpu_data(cpu).topo.core_id)
 #define topology_ppin(cpu)                     (cpu_data(cpu).ppin)
 
 extern unsigned int __max_die_per_package;
index 356de955e78ddcc1a0c63a50c7a43a7e855ce758..75df3c8712fcd02a0e541ca9c43ab406079b9f5e 100644 (file)
@@ -386,7 +386,7 @@ int amd_get_subcaches(int cpu)
 
        pci_read_config_dword(link, 0x1d4, &mask);
 
-       return (mask >> (4 * cpu_data(cpu).cpu_core_id)) & 0xf;
+       return (mask >> (4 * cpu_data(cpu).topo.core_id)) & 0xf;
 }
 
 int amd_set_subcaches(int cpu, unsigned long mask)
@@ -412,7 +412,7 @@ int amd_set_subcaches(int cpu, unsigned long mask)
                pci_write_config_dword(nb->misc, 0x1b8, reg & ~0x180000);
        }
 
-       cuid = cpu_data(cpu).cpu_core_id;
+       cuid = cpu_data(cpu).topo.core_id;
        mask <<= 4 * cuid;
        mask |= (0xf ^ (1 << cuid)) << 26;
 
index c10f5f7372f380f7929b4c6cec91c319ed8a51c7..66bb92995a12ca662785856e4505c791160ea923 100644 (file)
@@ -378,7 +378,7 @@ static int nearby_node(int apicid)
 #endif
 
 /*
- * Fix up cpu_core_id for pre-F17h systems to be in the
+ * Fix up topo::core_id for pre-F17h systems to be in the
  * [0 .. cores_per_node - 1] range. Not really needed but
  * kept so as not to break existing setups.
  */
@@ -390,7 +390,7 @@ static void legacy_fixup_core_id(struct cpuinfo_x86 *c)
                return;
 
        cus_per_node = c->x86_max_cores / nodes_per_socket;
-       c->cpu_core_id %= cus_per_node;
+       c->topo.core_id %= cus_per_node;
 }
 
 /*
@@ -416,7 +416,7 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
                        c->cu_id = ebx & 0xff;
 
                if (c->x86 >= 0x17) {
-                       c->cpu_core_id = ebx & 0xff;
+                       c->topo.core_id = ebx & 0xff;
 
                        if (smp_num_siblings > 1)
                                c->x86_max_cores /= smp_num_siblings;
@@ -459,7 +459,7 @@ static void amd_detect_cmp(struct cpuinfo_x86 *c)
 
        bits = c->x86_coreid_bits;
        /* Low order bits define the core id (index of core in socket) */
-       c->cpu_core_id = c->topo.initial_apicid & ((1 << bits)-1);
+       c->topo.core_id = c->topo.initial_apicid & ((1 << bits)-1);
        /* Convert the initial APIC ID into the socket ID */
        c->topo.pkg_id = c->topo.initial_apicid >> bits;
        /* use socket ID also for last level cache */
index 8f60d5535efe63e423e99e0cb096e7a33d7d88cd..414766545ef7f6cafe28f45bf5f97b6569757f63 100644 (file)
@@ -922,8 +922,8 @@ void detect_ht(struct cpuinfo_x86 *c)
 
        core_bits = get_count_order(c->x86_max_cores);
 
-       c->cpu_core_id = apic->phys_pkg_id(c->topo.initial_apicid, index_msb) &
-                                      ((1 << core_bits) - 1);
+       c->topo.core_id = apic->phys_pkg_id(c->topo.initial_apicid, index_msb) &
+               ((1 << core_bits) - 1);
 #endif
 }
 
index 9190be47c6512ede5982ed7f7d6b6fa1655a5b15..f3898b5af9f30b1fc859faa6108c02e3d25a1531 100644 (file)
@@ -74,7 +74,7 @@ static void hygon_get_topology(struct cpuinfo_x86 *c)
 
                c->topo.die_id  = ecx & 0xff;
 
-               c->cpu_core_id = ebx & 0xff;
+               c->topo.core_id = ebx & 0xff;
 
                if (smp_num_siblings > 1)
                        c->x86_max_cores /= smp_num_siblings;
@@ -120,7 +120,7 @@ static void hygon_detect_cmp(struct cpuinfo_x86 *c)
 
        bits = c->x86_coreid_bits;
        /* Low order bits define the core id (index of core in socket) */
-       c->cpu_core_id = c->topo.initial_apicid & ((1 << bits)-1);
+       c->topo.core_id = c->topo.initial_apicid & ((1 << bits)-1);
        /* Convert the initial APIC ID into the socket ID */
        c->topo.pkg_id = c->topo.initial_apicid >> bits;
        /* use socket ID also for last level cache */
index 366af2e392d2bf896dee52034407a109a154b92f..e65fae63660e3f1c50922e918ac99caa1adbac10 100644 (file)
@@ -23,7 +23,7 @@ static void show_cpuinfo_core(struct seq_file *m, struct cpuinfo_x86 *c,
        seq_printf(m, "physical id\t: %d\n", c->topo.pkg_id);
        seq_printf(m, "siblings\t: %d\n",
                   cpumask_weight(topology_core_cpumask(cpu)));
-       seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id);
+       seq_printf(m, "core id\t\t: %d\n", c->topo.core_id);
        seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
        seq_printf(m, "apicid\t\t: %d\n", c->topo.apicid);
        seq_printf(m, "initial apicid\t: %d\n", c->topo.initial_apicid);
index 3b48bc324dfd346f91734d7b0824e8ac306a7d4e..dc136703566f3fb97cc77fde581a373a8688c909 100644 (file)
@@ -146,7 +146,7 @@ int detect_extended_topology(struct cpuinfo_x86 *c)
        die_select_mask = (~(-1 << die_plus_mask_width)) >>
                                core_plus_mask_width;
 
-       c->cpu_core_id = apic->phys_pkg_id(c->topo.initial_apicid,
+       c->topo.core_id = apic->phys_pkg_id(c->topo.initial_apicid,
                                ht_mask_width) & core_select_mask;
 
        if (die_level_present) {
index 8df02964afe1dfdc1f170fbc37a5969491338fbe..7ab9224736db5d6a4248249bb58a718e069b9ab4 100644 (file)
@@ -479,7 +479,7 @@ static bool match_smt(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
                if (c->topo.pkg_id == o->topo.pkg_id &&
                    c->topo.die_id == o->topo.die_id &&
                    per_cpu(cpu_llc_id, cpu1) == per_cpu(cpu_llc_id, cpu2)) {
-                       if (c->cpu_core_id == o->cpu_core_id)
+                       if (c->topo.core_id == o->topo.core_id)
                                return topology_sane(c, o, "smt");
 
                        if ((c->cu_id != 0xff) &&
@@ -490,7 +490,7 @@ static bool match_smt(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
 
        } else if (c->topo.pkg_id == o->topo.pkg_id &&
                   c->topo.die_id == o->topo.die_id &&
-                  c->cpu_core_id == o->cpu_core_id) {
+                  c->topo.core_id == o->topo.core_id) {
                return topology_sane(c, o, "smt");
        }
 
@@ -1426,7 +1426,7 @@ static void remove_siblinginfo(int cpu)
        cpumask_clear(topology_sibling_cpumask(cpu));
        cpumask_clear(topology_core_cpumask(cpu));
        cpumask_clear(topology_die_cpumask(cpu));
-       c->cpu_core_id = 0;
+       c->topo.core_id = 0;
        c->booted_cores = 0;
        cpumask_clear_cpu(cpu, cpu_sibling_setup_mask);
        recompute_smt_state();