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

topology: Create core_cpus and die_cpus sysfs attributes

Create CPU topology sysfs attributes: "core_cpus" and "core_cpus_list"

These attributes represent all of the logical CPUs that share the
same core.

These attriutes is synonymous with the existing "thread_siblings" and
"thread_siblings_list" attribute, which will be deprecated.

Create CPU topology sysfs attributes: "die_cpus" and "die_cpus_list".
These attributes represent all of the logical CPUs that share the
same die.

Suggested-by: Brice Goglin <Brice.Goglin@inria.fr>
Signed-off-by: Len Brown <len.brown@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/071c23a298cd27ede6ed0b6460cae190d193364f.1557769318.git.len.brown@intel.com

authored by

Len Brown and committed by
Thomas Gleixner
2e4c54da b73ed8dc

+55 -6
+15 -6
Documentation/cputopology.txt
··· 36 36 identifier (rather than the kernel's). The actual value is 37 37 architecture and platform dependent. 38 38 39 - thread_siblings: 39 + core_cpus: 40 40 41 - internal kernel map of cpuX's hardware threads within the same 42 - core as cpuX. 41 + internal kernel map of CPUs within the same core. 42 + (deprecated name: "thread_siblings") 43 43 44 - thread_siblings_list: 44 + core_cpus_list: 45 45 46 - human-readable list of cpuX's hardware threads within the same 47 - core as cpuX. 46 + human-readable list of CPUs within the same core. 47 + (deprecated name: "thread_siblings_list"); 48 48 49 49 package_cpus: 50 50 ··· 55 55 56 56 human-readable list of CPUs sharing the same physical_package_id. 57 57 (deprecated name: "core_siblings_list") 58 + 59 + die_cpus: 60 + 61 + internal kernel map of CPUs within the same die. 62 + 63 + die_cpus_list: 64 + 65 + human-readable list of CPUs within the same die. 58 66 59 67 book_siblings: 60 68 ··· 101 93 #define topology_drawer_id(cpu) 102 94 #define topology_sibling_cpumask(cpu) 103 95 #define topology_core_cpumask(cpu) 96 + #define topology_die_cpumask(cpu) 104 97 #define topology_book_cpumask(cpu) 105 98 #define topology_drawer_cpumask(cpu) 106 99
+1
arch/x86/include/asm/smp.h
··· 23 23 24 24 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_sibling_map); 25 25 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map); 26 + DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_die_map); 26 27 /* cpus sharing the last level cache: */ 27 28 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map); 28 29 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
+1
arch/x86/include/asm/topology.h
··· 111 111 #define topology_core_id(cpu) (cpu_data(cpu).cpu_core_id) 112 112 113 113 #ifdef CONFIG_SMP 114 + #define topology_die_cpumask(cpu) (per_cpu(cpu_die_map, cpu)) 114 115 #define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu)) 115 116 #define topology_sibling_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu)) 116 117
+22
arch/x86/kernel/smpboot.c
··· 91 91 DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map); 92 92 EXPORT_PER_CPU_SYMBOL(cpu_core_map); 93 93 94 + /* representing HT, core, and die siblings of each logical CPU */ 95 + DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_die_map); 96 + EXPORT_PER_CPU_SYMBOL(cpu_die_map); 97 + 94 98 DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map); 95 99 96 100 /* Per CPU bogomips and other parameters */ ··· 513 509 return false; 514 510 } 515 511 512 + static bool match_die(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o) 513 + { 514 + if ((c->phys_proc_id == o->phys_proc_id) && 515 + (c->cpu_die_id == o->cpu_die_id)) 516 + return true; 517 + return false; 518 + } 519 + 520 + 516 521 #if defined(CONFIG_SCHED_SMT) || defined(CONFIG_SCHED_MC) 517 522 static inline int x86_sched_itmt_flags(void) 518 523 { ··· 584 571 cpumask_set_cpu(cpu, topology_sibling_cpumask(cpu)); 585 572 cpumask_set_cpu(cpu, cpu_llc_shared_mask(cpu)); 586 573 cpumask_set_cpu(cpu, topology_core_cpumask(cpu)); 574 + cpumask_set_cpu(cpu, topology_die_cpumask(cpu)); 587 575 c->booted_cores = 1; 588 576 return; 589 577 } ··· 633 619 } 634 620 if (match_pkg(c, o) && !topology_same_node(c, o)) 635 621 x86_has_numa_in_package = true; 622 + 623 + if ((i == cpu) || (has_mp && match_die(c, o))) 624 + link_mask(topology_die_cpumask, cpu, i); 636 625 } 637 626 638 627 threads = cpumask_weight(topology_sibling_cpumask(cpu)); ··· 1240 1223 physid_set_mask_of_physid(0, &phys_cpu_present_map); 1241 1224 cpumask_set_cpu(0, topology_sibling_cpumask(0)); 1242 1225 cpumask_set_cpu(0, topology_core_cpumask(0)); 1226 + cpumask_set_cpu(0, topology_die_cpumask(0)); 1243 1227 } 1244 1228 1245 1229 /* ··· 1336 1318 for_each_possible_cpu(i) { 1337 1319 zalloc_cpumask_var(&per_cpu(cpu_sibling_map, i), GFP_KERNEL); 1338 1320 zalloc_cpumask_var(&per_cpu(cpu_core_map, i), GFP_KERNEL); 1321 + zalloc_cpumask_var(&per_cpu(cpu_die_map, i), GFP_KERNEL); 1339 1322 zalloc_cpumask_var(&per_cpu(cpu_llc_shared_map, i), GFP_KERNEL); 1340 1323 } 1341 1324 ··· 1557 1538 cpu_data(sibling).booted_cores--; 1558 1539 } 1559 1540 1541 + for_each_cpu(sibling, topology_die_cpumask(cpu)) 1542 + cpumask_clear_cpu(cpu, topology_die_cpumask(sibling)); 1560 1543 for_each_cpu(sibling, topology_sibling_cpumask(cpu)) 1561 1544 cpumask_clear_cpu(cpu, topology_sibling_cpumask(sibling)); 1562 1545 for_each_cpu(sibling, cpu_llc_shared_mask(cpu)) ··· 1566 1545 cpumask_clear(cpu_llc_shared_mask(cpu)); 1567 1546 cpumask_clear(topology_sibling_cpumask(cpu)); 1568 1547 cpumask_clear(topology_core_cpumask(cpu)); 1548 + cpumask_clear(topology_die_cpumask(cpu)); 1569 1549 c->cpu_core_id = 0; 1570 1550 c->booted_cores = 0; 1571 1551 cpumask_clear_cpu(cpu, cpu_sibling_setup_mask);
+1
arch/x86/xen/smp_pv.c
··· 251 251 for_each_possible_cpu(i) { 252 252 zalloc_cpumask_var(&per_cpu(cpu_sibling_map, i), GFP_KERNEL); 253 253 zalloc_cpumask_var(&per_cpu(cpu_core_map, i), GFP_KERNEL); 254 + zalloc_cpumask_var(&per_cpu(cpu_die_map, i), GFP_KERNEL); 254 255 zalloc_cpumask_var(&per_cpu(cpu_llc_shared_map, i), GFP_KERNEL); 255 256 } 256 257 set_cpu_sibling_map(0);
+12
drivers/base/topology.c
··· 53 53 static DEVICE_ATTR_RO(thread_siblings); 54 54 static DEVICE_ATTR_RO(thread_siblings_list); 55 55 56 + define_siblings_show_func(core_cpus, sibling_cpumask); 57 + static DEVICE_ATTR_RO(core_cpus); 58 + static DEVICE_ATTR_RO(core_cpus_list); 59 + 56 60 define_siblings_show_func(core_siblings, core_cpumask); 57 61 static DEVICE_ATTR_RO(core_siblings); 58 62 static DEVICE_ATTR_RO(core_siblings_list); 63 + 64 + define_siblings_show_func(die_cpus, die_cpumask); 65 + static DEVICE_ATTR_RO(die_cpus); 66 + static DEVICE_ATTR_RO(die_cpus_list); 59 67 60 68 define_siblings_show_func(package_cpus, core_cpumask); 61 69 static DEVICE_ATTR_RO(package_cpus); ··· 91 83 &dev_attr_core_id.attr, 92 84 &dev_attr_thread_siblings.attr, 93 85 &dev_attr_thread_siblings_list.attr, 86 + &dev_attr_core_cpus.attr, 87 + &dev_attr_core_cpus_list.attr, 94 88 &dev_attr_core_siblings.attr, 95 89 &dev_attr_core_siblings_list.attr, 90 + &dev_attr_die_cpus.attr, 91 + &dev_attr_die_cpus_list.attr, 96 92 &dev_attr_package_cpus.attr, 97 93 &dev_attr_package_cpus_list.attr, 98 94 #ifdef CONFIG_SCHED_BOOK
+3
include/linux/topology.h
··· 196 196 #ifndef topology_core_cpumask 197 197 #define topology_core_cpumask(cpu) cpumask_of(cpu) 198 198 #endif 199 + #ifndef topology_die_cpumask 200 + #define topology_die_cpumask(cpu) cpumask_of(cpu) 201 + #endif 199 202 200 203 #ifdef CONFIG_SCHED_SMT 201 204 static inline const struct cpumask *cpu_smt_mask(int cpu)