v3 multi-die/package topology support
Subsystems (8)
PATCH 8/14 powercap/intel_rapl: Simplify rapl_find_package()
In reply to Len BrownFrom: Zhang Rui <[email protected]>
Syntax only, no functional or semantic change.
Simplify how the code to discover a package is called. Rename find_package_by_id() to rapl_find_package_domain()
--- drivers/powercap/intel_rapl.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/powercap/intel_rapl.c +9 -9
@@ -264,8 +264,9 @@ static struct powercap_control_type *control_type; /* PowerCap Controller */static struct rapl_domain *platform_rapl_domain;/* Platform (PSys) domain */ /* caller to ensure CPU hotplug lock is held */ -static struct rapl_package *find_package_by_id (int id) +static struct rapl_package *rapl_find_package_domain (int cpu) { +int id =topology_physical_package_id (cpu);struct rapl_package *rp;list_for_each_entry (rp, &rapl_packages, plist) {
@@ -1298,7 +1299,7 @@ static int __init rapl_register_psys(void) rd->rpl[0 ].name = pl1_name; rd->rpl[1 ].prim_id =PL2_ENABLE ; rd->rpl[1 ].name = pl2_name; - rd->rp =find_package_by_id (0 ); + rd->rp =rapl_find_package_domain (0 ); power_zone = powercap_register_zone(&rd->power_zone, control_type, "psys", NULL,
@@ -1454,8 +1455,9 @@ static void rapl_remove_package(struct rapl_package *rp) }/* called from CPU hotplug notifier, hotplug lock held */ -static struct rapl_package *rapl_add_package (int cpu,int pkgid) +static struct rapl_package *rapl_add_package (int cpu) { +int id =topology_physical_package_id (cpu);struct rapl_package *rp;int ret;
@@ -1464,7 +1466,7 @@ static struct rapl_package *rapl_add_package(int cpu, int pkgid)return ERR_PTR (-ENOMEM );/* add the new package to the list */ - rp->id = pkgid; + rp->id = id; rp->lead_cpu = cpu;/* check if the package contains valid domains */
@@ -1495,12 +1497,11 @@ static struct rapl_package *rapl_add_package(int cpu, int pkgid)*/ static int rapl_cpu_online (unsigned int cpu) { -int pkgid =topology_physical_package_id (cpu);struct rapl_package *rp; - rp =find_package_by_id (pkgid); + rp =rapl_find_package_domain (cpu);if (!rp) { - rp =rapl_add_package (cpu, pkgid); + rp =rapl_add_package (cpu);if (IS_ERR (rp))return PTR_ERR (rp); }
@@ -1510,11 +1511,10 @@ static int rapl_cpu_online(unsigned int cpu)static int rapl_cpu_down_prep (unsigned int cpu) { -int pkgid =topology_physical_package_id (cpu);struct rapl_package *rp;int lead_cpu; - rp =find_package_by_id (pkgid); + rp =rapl_find_package_domain (cpu);if (!rp)return 0 ;
Signature · 1 line
2.18.0-rc0
PATCH 9/14 powercap/intel_rapl: Support multi-die/package
In reply to Len BrownFrom: Zhang Rui <[email protected]>
On the new dual-die/package systems, the RAPL MSR becomes die-scope. Thus instead of one powercap device per physical package, now there should be one powercap device for each unique die on these systems.
This patch introduces intel_rapl driver support for new dual-die/package systems.
On the hardwares that do not have multi-die, topology_logical_die_id() equals topology_physical_package_id(), thus there is no functional change.
--- drivers/powercap/intel_rapl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/powercap/intel_rapl.c +2 -2
@@ -266,7 +266,7 @@ static struct rapl_domain *platform_rapl_domain; /* Platform (PSys) domain *//* caller to ensure CPU hotplug lock is held */ static struct rapl_package *rapl_find_package_domain (int cpu) { -int id =topology_physical_package_id (cpu); +int id =topology_logical_die_id (cpu);struct rapl_package *rp;list_for_each_entry (rp, &rapl_packages, plist) {
@@ -1457,7 +1457,7 @@ static void rapl_remove_package(struct rapl_package *rp)/* called from CPU hotplug notifier, hotplug lock held */ static struct rapl_package *rapl_add_package (int cpu) { -int id =topology_physical_package_id (cpu); +int id =topology_logical_die_id (cpu);struct rapl_package *rp;int ret;
Signature · 1 line
2.18.0-rc0
PATCH 11/14 powercap/intel_rapl: update rapl domain name and debug messages
In reply to Len BrownFrom: Zhang Rui <[email protected]>
The RAPL domain "name" attribute contains "Package-N", which is ambiguous on multi-die per-package systems.
Update the name to "package-X-die-Y" on those systems.
No change on systems without multi-die.
Driver debug messages are also updated.
--- drivers/powercap/intel_rapl.c | 57 ++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 25 deletions(-)
drivers/powercap/intel_rapl.c +32 -25
@@ -178,12 +178,15 @@ struct rapl_domain {#define power_zone_to_rapl_domain (_zone) \ container_of(_zone, struct rapl_domain, power_zone) +/* maximum rapl package domain name: package-%d-die-%d */ +#define PACKAGE_DOMAIN_NAME_LENGTH 30 -/* Each physical package contains multiple domains, these are the common + +/* Each rapl package contains multiple domains, these are the common * data across RAPL domains within a package. */ struct rapl_package { -unsigned int id;/* physical package/socket id */ +unsigned int id;/* logical die id, equals physical 1-die systems */ unsigned int nr_domains;unsigned long domain_map;/* bit map of active domains */ unsigned int power_unit;
@@ -198,6 +201,7 @@ struct rapl_package {int lead_cpu;/* one active cpu per package for access */ /* Track active cpus */ struct cpumask cpumask; +char name[PACKAGE_DOMAIN_NAME_LENGTH ]; };struct rapl_defaults {
@@ -926,8 +930,8 @@ static int rapl_check_unit_core(struct rapl_package *rp, int cpu) value = (msr_val &TIME_UNIT_MASK ) >>TIME_UNIT_OFFSET ; rp->time_unit =1000000 / (1 << value); -pr_debug ("Core CPU package %d energy=%dpJ, time=%dus, power=%duW\n" , - rp->id, rp->energy_unit, rp->time_unit, rp->power_unit); +pr_debug ("Core CPU %s energy=%dpJ, time=%dus, power=%duW\n" , + rp->name, rp->energy_unit, rp->time_unit, rp->power_unit);return 0 ; }
@@ -951,8 +955,8 @@ static int rapl_check_unit_atom(struct rapl_package *rp, int cpu) value = (msr_val &TIME_UNIT_MASK ) >>TIME_UNIT_OFFSET ; rp->time_unit =1000000 / (1 << value); -pr_debug ("Atom package %d energy=%dpJ, time=%dus, power=%duW\n" , - rp->id, rp->energy_unit, rp->time_unit, rp->power_unit); +pr_debug ("Atom %s energy=%dpJ, time=%dus, power=%duW\n" , + rp->name, rp->energy_unit, rp->time_unit, rp->power_unit);return 0 ; }
@@ -1179,7 +1183,7 @@ static void rapl_update_domain_data(struct rapl_package *rp)u64 val;for (dmn =0 ; dmn < rp->nr_domains; dmn++) { -pr_debug ("update package %d domain %s data\n" , rp->id, +pr_debug ("update %s domain %s data\n" , rp->name, rp->domains[dmn].name);/* exclude non-raw primitives */ for (prim =0 ; prim <NR_RAW_PRIMITIVES ; prim++) {
@@ -1204,7 +1208,6 @@ static void rapl_unregister_powercap(void)static int rapl_package_register_powercap (struct rapl_package *rp) {struct rapl_domain *rd; -char dev_name[17 ];/* max domain name = 7 + 1 + 8 for int + 1 for null*/ struct powercap_zone *power_zone =NULL ;int nr_pl, ret;
@@ -1215,20 +1218,16 @@ static int rapl_package_register_powercap(struct rapl_package *rp)for (rd = rp->domains; rd < rp->domains + rp->nr_domains; rd++) {if (rd->id ==RAPL_DOMAIN_PACKAGE ) { nr_pl =find_nr_power_limit (rd); -pr_debug ("register socket %d package domain %s\n" , - rp->id, rd->name); -memset (dev_name,0 ,sizeof (dev_name)); -snprintf (dev_name,sizeof (dev_name),"%s-%d" , - rd->name, rp->id); +pr_debug ("register package domain %s\n" , rp->name); power_zone =powercap_register_zone (&rd->power_zone, control_type, - dev_name,NULL , + rp->name,NULL , &zone_ops[rd->id], nr_pl, &constraint_ops);if (IS_ERR (power_zone)) { -pr_debug ("failed to register package, %d\n" , - rp->id); +pr_debug ("failed to register power zone %s\n" , + rp->name);return PTR_ERR (power_zone); }/* track parent zone in per package/socket data */
@@ -1254,8 +1253,8 @@ static int rapl_package_register_powercap(struct rapl_package *rp) &constraint_ops);if (IS_ERR (power_zone)) { -pr_debug ("failed to register power_zone, %d:%s:%s\n" , - rp->id, rd->name, dev_name); +pr_debug ("failed to register power_zone, %s:%s\n" , + rp->name, rd->name); ret =PTR_ERR (power_zone); goto err_cleanup; }
@@ -1268,7 +1267,7 @@ static int rapl_package_register_powercap(struct rapl_package *rp)* failed after the first domain setup. */ while (--rd >= rp->domains) { -pr_debug ("unregister package %d domain %s\n" , rp->id, rd->name); +pr_debug ("unregister %s domain %s\n" , rp->name, rd->name);powercap_unregister_zone (control_type, &rd->power_zone); }
@@ -1378,8 +1377,8 @@ static void rapl_detect_powerlimit(struct rapl_domain *rd)/* check if the domain is locked by BIOS, ignore if MSR doesn't exist */ if (!rapl_read_data_raw (rd,FW_LOCK , false, &val64)) {if (val64) { -pr_info ("RAPL package %d domain %s locked by BIOS\n" , - rd->rp->id, rd->name); +pr_info ("RAPL %s domain %s locked by BIOS\n" , + rd->rp->name, rd->name); rd->state |=DOMAIN_STATE_BIOS_LOCKED ; } }
@@ -1408,10 +1407,10 @@ static int rapl_detect_domains(struct rapl_package *rp, int cpu) } rp->nr_domains =bitmap_weight (&rp->domain_map,RAPL_DOMAIN_MAX );if (!rp->nr_domains) { -pr_debug ("no valid rapl domains found in package %d\n" , rp->id); +pr_debug ("no valid rapl domains found in %s\n" , rp->name);return -ENODEV ; } -pr_debug ("found %d domains on package %d\n" , rp->nr_domains, rp->id); +pr_debug ("found %d domains on %s\n" , rp->nr_domains, rp->name); rp->domains =kcalloc (rp->nr_domains +1 ,sizeof (struct rapl_domain ),GFP_KERNEL );
@@ -1444,8 +1443,8 @@ static void rapl_remove_package(struct rapl_package *rp) rd_package = rd;continue ; } -pr_debug ("remove package, undo power limit on %d: %s\n" , - rp->id, rd->name); +pr_debug ("remove package, undo power limit on %s: %s\n" , + rp->name, rd->name);powercap_unregister_zone (control_type, &rd->power_zone); }/* do parent zone last */
@@ -1459,6 +1458,7 @@ static struct rapl_package *rapl_add_package(int cpu) {int id =topology_logical_die_id (cpu);struct rapl_package *rp; +struct cpuinfo_x86 *c = &cpu_data (cpu);int ret; rp =kzalloc (sizeof (struct rapl_package ),GFP_KERNEL );
@@ -1469,6 +1469,13 @@ static struct rapl_package *rapl_add_package(int cpu) rp->id = id; rp->lead_cpu = cpu; +if (c->x86_max_dies >1 ) +snprintf (rp->name,PACKAGE_DOMAIN_NAME_LENGTH , +"package-%d-die-%d" , c->phys_proc_id, c->cpu_die_id); +else +snprintf (rp->name,PACKAGE_DOMAIN_NAME_LENGTH ,"package-%d" , + c->phys_proc_id); +/* check if the package contains valid domains */ if (rapl_detect_domains (rp, cpu) || rapl_defaults->check_unit (rp, cpu)) {
Signature · 1 line
2.18.0-rc0
PATCH 12/14 hwmon/coretemp: Support multi-die/package
In reply to Len BrownFrom: Zhang Rui <[email protected]>
This patch introduces coretemp driver support
for new dual-die/package systems.
On the new dual-die/package systems, the package temperature MSRs becomes die-scope. Thus instead of one hwmon device per physical package, now there should be one hwmon device for each die on these systems.
On the hardwares that do not have multi-die support, topology_logical_die_id() equals topology_physical_package_id(), thus the only difference is that physical package id is used as the coretemp platform device id, instead of logical package id on these systems.
--- drivers/hwmon/coretemp.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/hwmon/coretemp.c +5 -4
@@ -435,7 +435,7 @@ static int chk_ucode_version(unsigned int cpu)static struct platform_device *coretemp_get_pdev (unsigned int cpu) { -int pkgid =topology_logical_package_id (cpu); +int pkgid =topology_logical_die_id (cpu);if (pkgid >=0 && pkgid < max_packages)return pkg_devices[pkgid];
@@ -579,7 +579,7 @@ static struct platform_driver coretemp_driver = {static struct platform_device *coretemp_device_add (unsigned int cpu) { -int err, pkgid =topology_logical_package_id (cpu); +int err, pkgid =topology_logical_die_id (cpu);struct platform_device *pdev;if (pkgid <0 )
@@ -703,7 +703,7 @@ static int coretemp_cpu_offline(unsigned int cpu)* the rest. */ if (cpumask_empty (&pd->cpumask)) { - pkg_devices[topology_logical_package_id (cpu)] =NULL ; + pkg_devices[topology_logical_die_id (cpu)] =NULL ;platform_device_unregister (pdev);return 0 ; }
@@ -732,6 +732,7 @@ static enum cpuhp_state coretemp_hp_online;static int __init coretemp_init (void ) {int err; +struct cpuinfo_x86 *c = &cpu_data (0 );/* * CPUID.06H.EAX[0] indicates whether the CPU has thermal
@@ -741,7 +742,7 @@ static int __init coretemp_init(void)if (!x86_match_cpu (coretemp_ids))return -ENODEV ; - max_packages =topology_max_packages (); + max_packages =topology_max_packages () * c->x86_max_dies; pkg_devices =kcalloc (max_packages,sizeof (struct platform_device *),GFP_KERNEL );if (!pkg_devices)
Signature · 1 line
2.18.0-rc0
cover v3 multi-die/package topology support
This patch series does 4 things.
1. Parse the new CPUID.1F leaf to discover multi-die/package topology
2. Export multi-die topology inside the kernel
3. Update 4 places (coretemp, pkgtemp, rapl, perf) that that need to know the difference between die and package-scope MSR.
4. Export multi-die topology to user-space via sysfs
These changes should have 0 impact on cache topology, NUMA topology, Linux scheduler, or system performance.
These topology changes primarily impact parts of the kernel and some applications that care about package MSR scope. Also, some software is licensed per package, and other tools, such as benchmark reporting software sometimes cares about packages.
---
Updates since v2:
All review feedback has been addressed.
In response to brice, peterz and Morten Rasmussen,
used the word "cpu" rather than "thread" for the new sysfs attributes.
In response to tglx, replaced access to cpuinfo_x86.x86_max_dies, with macro topology_max_die_per_package(). In doing so, deleted this new per-cpu field entirely, as a global is sufficient.
Also, appended 3 patches from Kan Liang, updating the perf code to be multi-die aware. These patches are similar to the preceding power and temperature patches. I believe that with these patches, this series now includes all needed multi-die kernel support.
---
The following changes since commit 085b7755808aa11f78ab9377257e1dad2e6fa4bb:
Linux 5.1-rc6 (2019-04-21 10:45:57 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux.git x86
for you to fetch changes up to 6c4891c7f2f1eacfcab00bf5d84b5ac119f654b9:
perf/x86/intel/cstate: Support multi-die/package (2019-04-30 16:49:26 -0400)
----------------------------------------------------------------
Kan Liang (3):
perf/x86/intel/uncore: Support multi-die/package perf/x86/intel/rapl: Support multi-die/package perf/x86/intel/cstate: Support multi-die/package
Len Brown (10):
x86 topology: Fix doc typo
topology: Simplify cputopology.txt formatting and wording x86 smpboot: Rename match_die() to match_pkg() x86 topology: Add CPUID.1F multi-die/package support x86 topology: Create topology_max_die_per_package() cpu topology: Export die_id
x86 topology: Define topology_die_id()
x86 topology: Define topology_logical_die_id()
topology: Create package_cpus sysfs attribute
topology: Create core_cpus and die_cpus sysfs attributes
Zhang Rui (5):
powercap/intel_rapl: Simplify rapl_find_package() powercap/intel_rapl: Support multi-die/package thermal/x86_pkg_temp_thermal: Support multi-die/package powercap/intel_rapl: update rapl domain name and debug messages hwmon/coretemp: Support multi-die/package
Documentation/cputopology.txt | 80 +++++++++++++++---------- Documentation/x86/topology.txt | 6 +- arch/x86/events/intel/cstate.c | 14 +++-- arch/x86/events/intel/rapl.c | 10 ++-- arch/x86/events/intel/uncore.c | 20 ++++--- arch/x86/include/asm/processor.h | 4 +- arch/x86/include/asm/smp.h | 1 + arch/x86/include/asm/topology.h | 17 ++++++ arch/x86/kernel/cpu/common.c | 1 + arch/x86/kernel/cpu/topology.c | 88 ++++++++++++++++++++++------ arch/x86/kernel/smpboot.c | 75 +++++++++++++++++++++++- arch/x86/xen/smp_pv.c | 1 + drivers/base/topology.c | 22 +++++++ drivers/hwmon/coretemp.c | 9 +-- drivers/powercap/intel_rapl.c | 75 +++++++++++++----------- drivers/thermal/intel/x86_pkg_temp_thermal.c | 8 +-- include/linux/topology.h | 6 ++ 17 files changed, 322 insertions(+), 115 deletions(-)
PATCH 1/14 x86 topology: Fix doc typo
From: Len Brown <[email protected]>
Syntax only, no functional or semantic change.
reflect actual cpuinfo_x86 field name:
s/logical_id/logical_proc_id/
--- Documentation/x86/topology.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/x86/topology.txt +1 -1
@@ -51,7 +51,7 @@ The topology of a system is described in the units of: The physical ID of the package. This information is retrieved via CPUID and deduced from the APIC IDs of the cores in the package. - - cpuinfo_x86.logical_id: + - cpuinfo_x86.logical_proc_id: The logical ID of the package. As we do not trust BIOSes to enumerate the packages in a consistent way, we introduced the concept of logical package
Signature · 1 line
2.18.0-rc0
PATCH 4/14 x86 topology: Add CPUID.1F multi-die/package support
From: Len Brown <[email protected]>
Some new systems have multiple software-visible die within each package.
Update Linux parsing of the Intel CPUID "Extended Topology Leaf" to handle either CPUID.B, or the new CPUID.1F.
Add cpuinfo_x86.die_id and cpuinfo_x86.max_dies to store the result.
die_id will be non-zero only for multi-die/package systems.
--- Documentation/x86/topology.txt | 4 ++ arch/x86/include/asm/processor.h | 4 +- arch/x86/kernel/cpu/topology.c | 85 +++++++++++++++++++++++++------- arch/x86/kernel/smpboot.c | 2 + 4 files changed, 75 insertions(+), 20 deletions(-)
Documentation/x86/topology.txt +4 -0
@@ -46,6 +46,10 @@ The topology of a system is described in the units of: The number of cores in a package. This information is retrieved via CPUID. + - cpuinfo_x86.x86_max_dies: + + The number of dies in a package. This information is retrieved via CPUID. + - cpuinfo_x86.phys_proc_id: The physical ID of the package. This information is retrieved via CPUID
arch/x86/include/asm/processor.h +3 -1
@@ -105,7 +105,8 @@ struct cpuinfo_x86 {int x86_power;unsigned long loops_per_jiffy;/* cpuid returned max cores value: */ -u16 x86_max_cores; +u16 x86_max_cores; +u16 x86_max_dies;u16 apicid;u16 initial_apicid;u16 x86_clflush_size;
@@ -117,6 +118,7 @@ struct cpuinfo_x86 {u16 logical_proc_id;/* Core id: */ u16 cpu_core_id; +u16 cpu_die_id;/* Index into per_cpu list: */ u16 cpu_index;u32 microcode;
arch/x86/kernel/cpu/topology.c +66 -19
151 lines not on this page · raw message
arch/x86/kernel/smpboot.c +2 -0
@@ -393,6 +393,7 @@ static bool match_smt(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)int cpu1 = c->cpu_index, cpu2 = o->cpu_index;if (c->phys_proc_id == o->phys_proc_id && + c->cpu_die_id == o->cpu_die_id &&per_cpu (cpu_llc_id, cpu1) ==per_cpu (cpu_llc_id, cpu2)) {if (c->cpu_core_id == o->cpu_core_id)return topology_sane (c, o,"smt" );
@@ -404,6 +405,7 @@ static bool match_smt(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o) } }else if (c->phys_proc_id == o->phys_proc_id && + c->cpu_die_id == o->cpu_die_id && c->cpu_core_id == o->cpu_core_id) {return topology_sane (c, o,"smt" ); }
Signature · 1 line
2.18.0-rc0
PATCH 6/14 x86 topology: Define topology_die_id()
In reply to Len BrownFrom: Len Brown <[email protected]>
topology_die_id(cpu) is a simple macro for use inside the kernel to get the die_id associated with the given cpu.
--- arch/x86/include/asm/topology.h | 1 + 1 file changed, 1 insertion(+)
arch/x86/include/asm/topology.h +1 -0
@@ -106,6 +106,7 @@ extern const struct cpumask *cpu_coregroup_mask(int cpu);#define topology_logical_package_id (cpu) (cpu_data(cpu).logical_proc_id)#define topology_physical_package_id (cpu) (cpu_data(cpu).phys_proc_id) +#define topology_die_id (cpu) (cpu_data(cpu).cpu_die_id)#define topology_core_id (cpu) (cpu_data(cpu).cpu_core_id)#ifdef CONFIG_SMP
Signature · 1 line
2.18.0-rc0
PATCH 13/14 topology: Create package_threads sysfs attribute
In reply to Len BrownFrom: Len Brown <[email protected]>
The sysfs cpu/topology/core_siblings (and core_siblings_list) attributes are documented, implemented, and used by programs to represent set of logical CPU threads sharing the same package.
This makes sense if the next topology level above a core is always a package. But on systems where there is a die topology level between a core and a package, the name no longer makese sense.
So without changing its function, add a name for this map that describes what it actually is -- package threads -- the set of logical CPU threads that share the same package.
This new name will be immune to changes in topology, since it describes threads at the current level, not siblings at a contained level.
--- Documentation/cputopology.txt | 8 ++++---- drivers/base/topology.c | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-)
Documentation/cputopology.txt +4 -4
@@ -46,15 +46,15 @@ thread_siblings_list: human-readable list of cpuX's hardware threads within the same core as cpuX. -core_siblings: +package_threads: internal kernel map of cpuX's hardware threads within the same - physical_package_id. + physical_package_id. (deprecated name: "core_siblings") -core_siblings_list: +package_threads_list: human-readable list of cpuX's hardware threads within the same - physical_package_id. + physical_package_id. (deprecated name: "core_siblings_list") book_siblings:
drivers/base/topology.c +6 -0
@@ -57,6 +57,10 @@ define_siblings_show_func(core_siblings, core_cpumask);static DEVICE_ATTR_RO (core_siblings);static DEVICE_ATTR_RO (core_siblings_list); +define_siblings_show_func (package_threads, core_cpumask); +static DEVICE_ATTR_RO (package_threads); +static DEVICE_ATTR_RO (package_threads_list); +#ifdef CONFIG_SCHED_BOOK define_id_show_func (book_id);static DEVICE_ATTR_RO (book_id);
@@ -81,6 +85,8 @@ static struct attribute *default_attrs[] = { &dev_attr_thread_siblings_list.attr, &dev_attr_core_siblings.attr, &dev_attr_core_siblings_list.attr, + &dev_attr_package_threads.attr, + &dev_attr_package_threads_list.attr, #ifdef CONFIG_SCHED_BOOK &dev_attr_book_id.attr, &dev_attr_book_siblings.attr,
Signature · 1 line
2.18.0-rc0
PATCH 10/14 thermal/x86_pkg_temp_thermal: Support multi-die/package
In reply to Len BrownFrom: Zhang Rui <[email protected]>
On the new dual-die/package systems, the package temperature MSR becomes die-scope. Thus instead of one thermal zone device per physical package, now there should be one thermal_zone for each die on these systems.
This patch introduces x86_pkg_temp_thermal support for new dual-die/package systems.
On the hardwares that do not have multi-die, topology_logical_die_id() equals topology_physical_package_id(), thus there is no functional change.
--- drivers/thermal/intel/x86_pkg_temp_thermal.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/thermal/intel/x86_pkg_temp_thermal.c +5 -4
@@ -122,7 +122,7 @@ static int pkg_temp_debugfs_init(void)*/ static struct pkg_device *pkg_temp_thermal_get_dev (unsigned int cpu) { -int pkgid =topology_logical_package_id (cpu); +int pkgid =topology_logical_die_id (cpu);if (pkgid >=0 && pkgid < max_packages)return packages[pkgid];
@@ -353,7 +353,7 @@ static int pkg_thermal_notify(u64 msr_val)static int pkg_temp_thermal_device_add (unsigned int cpu) { -int pkgid =topology_logical_package_id (cpu); +int pkgid =topology_logical_die_id (cpu);u32 tj_max, eax, ebx, ecx, edx;struct pkg_device *pkgdev;int thres_count, err;
@@ -449,7 +449,7 @@ static int pkg_thermal_cpu_offline(unsigned int cpu)* worker will see the package anymore. */ if (lastcpu) { - packages[topology_logical_package_id (cpu)] =NULL ; + packages[topology_logical_die_id (cpu)] =NULL ;/* After this point nothing touches the MSR anymore. */ wrmsr (MSR_IA32_PACKAGE_THERM_INTERRUPT , pkgdev->msr_pkg_therm_low, pkgdev->msr_pkg_therm_high);
@@ -511,11 +511,12 @@ MODULE_DEVICE_TABLE(x86cpu, pkg_temp_thermal_ids);static int __init pkg_temp_thermal_init (void ) {int ret; +struct cpuinfo_x86 *c = &cpu_data (0 );if (!x86_match_cpu (pkg_temp_thermal_ids))return -ENODEV ; - max_packages =topology_max_packages (); + max_packages =topology_max_packages () * c->x86_max_dies; packages =kcalloc (max_packages,sizeof (struct pkg_device *),GFP_KERNEL );if (!packages)
Signature · 1 line
2.18.0-rc0
PATCH 14/14 topology: Create core_threads sysfs attribute
In reply to Len BrownFrom: Len Brown <[email protected]>
Create CPU topology sysfs attributes:
"core_threads" and "core_threads_list"
These attributes represent all of the logical CPU threads that share the same core.
These attriutes is synonymous with the existing "thread_siblings" and "thread_siblings_list" attribute, which will be deprecated.
--- Documentation/cputopology.txt | 19 +++++++++++++++---- arch/x86/include/asm/smp.h | 1 + arch/x86/include/asm/topology.h | 1 + arch/x86/kernel/smpboot.c | 22 ++++++++++++++++++++++ arch/x86/xen/smp_pv.c | 1 + drivers/base/topology.c | 12 ++++++++++++ include/linux/topology.h | 3 +++ 7 files changed, 55 insertions(+), 4 deletions(-)
Documentation/cputopology.txt +15 -4
@@ -36,15 +36,15 @@ drawer_id: identifier (rather than the kernel's). The actual value is architecture and platform dependent. -thread_siblings: +core_threads: internal kernel map of cpuX's hardware threads within the same - core as cpuX. + core as cpuX. (deprecated name: "thread_siblings") -thread_siblings_list: +core_threads_list: human-readable list of cpuX's hardware threads within the same - core as cpuX. + core as cpuX. (deprecated name: "thread_siblings_list"); package_threads:
@@ -56,6 +56,16 @@ package_threads_list: human-readable list of cpuX's hardware threads within the same physical_package_id. (deprecated name: "core_siblings_list") +die_threads: + + internal kernel map of cpuX's hardware threads within the same + die_id. + +die_threads_list: + + human-readable list of cpuX's hardware threads within the same + die_id. + book_siblings: internal kernel map of cpuX's hardware threads within the same
@@ -93,6 +103,7 @@ these macros in include/asm-XXX/topology.h:: #define topology_drawer_id(cpu) #define topology_sibling_cpumask(cpu) #define topology_core_cpumask(cpu) + #define topology_die_cpumask(cpu) #define topology_book_cpumask(cpu) #define topology_drawer_cpumask(cpu)
arch/x86/include/asm/smp.h +1 -0
@@ -23,6 +23,7 @@ extern unsigned int num_processors;DECLARE_PER_CPU_READ_MOSTLY (cpumask_var_t, cpu_sibling_map);DECLARE_PER_CPU_READ_MOSTLY (cpumask_var_t, cpu_core_map); +DECLARE_PER_CPU_READ_MOSTLY (cpumask_var_t, cpu_die_map);/* cpus sharing the last level cache: */ DECLARE_PER_CPU_READ_MOSTLY (cpumask_var_t, cpu_llc_shared_map);DECLARE_PER_CPU_READ_MOSTLY (u16, cpu_llc_id);
arch/x86/include/asm/topology.h +1 -0
@@ -111,6 +111,7 @@ extern const struct cpumask *cpu_coregroup_mask(int cpu);#define topology_core_id (cpu) (cpu_data(cpu).cpu_core_id)#ifdef CONFIG_SMP +#define topology_die_cpumask (cpu) (per_cpu(cpu_die_map, cpu))#define topology_core_cpumask (cpu) (per_cpu(cpu_core_map, cpu))#define topology_sibling_cpumask (cpu) (per_cpu(cpu_sibling_map, cpu))
arch/x86/kernel/smpboot.c +22 -0
@@ -90,6 +90,10 @@ EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);DEFINE_PER_CPU_READ_MOSTLY (cpumask_var_t, cpu_core_map);EXPORT_PER_CPU_SYMBOL (cpu_core_map); +/* representing HT, core, and die siblings of each logical CPU */ +DEFINE_PER_CPU_READ_MOSTLY (cpumask_var_t, cpu_die_map); +EXPORT_PER_CPU_SYMBOL (cpu_die_map); +DEFINE_PER_CPU_READ_MOSTLY (cpumask_var_t, cpu_llc_shared_map);/* Per CPU bogomips and other parameters */
@@ -513,6 +517,15 @@ static bool match_pkg(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)return false; } +static bool match_die (struct cpuinfo_x86 *c,struct cpuinfo_x86 *o) +{ +if ((c->phys_proc_id == o->phys_proc_id) && + (c->cpu_die_id == o->cpu_die_id)) +return true; +return false; +} + +#if defined(CONFIG_SCHED_SMT ) || defined(CONFIG_SCHED_MC )static inline int x86_sched_itmt_flags (void ) {
@@ -575,6 +588,7 @@ void set_cpu_sibling_map(int cpu)cpumask_set_cpu (cpu,topology_sibling_cpumask (cpu));cpumask_set_cpu (cpu,cpu_llc_shared_mask (cpu));cpumask_set_cpu (cpu,topology_core_cpumask (cpu)); +cpumask_set_cpu (cpu,topology_die_cpumask (cpu)); c->booted_cores =1 ;return ; }
@@ -623,6 +637,9 @@ void set_cpu_sibling_map(int cpu) }if (match_pkg (c, o) && !topology_same_node (c, o)) x86_has_numa_in_package = true; + +if ((i == cpu) || (has_mp &&match_die (c, o))) +link_mask (topology_die_cpumask, cpu, i); } threads =cpumask_weight (topology_sibling_cpumask (cpu));
@@ -1218,6 +1235,7 @@ static __init void disable_smp(void)physid_set_mask_of_physid (0 , &phys_cpu_present_map);cpumask_set_cpu (0 ,topology_sibling_cpumask (0 ));cpumask_set_cpu (0 ,topology_core_cpumask (0 )); +cpumask_set_cpu (0 ,topology_die_cpumask (0 )); }/*
@@ -1313,6 +1331,7 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)for_each_possible_cpu (i) {zalloc_cpumask_var (&per_cpu (cpu_sibling_map, i),GFP_KERNEL );zalloc_cpumask_var (&per_cpu (cpu_core_map, i),GFP_KERNEL ); +zalloc_cpumask_var (&per_cpu (cpu_die_map, i),GFP_KERNEL );zalloc_cpumask_var (&per_cpu (cpu_llc_shared_map, i),GFP_KERNEL ); }
@@ -1533,6 +1552,8 @@ static void remove_siblinginfo(int cpu)cpu_data (sibling).booted_cores--; } +for_each_cpu (sibling,topology_die_cpumask (cpu)) +cpumask_clear_cpu (cpu,topology_die_cpumask (sibling));for_each_cpu (sibling,topology_sibling_cpumask (cpu))cpumask_clear_cpu (cpu,topology_sibling_cpumask (sibling));for_each_cpu (sibling,cpu_llc_shared_mask (cpu))
@@ -1540,6 +1561,7 @@ static void remove_siblinginfo(int cpu)cpumask_clear (cpu_llc_shared_mask (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->booted_cores =0 ;cpumask_clear_cpu (cpu, cpu_sibling_setup_mask);
arch/x86/xen/smp_pv.c +1 -0
@@ -251,6 +251,7 @@ static void __init xen_pv_smp_prepare_cpus(unsigned int max_cpus)for_each_possible_cpu (i) {zalloc_cpumask_var (&per_cpu (cpu_sibling_map, i),GFP_KERNEL );zalloc_cpumask_var (&per_cpu (cpu_core_map, i),GFP_KERNEL ); +zalloc_cpumask_var (&per_cpu (cpu_die_map, i),GFP_KERNEL );zalloc_cpumask_var (&per_cpu (cpu_llc_shared_map, i),GFP_KERNEL ); }set_cpu_sibling_map (0 );
drivers/base/topology.c +12 -0
@@ -53,10 +53,18 @@ define_siblings_show_func(thread_siblings, sibling_cpumask);static DEVICE_ATTR_RO (thread_siblings);static DEVICE_ATTR_RO (thread_siblings_list); +define_siblings_show_func (core_threads, sibling_cpumask); +static DEVICE_ATTR_RO (core_threads); +static DEVICE_ATTR_RO (core_threads_list); +define_siblings_show_func (core_siblings, core_cpumask);static DEVICE_ATTR_RO (core_siblings);static DEVICE_ATTR_RO (core_siblings_list); +define_siblings_show_func (die_threads, die_cpumask); +static DEVICE_ATTR_RO (die_threads); +static DEVICE_ATTR_RO (die_threads_list); +define_siblings_show_func (package_threads, core_cpumask);static DEVICE_ATTR_RO (package_threads);static DEVICE_ATTR_RO (package_threads_list);
@@ -83,8 +91,12 @@ static struct attribute *default_attrs[] = { &dev_attr_core_id.attr, &dev_attr_thread_siblings.attr, &dev_attr_thread_siblings_list.attr, + &dev_attr_core_threads.attr, + &dev_attr_core_threads_list.attr, &dev_attr_core_siblings.attr, &dev_attr_core_siblings_list.attr, + &dev_attr_die_threads.attr, + &dev_attr_die_threads_list.attr, &dev_attr_package_threads.attr, &dev_attr_package_threads_list.attr, #ifdef CONFIG_SCHED_BOOK
include/linux/topology.h +3 -0
@@ -196,6 +196,9 @@ static inline int cpu_to_mem(int cpu)#ifndef topology_core_cpumask#define topology_core_cpumask (cpu) cpumask_of(cpu)#endif +#ifndef topology_die_cpumask +#define topology_die_cpumask (cpu) cpumask_of(cpu) +#endif #ifdef CONFIG_SCHED_SMT static inline const struct cpumask *cpu_smt_mask (int cpu)
Signature · 1 line
2.18.0-rc0
PATCH 7/14 x86 topology: Define topology_logical_die_id()
In reply to Len BrownFrom: Len Brown <[email protected]>
Define topology_logical_die_id() ala
existing topology_logical_package_id()
--- arch/x86/include/asm/processor.h | 1 + arch/x86/include/asm/topology.h | 7 +++++ arch/x86/kernel/cpu/common.c | 1 + arch/x86/kernel/smpboot.c | 45 ++++++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+)
arch/x86/include/asm/processor.h +1 -0
@@ -119,6 +119,7 @@ struct cpuinfo_x86 {/* Core id: */ u16 cpu_core_id;u16 cpu_die_id; +u16 logical_die_id;/* Index into per_cpu list: */ u16 cpu_index;u32 microcode;
arch/x86/include/asm/topology.h +7 -0
@@ -106,6 +106,7 @@ extern const struct cpumask *cpu_coregroup_mask(int cpu);#define topology_logical_package_id (cpu) (cpu_data(cpu).logical_proc_id)#define topology_physical_package_id (cpu) (cpu_data(cpu).phys_proc_id) +#define topology_logical_die_id (cpu) (cpu_data(cpu).logical_die_id)#define topology_die_id (cpu) (cpu_data(cpu).cpu_die_id)#define topology_core_id (cpu) (cpu_data(cpu).cpu_core_id)
@@ -124,14 +125,20 @@ static inline int topology_max_smt_threads(void) }int topology_update_package_map (unsigned int apicid,unsigned int cpu); +int topology_update_die_map (unsigned int dieid,unsigned int cpu);int topology_phys_to_logical_pkg (unsigned int pkg); +int topology_phys_to_logical_die (unsigned int die,unsigned int cpu);bool topology_is_primary_thread (unsigned int cpu);bool topology_smt_supported (void );#else #define topology_max_packages () (1)static inline int topology_update_package_map (unsigned int apicid,unsigned int cpu) {return 0 ; } +static inline int +topology_update_die_map (unsigned int dieid,unsigned int cpu) {return 0 ; }static inline int topology_phys_to_logical_pkg (unsigned int pkg) {return 0 ; } +static inline int topology_phys_to_logical_die (unsigned int die, +unsigned int cpu) {return 0 ; }static inline int topology_max_smt_threads (void ) {return 1 ; }static inline bool topology_is_primary_thread (unsigned int cpu) {return true; }static inline bool topology_smt_supported (void ) {return false; }
arch/x86/kernel/cpu/common.c +1 -0
@@ -1285,6 +1285,7 @@ static void validate_apic_and_package_id(struct cpuinfo_x86 *c) cpu, apicid, c->initial_apicid); }BUG_ON (topology_update_package_map (c->phys_proc_id, cpu)); +BUG_ON (topology_update_die_map (c->cpu_die_id, cpu));#else c->logical_proc_id =0 ;#endif
arch/x86/kernel/smpboot.c +45 -0
69 lines not on this page · raw message
Signature · 1 line
2.18.0-rc0
PATCH 5/14 cpu topology: Export die_id
In reply to Len BrownFrom: Len Brown <[email protected]>
Export die_id in cpu topology, for the benefit of hardware that has multiple-die/package.
--- Documentation/cputopology.txt | 15 ++++++++++++--- drivers/base/topology.c | 4 ++++ include/linux/topology.h | 3 +++ 3 files changed, 19 insertions(+), 3 deletions(-)
Documentation/cputopology.txt +12 -3
@@ -12,6 +12,12 @@ physical_package_id: socket number, but the actual value is architecture and platform dependent. +die_id: + + the CPU die ID of cpuX. Typically it is the hardware platform's + identifier (rather than the kernel's). The actual value is + architecture and platform dependent. + core_id: the CPU core ID of cpuX. Typically it is the hardware platform's
@@ -81,6 +87,7 @@ For an architecture to support this feature, it must define some of these macros in include/asm-XXX/topology.h:: #define topology_physical_package_id(cpu) + #define topology_die_id(cpu) #define topology_core_id(cpu) #define topology_book_id(cpu) #define topology_drawer_id(cpu)
@@ -99,9 +106,11 @@ provides default definitions for any of the above macros that are not defined by include/asm-XXX/topology.h: 1) topology_physical_package_id: -1 -2) topology_core_id: 0 -3) topology_sibling_cpumask: just the given CPU -4) topology_core_cpumask: just the given CPU +2) topology_die_id: -1 +3) topology_core_id: 0 +4) topology_sibling_cpumask: just the given CPU +5) topology_core_cpumask: just the given CPU +6) topology_die_cpumask: just the given CPU For architectures that don't support books (CONFIG_SCHED_BOOK) there are no default definitions for topology_book_id() and topology_book_cpumask().
drivers/base/topology.c +4 -0
@@ -43,6 +43,9 @@ static ssize_t name##_list_show(struct device *dev, \define_id_show_func (physical_package_id);static DEVICE_ATTR_RO (physical_package_id); +define_id_show_func (die_id); +static DEVICE_ATTR_RO (die_id); +define_id_show_func (core_id);static DEVICE_ATTR_RO (core_id);
@@ -72,6 +75,7 @@ static DEVICE_ATTR_RO(drawer_siblings_list);static struct attribute *default_attrs[] = { &dev_attr_physical_package_id.attr, + &dev_attr_die_id.attr, &dev_attr_core_id.attr, &dev_attr_thread_siblings.attr, &dev_attr_thread_siblings_list.attr,
include/linux/topology.h +3 -0
@@ -184,6 +184,9 @@ static inline int cpu_to_mem(int cpu)#ifndef topology_physical_package_id#define topology_physical_package_id (cpu) ((void)(cpu), -1)#endif +#ifndef topology_die_id +#define topology_die_id (cpu) ((void)(cpu), -1) +#endif #ifndef topology_core_id#define topology_core_id (cpu) ((void)(cpu), 0)#endif
Signature · 1 line
2.18.0-rc0
PATCH 2/14 topolgy: Simplify cputopology.txt formatting and wording
In reply to Len BrownFrom: Len Brown <[email protected]>
Syntax only, no functional or semantic change.
--- Documentation/cputopology.txt | 46 +++++++++++++++++------------------ 1 file changed, 23 insertions(+), 23 deletions(-)
Documentation/cputopology.txt +23 -23
@@ -3,79 +3,79 @@ How CPU topology info is exported via sysfs =========================================== Export CPU topology info via sysfs. Items (attributes) are similar -to /proc/cpuinfo output of some architectures: +to /proc/cpuinfo output of some architectures. They reside in +/sys/devices/system/cpu/cpuX/topology/: -1) /sys/devices/system/cpu/cpuX/topology/physical_package_id: +physical_package_id: physical package id of cpuX. Typically corresponds to a physical socket number, but the actual value is architecture and platform dependent. -2) /sys/devices/system/cpu/cpuX/topology/core_id: +core_id: the CPU core ID of cpuX. Typically it is the hardware platform's identifier (rather than the kernel's). The actual value is architecture and platform dependent. -3) /sys/devices/system/cpu/cpuX/topology/book_id: +book_id: the book ID of cpuX. Typically it is the hardware platform's identifier (rather than the kernel's). The actual value is architecture and platform dependent. -4) /sys/devices/system/cpu/cpuX/topology/drawer_id: +drawer_id: the drawer ID of cpuX. Typically it is the hardware platform's identifier (rather than the kernel's). The actual value is architecture and platform dependent. -5) /sys/devices/system/cpu/cpuX/topology/thread_siblings: +thread_siblings: internal kernel map of cpuX's hardware threads within the same core as cpuX. -6) /sys/devices/system/cpu/cpuX/topology/thread_siblings_list: +thread_siblings_list: human-readable list of cpuX's hardware threads within the same core as cpuX. -7) /sys/devices/system/cpu/cpuX/topology/core_siblings: +core_siblings: internal kernel map of cpuX's hardware threads within the same physical_package_id. -8) /sys/devices/system/cpu/cpuX/topology/core_siblings_list: +core_siblings_list: human-readable list of cpuX's hardware threads within the same physical_package_id. -9) /sys/devices/system/cpu/cpuX/topology/book_siblings: +book_siblings: internal kernel map of cpuX's hardware threads within the same book_id. -10) /sys/devices/system/cpu/cpuX/topology/book_siblings_list: +book_siblings_list: human-readable list of cpuX's hardware threads within the same book_id. -11) /sys/devices/system/cpu/cpuX/topology/drawer_siblings: +drawer_siblings: internal kernel map of cpuX's hardware threads within the same drawer_id. -12) /sys/devices/system/cpu/cpuX/topology/drawer_siblings_list: +drawer_siblings_list: human-readable list of cpuX's hardware threads within the same drawer_id. -To implement it in an architecture-neutral way, a new source file, -drivers/base/topology.c, is to export the 6 to 12 attributes. The book -and drawer related sysfs files will only be created if CONFIG_SCHED_BOOK -and CONFIG_SCHED_DRAWER are selected. +Architecture-neutral, drivers/base/topology.c, exports these attributes. +However, the book and drawer related sysfs files will only be created if +CONFIG_SCHED_BOOK and CONFIG_SCHED_DRAWER are selected, respectively. -CONFIG_SCHED_BOOK and CONFIG_DRAWER are currently only used on s390, where -they reflect the cpu and cache hierarchy. +CONFIG_SCHED_BOOK and CONFIG_SCHED_DRAWER are currently only used on s390, +where they reflect the cpu and cache hierarchy. For an architecture to support this feature, it must define some of these macros in include/asm-XXX/topology.h::
@@ -98,10 +98,10 @@ To be consistent on all architectures, include/linux/topology.h provides default definitions for any of the above macros that are not defined by include/asm-XXX/topology.h: -1) physical_package_id: -1 -2) core_id: 0 -3) sibling_cpumask: just the given CPU -4) core_cpumask: just the given CPU +1) topology_physical_package_id: -1 +2) topology_core_id: 0 +3) topology_sibling_cpumask: just the given CPU +4) topology_core_cpumask: just the given CPU For architectures that don't support books (CONFIG_SCHED_BOOK) there are no default definitions for topology_book_id() and topology_book_cpumask().
Signature · 1 line
2.18.0-rc0
PATCH 3/14 x86 smpboot: Rename match_die() to match_pkg()
In reply to Len BrownFrom: Len Brown <[email protected]>
Syntax only, no functional or semantic change.
This routine matches packages, not die, so name it thus.
--- arch/x86/kernel/smpboot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/smpboot.c +3 -3
@@ -459,7 +459,7 @@ static bool match_llc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)* multicore group inside a NUMA node. If this happens, we will * discard the MC level of the topology later. */ -static bool match_die (struct cpuinfo_x86 *c,struct cpuinfo_x86 *o) +static bool match_pkg (struct cpuinfo_x86 *c,struct cpuinfo_x86 *o) {if (c->phys_proc_id == o->phys_proc_id)return true;
@@ -550,7 +550,7 @@ void set_cpu_sibling_map(int cpu)for_each_cpu (i, cpu_sibling_setup_mask) { o = &cpu_data (i); -if ((i == cpu) || (has_mp &&match_die (c, o))) { +if ((i == cpu) || (has_mp &&match_pkg (c, o))) {link_mask (topology_core_cpumask, cpu, i);/*
@@ -574,7 +574,7 @@ void set_cpu_sibling_map(int cpu) }else if (i != cpu && !c->booted_cores) c->booted_cores =cpu_data (i).booted_cores; } -if (match_die (c, o) && !topology_same_node (c, o)) +if (match_pkg (c, o) && !topology_same_node (c, o)) x86_has_numa_in_package = true; }
Signature · 1 line
2.18.0-rc0