Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/topology: Define topology_logical_die_id()

Define topology_logical_die_id() ala existing topology_logical_package_id()

Signed-off-by: Len Brown <len.brown@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/2f3526e25ae14fbeff26fb26e877d159df8946d9.1557769318.git.len.brown@intel.com

authored by

Len Brown and committed by
Thomas Gleixner
212bf4fd 306a0de3

+52
+1
arch/x86/include/asm/processor.h
··· 118 118 /* Core id: */ 119 119 u16 cpu_core_id; 120 120 u16 cpu_die_id; 121 + u16 logical_die_id; 121 122 /* Index into per_cpu list: */ 122 123 u16 cpu_index; 123 124 u32 microcode;
+5
arch/x86/include/asm/topology.h
··· 106 106 107 107 #define topology_logical_package_id(cpu) (cpu_data(cpu).logical_proc_id) 108 108 #define topology_physical_package_id(cpu) (cpu_data(cpu).phys_proc_id) 109 + #define topology_logical_die_id(cpu) (cpu_data(cpu).logical_die_id) 109 110 #define topology_die_id(cpu) (cpu_data(cpu).cpu_die_id) 110 111 #define topology_core_id(cpu) (cpu_data(cpu).cpu_core_id) 111 112 ··· 132 131 } 133 132 134 133 int topology_update_package_map(unsigned int apicid, unsigned int cpu); 134 + int topology_update_die_map(unsigned int dieid, unsigned int cpu); 135 135 int topology_phys_to_logical_pkg(unsigned int pkg); 136 + int topology_phys_to_logical_die(unsigned int die, unsigned int cpu); 136 137 bool topology_is_primary_thread(unsigned int cpu); 137 138 bool topology_smt_supported(void); 138 139 #else 139 140 #define topology_max_packages() (1) 140 141 static inline int 141 142 topology_update_package_map(unsigned int apicid, unsigned int cpu) { return 0; } 143 + static inline int 144 + topology_update_die_map(unsigned int dieid, unsigned int cpu) { return 0; } 142 145 static inline int topology_phys_to_logical_pkg(unsigned int pkg) { return 0; } 143 146 static inline int topology_phys_to_logical_die(unsigned int die, 144 147 unsigned int cpu) { return 0; }
+1
arch/x86/kernel/cpu/common.c
··· 1298 1298 cpu, apicid, c->initial_apicid); 1299 1299 } 1300 1300 BUG_ON(topology_update_package_map(c->phys_proc_id, cpu)); 1301 + BUG_ON(topology_update_die_map(c->cpu_die_id, cpu)); 1301 1302 #else 1302 1303 c->logical_proc_id = 0; 1303 1304 #endif
+45
arch/x86/kernel/smpboot.c
··· 101 101 unsigned int __max_logical_packages __read_mostly; 102 102 EXPORT_SYMBOL(__max_logical_packages); 103 103 static unsigned int logical_packages __read_mostly; 104 + static unsigned int logical_die __read_mostly; 104 105 105 106 /* Maximum number of SMT threads on any online core */ 106 107 int __read_mostly __max_smt_threads = 1; ··· 303 302 return -1; 304 303 } 305 304 EXPORT_SYMBOL(topology_phys_to_logical_pkg); 305 + /** 306 + * topology_phys_to_logical_die - Map a physical die id to logical 307 + * 308 + * Returns logical die id or -1 if not found 309 + */ 310 + int topology_phys_to_logical_die(unsigned int die_id, unsigned int cur_cpu) 311 + { 312 + int cpu; 313 + int proc_id = cpu_data(cur_cpu).phys_proc_id; 314 + 315 + for_each_possible_cpu(cpu) { 316 + struct cpuinfo_x86 *c = &cpu_data(cpu); 317 + 318 + if (c->initialized && c->cpu_die_id == die_id && 319 + c->phys_proc_id == proc_id) 320 + return c->logical_die_id; 321 + } 322 + return -1; 323 + } 324 + EXPORT_SYMBOL(topology_phys_to_logical_die); 306 325 307 326 /** 308 327 * topology_update_package_map - Update the physical to logical package map ··· 347 326 cpu_data(cpu).logical_proc_id = new; 348 327 return 0; 349 328 } 329 + /** 330 + * topology_update_die_map - Update the physical to logical die map 331 + * @die: The die id as retrieved via CPUID 332 + * @cpu: The cpu for which this is updated 333 + */ 334 + int topology_update_die_map(unsigned int die, unsigned int cpu) 335 + { 336 + int new; 337 + 338 + /* Already available somewhere? */ 339 + new = topology_phys_to_logical_die(die, cpu); 340 + if (new >= 0) 341 + goto found; 342 + 343 + new = logical_die++; 344 + if (new != die) { 345 + pr_info("CPU %u Converting physical %u to logical die %u\n", 346 + cpu, die, new); 347 + } 348 + found: 349 + cpu_data(cpu).logical_die_id = new; 350 + return 0; 351 + } 350 352 351 353 void __init smp_store_boot_cpu_info(void) 352 354 { ··· 379 335 *c = boot_cpu_data; 380 336 c->cpu_index = id; 381 337 topology_update_package_map(c->phys_proc_id, id); 338 + topology_update_die_map(c->cpu_die_id, id); 382 339 c->initialized = true; 383 340 } 384 341