v6 multi-die/package topology support
Subsystems (9)
PATCH 6/19 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) {
@@ -1300,7 +1301,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,
@@ -1456,8 +1457,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;
@@ -1466,7 +1468,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 */
@@ -1497,12 +1499,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); }
@@ -1512,11 +1513,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 7/19 powercap/intel_rapl: Support multi-die/package
In reply to Len BrownFrom: Zhang Rui <[email protected]>
RAPL "package" domains are actually implemented in hardware per-die. Thus, the new multi-die/package systems have mulitple domains within each physical package.
Update the intel_rapl driver to be "die aware" -- exporting multiple domains within a single package, when present.
No change on single die/package systems.
--- 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) {
@@ -1459,7 +1459,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 9/19 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/package.
Update driver debug messages.
--- 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 ; }
@@ -1181,7 +1185,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++) {
@@ -1206,7 +1210,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;
@@ -1217,20 +1220,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 */
@@ -1256,8 +1255,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; }
@@ -1270,7 +1269,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); }
@@ -1380,8 +1379,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 ; } }
@@ -1410,10 +1409,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 );
@@ -1446,8 +1445,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 */
@@ -1461,6 +1460,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 );
@@ -1471,6 +1471,13 @@ static struct rapl_package *rapl_add_package(int cpu) rp->id = id; rp->lead_cpu = cpu; +if (topology_max_die_per_package () >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 10/19 hwmon/coretemp: Support multi-die/package
In reply to Len BrownFrom: Zhang Rui <[email protected]>
Package temperature sensors are actually implemented in hardware per-die.
Update coretemp to be "die-aware", so it can expose mulitple sensors per package, instead of just one. No change to single-die/package systems.
--- drivers/hwmon/coretemp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/coretemp.c +4 -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 ; }
@@ -741,7 +741,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 () *topology_max_die_per_package (); pkg_devices =kcalloc (max_packages,sizeof (struct platform_device *),GFP_KERNEL );if (!pkg_devices)
Signature · 1 line
2.18.0-rc0
cover v6 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 no 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.
Changes since v5:
The patch numbers have decremented by 3, since the first 3 patches in the original series are now upstream.
The last two "Cosmetic rename" patches have been replaced with those by Kan, who did a more thorough variable rename than I had originally proposed.
[PATCH 18/19] perf/x86/intel/uncore: Cosmetic renames in response to multi-die/pkg support [PATCH 19/19] perf/x86/intel/rapl: Cosmetic rename internal variables in response to multi-die/pkg support
I'm not aware of any outstanding feedback on this series, functional or cosmetic.
thanks,
Len Brown, Intel Opensource Technology Center
--------------
The following changes since commit a13f0655503a4a89df67fdc7cac6a7810795d4b3:
Merge tag 'iommu-updates-v5.2' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/joro/iommu (2019-05-13 09:23:18 -0400)
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 0ddb97e121397d37933233da303556141814fa47:
perf/x86/intel/rapl: Cosmetic rename internal variables in response to multi-die/pkg support (2019-05-13 13:41:50 -0400)
----------------------------------------------------------------
Kan Liang (5):
perf/x86/intel/uncore: Support multi-die/package
perf/x86/intel/rapl: Support multi-die/package
perf/x86/intel/cstate: Support multi-die/package
perf/x86/intel/uncore: Cosmetic renames in response to multi-die/pkg support perf/x86/intel/rapl: Cosmetic rename internal variables in response to multi-die/pkg support
Len Brown (9):
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 thermal/x86_pkg_temp_thermal: Cosmetic: Rename internal variables to zones from packages hwmon/coretemp: Cosmetic: Rename internal variables to zones from packages
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 | 48 ++++++--- Documentation/x86/topology.rst | 4 + arch/x86/events/intel/cstate.c | 14 ++- arch/x86/events/intel/rapl.c | 20 ++-- arch/x86/events/intel/uncore.c | 80 +++++++-------- arch/x86/events/intel/uncore.h | 4 +- arch/x86/events/intel/uncore_snbep.c | 4 +- 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 | 69 +++++++++++++ arch/x86/xen/smp_pv.c | 1 + drivers/base/topology.c | 22 +++++ drivers/hwmon/coretemp.c | 36 +++---- drivers/powercap/intel_rapl.c | 75 +++++++------- drivers/thermal/intel/x86_pkg_temp_thermal.c | 142 ++++++++++++++------------- include/linux/topology.h | 6 ++ 19 files changed, 422 insertions(+), 214 deletions(-)
PATCH 3/19 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 4/19 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 14/19 perf/x86/intel/rapl: Support multi-die/package
In reply to Len BrownFrom: Kan Liang <[email protected]>
RAPL becomes die-scope on Xeon Cascade Lake-AP. Perf RAPL driver needs to support die-scope RAPL domain.
Use topology_logical_die_id() to replace topology_logical_package_id(). For previous platforms which doesn't have multi-die, topology_logical_die_id() is identical as topology_logical_package_id().
Use topology_die_cpumask() to replace topology_core_cpumask(). For previous platforms which doesn't have multi-die, topology_die_cpumask() is identical as topology_core_cpumask().
There is no functional change for previous platforms.
--- arch/x86/events/intel/rapl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/x86/events/intel/rapl.c +5 -5
@@ -161,7 +161,7 @@ static u64 rapl_timer_ms;static inline struct rapl_pmu *cpu_to_rapl_pmu (unsigned int cpu) { -unsigned int pkgid =topology_logical_package_id (cpu); +unsigned int pkgid =topology_logical_die_id (cpu);/* * The unsigned check also catches the '-1' return value for non
@@ -571,7 +571,7 @@ static int rapl_cpu_offline(unsigned int cpu) pmu->cpu =-1 ;/* Find a new cpu to collect rapl events */ - target =cpumask_any_but (topology_core_cpumask (cpu), cpu); + target =cpumask_any_but (topology_die_cpumask (cpu), cpu);/* Migrate rapl events to the new target */ if (target < nr_cpu_ids) {
@@ -598,14 +598,14 @@ static int rapl_cpu_online(unsigned int cpu) pmu->timer_interval =ms_to_ktime (rapl_timer_ms);rapl_hrtimer_init (pmu); - rapl_pmus->pmus[topology_logical_package_id (cpu)] = pmu; + rapl_pmus->pmus[topology_logical_die_id (cpu)] = pmu; }/* * Check if there is an online cpu in the package which collects rapl * events already. */ - target =cpumask_any_and (&rapl_cpu_mask,topology_core_cpumask (cpu)); + target =cpumask_any_and (&rapl_cpu_mask,topology_die_cpumask (cpu));if (target < nr_cpu_ids)return 0 ;
@@ -675,7 +675,7 @@ static void cleanup_rapl_pmus(void)static int __init init_rapl_pmus (void ) { -int maxpkg =topology_max_packages (); +int maxpkg =topology_max_packages () *topology_max_die_per_package ();size_t size; size =sizeof (*rapl_pmus) + maxpkg *sizeof (struct rapl_pmu *);
Signature · 1 line
2.18.0-rc0
PATCH 15/19 perf/x86/intel/cstate: Support multi-die/package
In reply to Len BrownFrom: Kan Liang <[email protected]>
Some cstate counters becomes die-scope on Xeon Cascade Lake-AP. Perf cstate driver needs to support die-scope cstate counters.
Use topology_die_cpumask() to replace topology_core_cpumask(). For previous platforms which doesn't have multi-die, topology_die_cpumask() is identical as topology_core_cpumask(). There is no functional change for previous platforms.
Name the die-scope PMU "cstate_die".
--- arch/x86/events/intel/cstate.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
arch/x86/events/intel/cstate.c +10 -4
@@ -302,7 +302,7 @@ static int cstate_pmu_event_init(struct perf_event *event)return -EINVAL ; event->hw.event_base = pkg_msr[cfg].msr; cpu =cpumask_any_and (&cstate_pkg_cpu_mask, -topology_core_cpumask (event->cpu)); +topology_die_cpumask (event->cpu)); }else {return -ENOENT ; }
@@ -385,7 +385,7 @@ static int cstate_cpu_exit(unsigned int cpu)if (has_cstate_pkg &&cpumask_test_and_clear_cpu (cpu, &cstate_pkg_cpu_mask)) { - target =cpumask_any_but (topology_core_cpumask (cpu), cpu); + target =cpumask_any_but (topology_die_cpumask (cpu), cpu);/* Migrate events if there is a valid target */ if (target < nr_cpu_ids) {cpumask_set_cpu (target, &cstate_pkg_cpu_mask);
@@ -414,7 +414,7 @@ static int cstate_cpu_init(unsigned int cpu)* in the package cpu mask as the designated reader. */ target =cpumask_any_and (&cstate_pkg_cpu_mask, -topology_core_cpumask (cpu)); +topology_die_cpumask (cpu));if (has_cstate_pkg && target >= nr_cpu_ids)cpumask_set_cpu (cpu, &cstate_pkg_cpu_mask);
@@ -663,7 +663,13 @@ static int __init cstate_init(void) }if (has_cstate_pkg) { - err =perf_pmu_register (&cstate_pkg_pmu, cstate_pkg_pmu.name,-1 ); +if (topology_max_die_per_package () >1 ) { + err =perf_pmu_register (&cstate_pkg_pmu, +"cstate_die" ,-1 ); + }else { + err =perf_pmu_register (&cstate_pkg_pmu, + cstate_pkg_pmu.name,-1 ); + }if (err) { has_cstate_pkg = false;pr_info ("Failed to register cstate pkg pmu\n" );
Signature · 1 line
2.18.0-rc0
PATCH 19/19 perf/x86/intel/rapl: Cosmetic rename internal variables in response to multi-die/pkg support
In reply to Len BrownFrom: Kan Liang <[email protected]>
Syntax update only -- no logical or functional change.
In response to the new multi-die/package changes, update variable names to use "die" terminology, instead of "pkg".
For previous platforms which doesn't have multi-die, "die" is identical as "pkg".
--- arch/x86/events/intel/rapl.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
arch/x86/events/intel/rapl.c +7 -7
@@ -148,7 +148,7 @@ struct rapl_pmu {struct rapl_pmus {struct pmu pmu; -unsigned int maxpkg; +unsigned int maxdie;struct rapl_pmu *pmus[]; };
@@ -161,13 +161,13 @@ static u64 rapl_timer_ms;static inline struct rapl_pmu *cpu_to_rapl_pmu (unsigned int cpu) { -unsigned int pkgid =topology_logical_die_id (cpu); +unsigned int dieid =topology_logical_die_id (cpu);/* * The unsigned check also catches the '-1' return value for non * existent mappings in the topology map. */ -return pkgid < rapl_pmus->maxpkg ? rapl_pmus->pmus[pkgid] :NULL ; +return dieid < rapl_pmus->maxdie ? rapl_pmus->pmus[dieid] :NULL ; }static inline u64 rapl_read_counter (struct perf_event *event)
@@ -668,22 +668,22 @@ static void cleanup_rapl_pmus(void) {int i; -for (i =0 ; i < rapl_pmus->maxpkg; i++) +for (i =0 ; i < rapl_pmus->maxdie; i++)kfree (rapl_pmus->pmus[i]);kfree (rapl_pmus); }static int __init init_rapl_pmus (void ) { -int maxpkg =topology_max_packages () *topology_max_die_per_package (); +int maxdie =topology_max_packages () *topology_max_die_per_package ();size_t size; - size =sizeof (*rapl_pmus) + maxpkg *sizeof (struct rapl_pmu *); + size =sizeof (*rapl_pmus) + maxdie *sizeof (struct rapl_pmu *); rapl_pmus =kzalloc (size,GFP_KERNEL );if (!rapl_pmus)return -ENOMEM ; - rapl_pmus->maxpkg = maxpkg; + rapl_pmus->maxdie = maxdie; rapl_pmus->pmu.attr_groups = rapl_attr_groups; rapl_pmus->pmu.task_ctx_nr = perf_invalid_context; rapl_pmus->pmu.event_init = rapl_pmu_event_init;
Signature · 1 line
2.18.0-rc0
PATCH 18/19 perf/x86/intel/uncore: Cosmetic renames in response to multi-die/pkg support
In reply to Len BrownFrom: Kan Liang <[email protected]>
Syntax update only -- no logical or functional change.
In response to the new multi-die/package changes, update variable names to use "die" terminology, instead of "pkg".
For previous platforms which doesn't have multi-die, "die" is identical as "pkg".
--- arch/x86/events/intel/uncore.c | 74 ++++++++++++++-------------- arch/x86/events/intel/uncore.h | 4 +- arch/x86/events/intel/uncore_snbep.c | 4 +- 3 files changed, 41 insertions(+), 41 deletions(-)
arch/x86/events/intel/uncore.c +37 -37
@@ -14,7 +14,7 @@ struct pci_driver *uncore_pci_driver;DEFINE_RAW_SPINLOCK (pci2phy_map_lock);struct list_head pci2phy_map_head =LIST_HEAD_INIT (pci2phy_map_head);struct pci_extra_dev *uncore_extra_pci_dev; -static int max_packages; +static int max_dies;/* mask of cpus that collect uncore events */ static cpumask_t uncore_cpu_mask;
@@ -100,13 +100,13 @@ ssize_t uncore_event_show(struct kobject *kobj,struct intel_uncore_box *uncore_pmu_to_box (struct intel_uncore_pmu *pmu,int cpu) { -unsigned int pkgid =topology_logical_die_id (cpu); +unsigned int dieid =topology_logical_die_id (cpu);/* * The unsigned check also catches the '-1' return value for non * existent mappings in the topology map. */ -return pkgid < max_packages ? pmu->boxes[pkgid] :NULL ; +return dieid < max_dies ? pmu->boxes[dieid] :NULL ; }u64 uncore_msr_read_counter (struct intel_uncore_box *box,struct perf_event *event)
@@ -311,7 +311,7 @@ static struct intel_uncore_box *uncore_alloc_box(struct intel_uncore_type *type,uncore_pmu_init_hrtimer (box); box->cpu =-1 ; box->pci_phys_id =-1 ; - box->pkgid =-1 ; + box->dieid =-1 ;/* set default hrtimer timeout */ box->hrtimer_duration =UNCORE_PMU_HRTIMER_INTERVAL ;
@@ -826,10 +826,10 @@ static void uncore_pmu_unregister(struct intel_uncore_pmu *pmu)static void uncore_free_boxes (struct intel_uncore_pmu *pmu) { -int pkg; +int die; -for (pkg =0 ; pkg < max_packages; pkg++) -kfree (pmu->boxes[pkg]); +for (die =0 ; die < max_dies; die++) +kfree (pmu->boxes[die]);kfree (pmu->boxes); }
@@ -866,7 +866,7 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid)if (!pmus)return -ENOMEM ; - size = max_packages *sizeof (struct intel_uncore_box *); + size = max_dies *sizeof (struct intel_uncore_box *);for (i =0 ; i < type->num_boxes; i++) { pmus[i].func_id = setid ? i :-1 ;
@@ -936,21 +936,21 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *idstruct intel_uncore_type *type;struct intel_uncore_pmu *pmu =NULL ;struct intel_uncore_box *box; -int phys_id, pkg, ret; +int phys_id, die, ret; phys_id =uncore_pcibus_to_physid (pdev->bus);if (phys_id <0 )return -ENODEV ; - pkg = (topology_max_die_per_package () >1 ) ? phys_id : + die = (topology_max_die_per_package () >1 ) ? phys_id :topology_phys_to_logical_pkg (phys_id); -if (pkg <0 ) +if (die <0 )return -EINVAL ;if (UNCORE_PCI_DEV_TYPE (id->driver_data) ==UNCORE_EXTRA_PCI_DEV ) {int idx =UNCORE_PCI_DEV_IDX (id->driver_data); - uncore_extra_pci_dev[pkg].dev[idx] = pdev; + uncore_extra_pci_dev[die].dev[idx] = pdev;pci_set_drvdata (pdev,NULL );return 0 ; }
@@ -989,7 +989,7 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id pmu = &type->pmus[UNCORE_PCI_DEV_IDX (id->driver_data)]; } -if (WARN_ON_ONCE (pmu->boxes[pkg] !=NULL )) +if (WARN_ON_ONCE (pmu->boxes[die] !=NULL ))return -EINVAL ; box =uncore_alloc_box (type,NUMA_NO_NODE );
@@ -1003,13 +1003,13 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *idatomic_inc (&box->refcnt); box->pci_phys_id = phys_id; - box->pkgid = pkg; + box->dieid = die; box->pci_dev = pdev; box->pmu = pmu;uncore_box_init (box);pci_set_drvdata (pdev, box); - pmu->boxes[pkg] = box; + pmu->boxes[die] = box;if (atomic_inc_return (&pmu->activeboxes) >1 )return 0 ;
@@ -1017,7 +1017,7 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id ret =uncore_pmu_register (pmu);if (ret) {pci_set_drvdata (pdev,NULL ); - pmu->boxes[pkg] =NULL ; + pmu->boxes[die] =NULL ;uncore_box_exit (box);kfree (box); }
@@ -1028,17 +1028,17 @@ static void uncore_pci_remove(struct pci_dev *pdev) {struct intel_uncore_box *box;struct intel_uncore_pmu *pmu; -int i, phys_id, pkg; +int i, phys_id, die; phys_id =uncore_pcibus_to_physid (pdev->bus); box =pci_get_drvdata (pdev);if (!box) { - pkg = (topology_max_die_per_package () >1 ) ? phys_id : + die = (topology_max_die_per_package () >1 ) ? phys_id :topology_phys_to_logical_pkg (phys_id);for (i =0 ; i <UNCORE_EXTRA_PCI_DEV_MAX ; i++) { -if (uncore_extra_pci_dev[pkg].dev[i] == pdev) { - uncore_extra_pci_dev[pkg].dev[i] =NULL ; +if (uncore_extra_pci_dev[die].dev[i] == pdev) { + uncore_extra_pci_dev[die].dev[i] =NULL ;break ; } }
@@ -1051,7 +1051,7 @@ static void uncore_pci_remove(struct pci_dev *pdev)return ;pci_set_drvdata (pdev,NULL ); - pmu->boxes[box->pkgid] =NULL ; + pmu->boxes[box->dieid] =NULL ;if (atomic_dec_return (&pmu->activeboxes) ==0 )uncore_pmu_unregister (pmu);uncore_box_exit (box);
@@ -1063,7 +1063,7 @@ static int __init uncore_pci_init(void)size_t size;int ret; - size = max_packages *sizeof (struct pci_extra_dev ); + size = max_dies *sizeof (struct pci_extra_dev ); uncore_extra_pci_dev =kzalloc (size,GFP_KERNEL );if (!uncore_extra_pci_dev) { ret = -ENOMEM ;
@@ -1110,11 +1110,11 @@ static void uncore_change_type_ctx(struct intel_uncore_type *type, int old_cpu, {struct intel_uncore_pmu *pmu = type->pmus;struct intel_uncore_box *box; -int i, pkg; +int i, die; - pkg =topology_logical_die_id (old_cpu <0 ? new_cpu : old_cpu); + die =topology_logical_die_id (old_cpu <0 ? new_cpu : old_cpu);for (i =0 ; i < type->num_boxes; i++, pmu++) { - box = pmu->boxes[pkg]; + box = pmu->boxes[die];if (!box)continue ;
@@ -1147,7 +1147,7 @@ static int uncore_event_cpu_offline(unsigned int cpu)struct intel_uncore_type *type, **types = uncore_msr_uncores;struct intel_uncore_pmu *pmu;struct intel_uncore_box *box; -int i, pkg, target; +int i, die, target;/* Check if exiting cpu is used for collecting uncore events */ if (!cpumask_test_and_clear_cpu (cpu, &uncore_cpu_mask))
@@ -1166,12 +1166,12 @@ static int uncore_event_cpu_offline(unsigned int cpu) unref:/* Clear the references */ - pkg =topology_logical_die_id (cpu); + die =topology_logical_die_id (cpu);for (; *types; types++) { type = *types; pmu = type->pmus;for (i =0 ; i < type->num_boxes; i++, pmu++) { - box = pmu->boxes[pkg]; + box = pmu->boxes[die];if (box &&atomic_dec_return (&box->refcnt) ==0 )uncore_box_exit (box); }
@@ -1180,7 +1180,7 @@ static int uncore_event_cpu_offline(unsigned int cpu) }static int allocate_boxes (struct intel_uncore_type **types, -unsigned int pkg,unsigned int cpu) +unsigned int die,unsigned int cpu) {struct intel_uncore_box *box, *tmp;struct intel_uncore_type *type;
@@ -1193,20 +1193,20 @@ static int allocate_boxes(struct intel_uncore_type **types, type = *types; pmu = type->pmus;for (i =0 ; i < type->num_boxes; i++, pmu++) { -if (pmu->boxes[pkg]) +if (pmu->boxes[die])continue ; box =uncore_alloc_box (type,cpu_to_node (cpu));if (!box) goto cleanup; box->pmu = pmu; - box->pkgid = pkg; + box->dieid = die;list_add (&box->active_list, &allocated); } }/* Install them in the pmus */ list_for_each_entry_safe (box, tmp, &allocated, active_list) {list_del_init (&box->active_list); - box->pmu->boxes[pkg] = box; + box->pmu->boxes[die] = box; }return 0 ;
@@ -1223,10 +1223,10 @@ static int uncore_event_cpu_online(unsigned int cpu)struct intel_uncore_type *type, **types = uncore_msr_uncores;struct intel_uncore_pmu *pmu;struct intel_uncore_box *box; -int i, ret, pkg, target; +int i, ret, die, target; - pkg =topology_logical_die_id (cpu); - ret =allocate_boxes (types, pkg, cpu); + die =topology_logical_die_id (cpu); + ret =allocate_boxes (types, die, cpu);if (ret)return ret;
@@ -1234,7 +1234,7 @@ static int uncore_event_cpu_online(unsigned int cpu) type = *types; pmu = type->pmus;for (i =0 ; i < type->num_boxes; i++, pmu++) { - box = pmu->boxes[pkg]; + box = pmu->boxes[die];if (box &&atomic_inc_return (&box->refcnt) ==1 )uncore_box_init (box); }
@@ -1419,7 +1419,7 @@ static int __init intel_uncore_init(void)if (boot_cpu_has (X86_FEATURE_HYPERVISOR ))return -ENODEV ; - max_packages =topology_max_packages () *topology_max_die_per_package (); + max_dies =topology_max_packages () *topology_max_die_per_package (); uncore_init = (struct intel_uncore_init_fun *)id->driver_data;if (uncore_init->pci_init) {
arch/x86/events/intel/uncore.h +2 -2
@@ -108,7 +108,7 @@ struct intel_uncore_extra_reg {struct intel_uncore_box {int pci_phys_id; -int pkgid;/* Logical package ID */ +int dieid;/* Logical die ID */ int n_active;/* number of active events */ int n_events;int cpu;/* cpu to collect events */
@@ -467,7 +467,7 @@ static inline void uncore_box_exit(struct intel_uncore_box *box)static inline bool uncore_box_is_fake (struct intel_uncore_box *box) { -return (box->pkgid <0 ); +return (box->dieid <0 ); }static inline struct intel_uncore_pmu *uncore_event_to_pmu (struct perf_event *event)
arch/x86/events/intel/uncore_snbep.c +2 -2
@@ -1058,8 +1058,8 @@ static void snbep_qpi_enable_event(struct intel_uncore_box *box, struct perf_eveif (reg1->idx !=EXTRA_REG_NONE ) {int idx = box->pmu->pmu_idx +SNBEP_PCI_QPI_PORT0_FILTER ; -int pkg = box->pkgid; -struct pci_dev *filter_pdev = uncore_extra_pci_dev[pkg].dev[idx]; +int die = box->dieid; +struct pci_dev *filter_pdev = uncore_extra_pci_dev[die].dev[idx];if (filter_pdev) { pci_write_config_dword(filter_pdev, reg1->reg,
Signature · 1 line
2.18.0-rc0
PATCH 17/19 hwmon/coretemp: Cosmetic: Rename internal variables to zones from packages
In reply to Len BrownFrom: Len Brown <[email protected]>
Syntax update only -- no logical or functional change.
In response to the new multi-die/package changes, update variable names to use the more generic thermal "zone" terminology, instead of "package", as the zones can refer to either packages or die.
--- drivers/hwmon/coretemp.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/hwmon/coretemp.c +18 -18
@@ -109,10 +109,10 @@ struct platform_data {struct device_attribute name_attr; }; -/* Keep track of how many package pointers we allocated in init() */ -static int max_packages__read_mostly ; -/* Array of package pointers. Serialized by cpu hotplug lock */ -static struct platform_device **pkg_devices; +/* Keep track of how many zone pointers we allocated in init() */ +static int max_zones__read_mostly ; +/* Array of zone pointers. Serialized by cpu hotplug lock */ +static struct platform_device **zone_devices;static ssize_t show_label (struct device *dev,struct device_attribute *devattr,char *buf)
@@ -435,10 +435,10 @@ static int chk_ucode_version(unsigned int cpu)static struct platform_device *coretemp_get_pdev (unsigned int cpu) { -int pkgid =topology_logical_die_id (cpu); +int id =topology_logical_die_id (cpu); -if (pkgid >=0 && pkgid < max_packages) -return pkg_devices[pkgid]; +if (id >=0 && id < max_zones) +return zone_devices[id];return NULL ; }
@@ -544,7 +544,7 @@ static int coretemp_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct platform_data *pdata; -/* Initialize the per-package data structures */ +/* Initialize the per-zone data structures */ pdata =devm_kzalloc (dev,sizeof (struct platform_data ),GFP_KERNEL );if (!pdata)return -ENOMEM ;
@@ -579,13 +579,13 @@ static struct platform_driver coretemp_driver = {static struct platform_device *coretemp_device_add (unsigned int cpu) { -int err, pkgid =topology_logical_die_id (cpu); +int err, zoneid =topology_logical_die_id (cpu);struct platform_device *pdev; -if (pkgid <0 ) +if (zoneid <0 )return ERR_PTR (-ENOMEM ); - pdev =platform_device_alloc (DRVNAME , pkgid); + pdev =platform_device_alloc (DRVNAME , zoneid);if (!pdev)return ERR_PTR (-ENOMEM );
@@ -595,7 +595,7 @@ static struct platform_device *coretemp_device_add(unsigned int cpu)return ERR_PTR (err); } - pkg_devices[pkgid] = pdev; + zone_devices[zoneid] = pdev;return pdev; }
@@ -703,7 +703,7 @@ static int coretemp_cpu_offline(unsigned int cpu)* the rest. */ if (cpumask_empty (&pd->cpumask)) { - pkg_devices[topology_logical_die_id (cpu)] =NULL ; + zone_devices[topology_logical_die_id (cpu)] =NULL ;platform_device_unregister (pdev);return 0 ; }
@@ -741,10 +741,10 @@ static int __init coretemp_init(void)if (!x86_match_cpu (coretemp_ids))return -ENODEV ; - max_packages =topology_max_packages () *topology_max_die_per_package (); - pkg_devices =kcalloc (max_packages,sizeof (struct platform_device *), + max_zones =topology_max_packages () *topology_max_die_per_package (); + zone_devices =kcalloc (max_zones,sizeof (struct platform_device *),GFP_KERNEL ); -if (!pkg_devices) +if (!zone_devices)return -ENOMEM ; err =platform_driver_register (&coretemp_driver);
@@ -760,7 +760,7 @@ static int __init coretemp_init(void) outdrv:platform_driver_unregister (&coretemp_driver); -kfree (pkg_devices); +kfree (zone_devices);return err; }module_init (coretemp_init)
@@ -769,7 +769,7 @@ static void __exit coretemp_exit(void) {cpuhp_remove_state (coretemp_hp_online);platform_driver_unregister (&coretemp_driver); -kfree (pkg_devices); +kfree (zone_devices); }module_exit (coretemp_exit)
Signature · 1 line
2.18.0-rc0
PATCH 13/19 perf/x86/intel/uncore: Support multi-die/package
In reply to Len BrownFrom: Kan Liang <[email protected]>
Uncore becomes die-scope on Xeon Cascade Lake-AP. Uncore driver needs to support die-scope uncore units.
Use topology_logical_die_id() to replace topology_logical_package_id(). For previous platforms which doesn't have multi-die, topology_logical_die_id() is identical as topology_logical_package_id().
In pci_probe/remove, the group id reads from PCI BUS is logical die id for multi-die systems.
Use topology_die_cpumask() to replace topology_core_cpumask(). For previous platforms which doesn't have multi-die, topology_die_cpumask() is identical as topology_core_cpumask().
There is no functional change for previous platforms.
--- arch/x86/events/intel/uncore.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
arch/x86/events/intel/uncore.c +11 -9
@@ -100,7 +100,7 @@ ssize_t uncore_event_show(struct kobject *kobj,struct intel_uncore_box *uncore_pmu_to_box (struct intel_uncore_pmu *pmu,int cpu) { -unsigned int pkgid =topology_logical_package_id (cpu); +unsigned int pkgid =topology_logical_die_id (cpu);/* * The unsigned check also catches the '-1' return value for non
@@ -942,7 +942,8 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *idif (phys_id <0 )return -ENODEV ; - pkg =topology_phys_to_logical_pkg (phys_id); + pkg = (topology_max_die_per_package () >1 ) ? phys_id : +topology_phys_to_logical_pkg (phys_id);if (pkg <0 )return -EINVAL ;
@@ -1033,7 +1034,8 @@ static void uncore_pci_remove(struct pci_dev *pdev) box =pci_get_drvdata (pdev);if (!box) { - pkg =topology_phys_to_logical_pkg (phys_id); + pkg = (topology_max_die_per_package () >1 ) ? phys_id : +topology_phys_to_logical_pkg (phys_id);for (i =0 ; i <UNCORE_EXTRA_PCI_DEV_MAX ; i++) {if (uncore_extra_pci_dev[pkg].dev[i] == pdev) { uncore_extra_pci_dev[pkg].dev[i] =NULL ;
@@ -1110,7 +1112,7 @@ static void uncore_change_type_ctx(struct intel_uncore_type *type, int old_cpu,struct intel_uncore_box *box;int i, pkg; - pkg =topology_logical_package_id (old_cpu <0 ? new_cpu : old_cpu); + pkg =topology_logical_die_id (old_cpu <0 ? new_cpu : old_cpu);for (i =0 ; i < type->num_boxes; i++, pmu++) { box = pmu->boxes[pkg];if (!box)
@@ -1151,7 +1153,7 @@ static int uncore_event_cpu_offline(unsigned int cpu)if (!cpumask_test_and_clear_cpu (cpu, &uncore_cpu_mask)) goto unref;/* Find a new cpu to collect uncore events */ - target =cpumask_any_but (topology_core_cpumask (cpu), cpu); + target =cpumask_any_but (topology_die_cpumask (cpu), cpu);/* Migrate uncore events to the new target */ if (target < nr_cpu_ids)
@@ -1164,7 +1166,7 @@ static int uncore_event_cpu_offline(unsigned int cpu) unref:/* Clear the references */ - pkg =topology_logical_package_id (cpu); + pkg =topology_logical_die_id (cpu);for (; *types; types++) { type = *types; pmu = type->pmus;
@@ -1223,7 +1225,7 @@ static int uncore_event_cpu_online(unsigned int cpu)struct intel_uncore_box *box;int i, ret, pkg, target; - pkg =topology_logical_package_id (cpu); + pkg =topology_logical_die_id (cpu); ret =allocate_boxes (types, pkg, cpu);if (ret)return ret;
@@ -1242,7 +1244,7 @@ static int uncore_event_cpu_online(unsigned int cpu)* Check if there is an online cpu in the package * which collects uncore events already. */ - target =cpumask_any_and (&uncore_cpu_mask,topology_core_cpumask (cpu)); + target =cpumask_any_and (&uncore_cpu_mask,topology_die_cpumask (cpu));if (target < nr_cpu_ids)return 0 ;
@@ -1417,7 +1419,7 @@ static int __init intel_uncore_init(void)if (boot_cpu_has (X86_FEATURE_HYPERVISOR ))return -ENODEV ; - max_packages =topology_max_packages (); + max_packages =topology_max_packages () *topology_max_die_per_package (); uncore_init = (struct intel_uncore_init_fun *)id->driver_data;if (uncore_init->pci_init) {
Signature · 1 line
2.18.0-rc0
PATCH 16/19 thermal/x86_pkg_temp_thermal: Cosmetic: Rename internal variables to zones from packages
In reply to Len BrownFrom: Len Brown <[email protected]>
Syntax update only -- no logical or functional change.
In response to the new multi-die/package changes, update variable names to use the more generic thermal "zone" terminology, instead of "package", as the zones can refer to either packages or die.
--- drivers/thermal/intel/x86_pkg_temp_thermal.c | 142 ++++++++++--------- 1 file changed, 72 insertions(+), 70 deletions(-)
drivers/thermal/intel/x86_pkg_temp_thermal.c +72 -70
@@ -55,7 +55,7 @@ MODULE_PARM_DESC(notify_delay_ms,*/ #define MAX_NUMBER_OF_TRIPS 2 -struct pkg_device { +struct zone_device {int cpu;bool work_scheduled;u32 tj_max;
@@ -70,10 +70,10 @@ static struct thermal_zone_params pkg_temp_tz_params = { .no_hwmon = true, }; -/* Keep track of how many package pointers we allocated in init() */ -static int max_packages__read_mostly ; -/* Array of package pointers */ -static struct pkg_device **packages; +/* Keep track of how many zone pointers we allocated in init() */ +static int max_id__read_mostly ; +/* Array of zone pointers */ +static struct zone_device **zones;/* Serializes interrupt notification, work and hotplug */ static DEFINE_SPINLOCK (pkg_temp_lock);/* Protects zone operation in the work function against hotplug removal */
@@ -120,12 +120,12 @@ static int pkg_temp_debugfs_init(void)* * - Other callsites: Must hold pkg_temp_lock */ -static struct pkg_device *pkg_temp_thermal_get_dev (unsigned int cpu) +static struct zone_device *pkg_temp_thermal_get_dev (unsigned int cpu) { -int pkgid =topology_logical_die_id (cpu); +int id =topology_logical_die_id (cpu); -if (pkgid >=0 && pkgid < max_packages) -return packages[pkgid]; +if (id >=0 && id < max_id) +return zones[id];return NULL ; }
@@ -150,12 +150,13 @@ static int get_tj_max(int cpu, u32 *tj_max)static int sys_get_curr_temp (struct thermal_zone_device *tzd,int *temp) { -struct pkg_device *pkgdev = tzd->devdata; +struct zone_device *zonedev = tzd->devdata;u32 eax, edx; -rdmsr_on_cpu (pkgdev->cpu,MSR_IA32_PACKAGE_THERM_STATUS , &eax, &edx); +rdmsr_on_cpu (zonedev->cpu,MSR_IA32_PACKAGE_THERM_STATUS , + &eax, &edx);if (eax &0x80000000 ) { - *temp = pkgdev->tj_max - ((eax >>16 ) &0x7f ) *1000 ; + *temp = zonedev->tj_max - ((eax >>16 ) &0x7f ) *1000 ;pr_debug ("sys_get_curr_temp %d\n" , *temp);return 0 ; }
@@ -165,7 +166,7 @@ static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp)static int sys_get_trip_temp (struct thermal_zone_device *tzd,int trip,int *temp) { -struct pkg_device *pkgdev = tzd->devdata; +struct zone_device *zonedev = tzd->devdata;unsigned long thres_reg_value;u32 mask, shift, eax, edx;int ret;
@@ -181,14 +182,14 @@ static int sys_get_trip_temp(struct thermal_zone_device *tzd, shift =THERM_SHIFT_THRESHOLD0 ; } - ret =rdmsr_on_cpu (pkgdev->cpu,MSR_IA32_PACKAGE_THERM_INTERRUPT , + ret =rdmsr_on_cpu (zonedev->cpu,MSR_IA32_PACKAGE_THERM_INTERRUPT , &eax, &edx);if (ret <0 )return ret; thres_reg_value = (eax & mask) >> shift;if (thres_reg_value) - *temp = pkgdev->tj_max - thres_reg_value *1000 ; + *temp = zonedev->tj_max - thres_reg_value *1000 ;else *temp =0 ;pr_debug ("sys_get_trip_temp %d\n" , *temp);
@@ -199,14 +200,14 @@ static int sys_get_trip_temp(struct thermal_zone_device *tzd,static int sys_set_trip_temp (struct thermal_zone_device *tzd,int trip,int temp) { -struct pkg_device *pkgdev = tzd->devdata; +struct zone_device *zonedev = tzd->devdata;u32 l, h, mask, shift, intr;int ret; -if (trip >=MAX_NUMBER_OF_TRIPS || temp >= pkgdev->tj_max) +if (trip >=MAX_NUMBER_OF_TRIPS || temp >= zonedev->tj_max)return -EINVAL ; - ret =rdmsr_on_cpu (pkgdev->cpu,MSR_IA32_PACKAGE_THERM_INTERRUPT , + ret =rdmsr_on_cpu (zonedev->cpu,MSR_IA32_PACKAGE_THERM_INTERRUPT , &l, &h);if (ret <0 )return ret;
@@ -228,11 +229,12 @@ sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp)if (!temp) { l &= ~intr; }else { - l |= (pkgdev->tj_max - temp)/1000 << shift; + l |= (zonedev->tj_max - temp)/1000 << shift; l |= intr; } -return wrmsr_on_cpu (pkgdev->cpu,MSR_IA32_PACKAGE_THERM_INTERRUPT , l, h); +return wrmsr_on_cpu (zonedev->cpu,MSR_IA32_PACKAGE_THERM_INTERRUPT , + l, h); } static int sys_get_trip_type(struct thermal_zone_device *thermal, int trip,
@@ -287,26 +289,26 @@ static void pkg_temp_thermal_threshold_work_fn(struct work_struct *work) {struct thermal_zone_device *tzone =NULL ;int cpu =smp_processor_id (); -struct pkg_device *pkgdev; +struct zone_device *zonedev;u64 msr_val, wr_val;mutex_lock (&thermal_zone_mutex);spin_lock_irq (&pkg_temp_lock); ++pkg_work_cnt; - pkgdev =pkg_temp_thermal_get_dev (cpu); -if (!pkgdev) { + zonedev =pkg_temp_thermal_get_dev (cpu); +if (!zonedev) {spin_unlock_irq (&pkg_temp_lock);mutex_unlock (&thermal_zone_mutex);return ; } - pkgdev->work_scheduled = false; + zonedev->work_scheduled = false;rdmsrl (MSR_IA32_PACKAGE_THERM_STATUS , msr_val); wr_val = msr_val & ~(THERM_LOG_THRESHOLD0 |THERM_LOG_THRESHOLD1 );if (wr_val != msr_val) {wrmsrl (MSR_IA32_PACKAGE_THERM_STATUS , wr_val); - tzone = pkgdev->tzone; + tzone = zonedev->tzone; }enable_pkg_thres_interrupt ();
@@ -332,7 +334,7 @@ static void pkg_thermal_schedule_work(int cpu, struct delayed_work *work)static int pkg_thermal_notify (u64 msr_val) {int cpu =smp_processor_id (); -struct pkg_device *pkgdev; +struct zone_device *zonedev;unsigned long flags;spin_lock_irqsave (&pkg_temp_lock, flags);
@@ -341,10 +343,10 @@ static int pkg_thermal_notify(u64 msr_val)disable_pkg_thres_interrupt ();/* Work is per package, so scheduling it once is enough. */ - pkgdev =pkg_temp_thermal_get_dev (cpu); -if (pkgdev && !pkgdev->work_scheduled) { - pkgdev->work_scheduled = true; -pkg_thermal_schedule_work (pkgdev->cpu, &pkgdev->work); + zonedev =pkg_temp_thermal_get_dev (cpu); +if (zonedev && !zonedev->work_scheduled) { + zonedev->work_scheduled = true; +pkg_thermal_schedule_work (zonedev->cpu, &zonedev->work); }spin_unlock_irqrestore (&pkg_temp_lock, flags);
@@ -353,12 +355,12 @@ static int pkg_thermal_notify(u64 msr_val)static int pkg_temp_thermal_device_add (unsigned int cpu) { -int pkgid =topology_logical_die_id (cpu); +int id =topology_logical_die_id (cpu);u32 tj_max, eax, ebx, ecx, edx; -struct pkg_device *pkgdev; +struct zone_device *zonedev;int thres_count, err; -if (pkgid >= max_packages) +if (id >= max_id)return -ENOMEM ;cpuid (6 , &eax, &ebx, &ecx, &edx);
@@ -372,51 +374,51 @@ static int pkg_temp_thermal_device_add(unsigned int cpu)if (err)return err; - pkgdev =kzalloc (sizeof (*pkgdev),GFP_KERNEL ); -if (!pkgdev) + zonedev =kzalloc (sizeof (*zonedev),GFP_KERNEL ); +if (!zonedev)return -ENOMEM ; -INIT_DELAYED_WORK (&pkgdev->work, pkg_temp_thermal_threshold_work_fn); - pkgdev->cpu = cpu; - pkgdev->tj_max = tj_max; - pkgdev->tzone =thermal_zone_device_register ("x86_pkg_temp" , +INIT_DELAYED_WORK (&zonedev->work, pkg_temp_thermal_threshold_work_fn); + zonedev->cpu = cpu; + zonedev->tj_max = tj_max; + zonedev->tzone =thermal_zone_device_register ("x86_pkg_temp" , thres_count, (thres_count ==MAX_NUMBER_OF_TRIPS ) ?0x03 :0x01 , - pkgdev, &tzone_ops, &pkg_temp_tz_params,0 ,0 ); -if (IS_ERR (pkgdev->tzone)) { - err =PTR_ERR (pkgdev->tzone); -kfree (pkgdev); + zonedev, &tzone_ops, &pkg_temp_tz_params,0 ,0 ); +if (IS_ERR (zonedev->tzone)) { + err =PTR_ERR (zonedev->tzone); +kfree (zonedev);return err; }/* Store MSR value for package thermal interrupt, to restore at exit */ -rdmsr (MSR_IA32_PACKAGE_THERM_INTERRUPT , pkgdev->msr_pkg_therm_low, - pkgdev->msr_pkg_therm_high); +rdmsr (MSR_IA32_PACKAGE_THERM_INTERRUPT , zonedev->msr_pkg_therm_low, + zonedev->msr_pkg_therm_high); -cpumask_set_cpu (cpu, &pkgdev->cpumask); +cpumask_set_cpu (cpu, &zonedev->cpumask);spin_lock_irq (&pkg_temp_lock); - packages[pkgid] = pkgdev; + zones[id] = zonedev;spin_unlock_irq (&pkg_temp_lock);return 0 ; }static int pkg_thermal_cpu_offline (unsigned int cpu) { -struct pkg_device *pkgdev =pkg_temp_thermal_get_dev (cpu); +struct zone_device *zonedev =pkg_temp_thermal_get_dev (cpu);bool lastcpu, was_target;int target; -if (!pkgdev) +if (!zonedev)return 0 ; - target =cpumask_any_but (&pkgdev->cpumask, cpu); -cpumask_clear_cpu (cpu, &pkgdev->cpumask); + target =cpumask_any_but (&zonedev->cpumask, cpu); +cpumask_clear_cpu (cpu, &zonedev->cpumask); lastcpu = target >= nr_cpu_ids;/* * Remove the sysfs files, if this is the last cpu in the package * before doing further cleanups. */ if (lastcpu) { -struct thermal_zone_device *tzone = pkgdev->tzone; +struct thermal_zone_device *tzone = zonedev->tzone;/* * We must protect against a work function calling
@@ -425,7 +427,7 @@ static int pkg_thermal_cpu_offline(unsigned int cpu)* won't try to call. */ mutex_lock (&thermal_zone_mutex); - pkgdev->tzone =NULL ; + zonedev->tzone =NULL ;mutex_unlock (&thermal_zone_mutex);thermal_zone_device_unregister (tzone);
@@ -439,8 +441,8 @@ static int pkg_thermal_cpu_offline(unsigned int cpu)* one. When we drop the lock, then the interrupt notify function * will see the new target. */ - was_target = pkgdev->cpu == cpu; - pkgdev->cpu = target; + was_target = zonedev->cpu == cpu; + zonedev->cpu = target;/* * If this is the last CPU in the package remove the package
@@ -449,23 +451,23 @@ static int pkg_thermal_cpu_offline(unsigned int cpu)* worker will see the package anymore. */ if (lastcpu) { - packages[topology_logical_die_id (cpu)] =NULL ; + zones[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); + zonedev->msr_pkg_therm_low, zonedev->msr_pkg_therm_high); }/* * Check whether there is work scheduled and whether the work is * targeted at the outgoing CPU. */ -if (pkgdev->work_scheduled && was_target) { +if (zonedev->work_scheduled && was_target) {/* * To cancel the work we need to drop the lock, otherwise * we might deadlock if the work needs to be flushed. */ spin_unlock_irq (&pkg_temp_lock); -cancel_delayed_work_sync (&pkgdev->work); +cancel_delayed_work_sync (&zonedev->work);spin_lock_irq (&pkg_temp_lock);/* * If this is not the last cpu in the package and the work
@@ -473,21 +475,21 @@ static int pkg_thermal_cpu_offline(unsigned int cpu)* need to reschedule the work, otherwise the interrupt * stays disabled forever. */ -if (!lastcpu && pkgdev->work_scheduled) -pkg_thermal_schedule_work (target, &pkgdev->work); +if (!lastcpu && zonedev->work_scheduled) +pkg_thermal_schedule_work (target, &zonedev->work); }spin_unlock_irq (&pkg_temp_lock);/* Final cleanup if this is the last cpu */ if (lastcpu) -kfree (pkgdev); +kfree (zonedev);return 0 ; }static int pkg_thermal_cpu_online (unsigned int cpu) { -struct pkg_device *pkgdev =pkg_temp_thermal_get_dev (cpu); +struct zone_device *zonedev =pkg_temp_thermal_get_dev (cpu);struct cpuinfo_x86 *c = &cpu_data (cpu);/* Paranoia check */
@@ -495,8 +497,8 @@ static int pkg_thermal_cpu_online(unsigned int cpu)return -ENODEV ;/* If the package exists, nothing to do */ -if (pkgdev) { -cpumask_set_cpu (cpu, &pkgdev->cpumask); +if (zonedev) { +cpumask_set_cpu (cpu, &zonedev->cpumask);return 0 ; }return pkg_temp_thermal_device_add (cpu);
@@ -515,10 +517,10 @@ static int __init pkg_temp_thermal_init(void)if (!x86_match_cpu (pkg_temp_thermal_ids))return -ENODEV ; - max_packages =topology_max_packages () *topology_max_die_per_package (); - packages =kcalloc (max_packages,sizeof (struct pkg_device *), + max_id =topology_max_packages () *topology_max_die_per_package (); + zones =kcalloc (max_id,sizeof (struct zone_device *),GFP_KERNEL ); -if (!packages) +if (!zones)return -ENOMEM ; ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "thermal/x86_pkg:online",
@@ -537,7 +539,7 @@ static int __init pkg_temp_thermal_init(void)return 0 ; err: -kfree (packages); +kfree (zones);return ret; }module_init (pkg_temp_thermal_init)
@@ -549,7 +551,7 @@ static void __exit pkg_temp_thermal_exit(void)cpuhp_remove_state (pkg_thermal_hp_state);debugfs_remove_recursive (debugfs); -kfree (packages); +kfree (zones); }module_exit (pkg_temp_thermal_exit)
Signature · 1 line
2.18.0-rc0
PATCH 12/19 topology: Create core_cpus and die_cpus sysfs attributes
In reply to Len BrownFrom: Len Brown <[email protected]>
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.
--- Documentation/cputopology.txt | 21 +++++++++++++++------ 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(+), 6 deletions(-)
Documentation/cputopology.txt +15 -6
@@ -36,15 +36,15 @@ drawer_id: identifier (rather than the kernel's). The actual value is architecture and platform dependent. -thread_siblings: +core_cpus: - internal kernel map of cpuX's hardware threads within the same - core as cpuX. + internal kernel map of CPUs within the same core. + (deprecated name: "thread_siblings") -thread_siblings_list: +core_cpus_list: - human-readable list of cpuX's hardware threads within the same - core as cpuX. + human-readable list of CPUs within the same core. + (deprecated name: "thread_siblings_list"); package_cpus:
@@ -56,6 +56,14 @@ package_cpus_list: human-readable list of CPUs sharing the same physical_package_id. (deprecated name: "core_siblings_list") +die_cpus: + + internal kernel map of CPUs within the same die. + +die_cpus_list: + + human-readable list of CPUs within the same die. + book_siblings: internal kernel map of cpuX's hardware threads within the same
@@ -93,6 +101,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
@@ -91,6 +91,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 */
@@ -509,6 +513,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 ) {
@@ -571,6 +584,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 ; }
@@ -619,6 +633,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));
@@ -1223,6 +1240,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 )); }/*
@@ -1318,6 +1336,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 ); }
@@ -1538,6 +1557,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))
@@ -1545,6 +1566,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_cpus, sibling_cpumask); +static DEVICE_ATTR_RO (core_cpus); +static DEVICE_ATTR_RO (core_cpus_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_cpus, die_cpumask); +static DEVICE_ATTR_RO (die_cpus); +static DEVICE_ATTR_RO (die_cpus_list); +define_siblings_show_func (package_cpus, core_cpumask);static DEVICE_ATTR_RO (package_cpus);static DEVICE_ATTR_RO (package_cpus_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_cpus.attr, + &dev_attr_core_cpus_list.attr, &dev_attr_core_siblings.attr, &dev_attr_core_siblings_list.attr, + &dev_attr_die_cpus.attr, + &dev_attr_die_cpus_list.attr, &dev_attr_package_cpus.attr, &dev_attr_package_cpus_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 11/19 topology: Create package_cpus sysfs attribute
In reply to Len BrownFrom: Len Brown <[email protected]>
The existing sysfs cpu/topology/core_siblings (and core_siblings_list) attributes are documented, implemented, and used by programs to represent set of logical CPUs 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 and its definition become inconsistent.
So without changing its function, add a name for this map that describes what it actually is -- package CPUs -- the set of CPUs 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 | 12 ++++++------ drivers/base/topology.c | 6 ++++++ 2 files changed, 12 insertions(+), 6 deletions(-)
Documentation/cputopology.txt +6 -6
@@ -46,15 +46,15 @@ thread_siblings_list: human-readable list of cpuX's hardware threads within the same core as cpuX. -core_siblings: +package_cpus: - internal kernel map of cpuX's hardware threads within the same - physical_package_id. + internal kernel map of the CPUs sharing the same physical_package_id. + (deprecated name: "core_siblings") -core_siblings_list: +package_cpus_list: - human-readable list of cpuX's hardware threads within the same - physical_package_id. + human-readable list of CPUs sharing the same 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_cpus, core_cpumask); +static DEVICE_ATTR_RO (package_cpus); +static DEVICE_ATTR_RO (package_cpus_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_cpus.attr, + &dev_attr_package_cpus_list.attr, #ifdef CONFIG_SCHED_BOOK &dev_attr_book_id.attr, &dev_attr_book_siblings.attr,
Signature · 1 line
2.18.0-rc0
PATCH 5/19 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 | 5 ++++ arch/x86/kernel/cpu/common.c | 1 + arch/x86/kernel/smpboot.c | 45 ++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+)
arch/x86/include/asm/processor.h +1 -0
@@ -118,6 +118,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 +5 -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)
@@ -131,13 +132,17 @@ 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 ; }
arch/x86/kernel/cpu/common.c +1 -0
@@ -1277,6 +1277,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 8/19 thermal/x86_pkg_temp_thermal: Support multi-die/package
In reply to Len BrownFrom: Zhang Rui <[email protected]>
Package temperature sensors are actually implemented in hardware per-die. Thus, the new multi-die/package systems sport mulitple package thermal zones for each package.
Update the x86_pkg_temp_thermal to be "multi-die-aware", so it can expose multiple zones per package, instead of just one.
--- drivers/thermal/intel/x86_pkg_temp_thermal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/thermal/intel/x86_pkg_temp_thermal.c +4 -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);
@@ -515,7 +515,7 @@ static int __init pkg_temp_thermal_init(void)if (!x86_match_cpu (pkg_temp_thermal_ids))return -ENODEV ; - max_packages =topology_max_packages (); + max_packages =topology_max_packages () *topology_max_die_per_package (); packages =kcalloc (max_packages,sizeof (struct pkg_device *),GFP_KERNEL );if (!packages)
Signature · 1 line
2.18.0-rc0
PATCH 1/19 x86 topology: Add CPUID.1F multi-die/package support
In reply to Len BrownFrom: 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.rst | 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.rst +4 -0
@@ -49,6 +49,10 @@ Package-related topology information in the kernel: 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
@@ -389,6 +389,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" );
@@ -400,6 +401,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 2/19 x86 topology: Create topology_max_die_per_package()
From: Len Brown <[email protected]>
topology_max_packages() is available to size resources to cover all packages in the system.
But now we have multi-die/package systems, and some resources are per-die.
Create topology_max_die_per_package(), for detecting multi-die/package systems, and sizing any per-die resources.
--- arch/x86/include/asm/processor.h | 1 - arch/x86/include/asm/topology.h | 10 ++++++++++ arch/x86/kernel/cpu/topology.c | 5 ++++- 3 files changed, 14 insertions(+), 2 deletions(-)
arch/x86/include/asm/processor.h +0 -1
@@ -106,7 +106,6 @@ struct cpuinfo_x86 {unsigned long loops_per_jiffy;/* cpuid returned max cores value: */ u16 x86_max_cores; -u16 x86_max_dies;u16 apicid;u16 initial_apicid;u16 x86_clflush_size;
arch/x86/include/asm/topology.h +10 -0
@@ -115,6 +115,13 @@ extern const struct cpumask *cpu_coregroup_mask(int cpu);extern unsigned int __max_logical_packages;#define topology_max_packages () (__max_logical_packages) +extern unsigned int __max_die_per_package; + +static inline int topology_max_die_per_package (void ) +{ +return __max_die_per_package; +} +extern int __max_smt_threads;static inline int topology_max_smt_threads (void )
@@ -131,6 +138,9 @@ bool topology_smt_supported(void);static inline int topology_update_package_map (unsigned int apicid,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_die_per_package (void ) {return 1 ; }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/topology.c +4 -1
@@ -26,6 +26,9 @@#define LEVEL_MAX_SIBLINGS (ebx) ((ebx) & 0xffff)#ifdef CONFIG_SMP +unsigned int __max_die_per_package__read_mostly =1 ; +EXPORT_SYMBOL (__max_die_per_package); +/* * Check if given CPUID extended toplogy "leaf" is implemented */
@@ -146,7 +149,7 @@ int detect_extended_topology(struct cpuinfo_x86 *c) c->apicid = apic->phys_pkg_id (c->initial_apicid,0 ); c->x86_max_cores = (core_level_siblings / smp_num_siblings); - c->x86_max_dies = (die_level_siblings / core_level_siblings); + __max_die_per_package = (die_level_siblings / core_level_siblings);#endif return 0 ; }
Signature · 1 line
2.18.0-rc0
Quoted 12 lines · Len Brown
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
Quoted 7 lines
These changes should have no 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.
I still think having a 'rapl package' be a 'die' is weird, but if that's the way it is specified in the SDM then so be it.
Quoted 21 lines · Peter Zijlstra
Quoted 12 lines · Len Brown
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
Quoted 7 lines
These changes should have no 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.
Quoted 4 lines
I still think having a 'rapl package' be a 'die' is weird, but if that's the way it is specified in the SDM then so be it.
Thanks Peter, I'll queue it up in the next couple of days, for a tentative v5.3 merge.
Thanks,
Ingo
Quoted 7 lines · Len Brown
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
Quoted 7 lines
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 no impact on cache topology, NUMA topology, Linux scheduler, or system performance.
Thank you Len:
Ingo
tip-bot for Len Brown
merge bot[tip:x86/topology] x86/topology: Add CPUID.1F multi-die/package support
In reply to Len Brownx86/topology: Add CPUID.1F multi-die/package support
Commit-ID: 7745f03eb39587dd15a1fb26e6223678b8e906d2 Gitweb: https://git.kernel.org/tip/7745f03eb39587dd15a1fb26e6223678b8e906d2 Author: Len Brown <[email protected]> AuthorDate: Mon, 13 May 2019 13:58:45 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 23 May 2019 10:08:30 +0200
x86/topology: Add CPUID.1F multi-die/package support
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.rst | 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.rst +4 -0
@@ -49,6 +49,10 @@ Package-related topology information in the kernel: 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
@@ -389,6 +389,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" );
@@ -400,6 +401,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" ); }
tip-bot for Len Brown
merge bot[tip:x86/topology] x86/topology: Create topology_max_die_per_package()
In reply to Len Brownx86/topology: Create topology_max_die_per_package()
Commit-ID: 14d96d6c06b5d8116b8d52c9c5530f5528ef1e61 Gitweb: https://git.kernel.org/tip/14d96d6c06b5d8116b8d52c9c5530f5528ef1e61 Author: Len Brown <[email protected]> AuthorDate: Mon, 13 May 2019 13:58:46 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 23 May 2019 10:08:30 +0200
x86/topology: Create topology_max_die_per_package()
topology_max_packages() is available to size resources to cover all packages in the system.
But now multi-die/package systems are coming up, and some resources are per-die.
Create topology_max_die_per_package(), for detecting multi-die/package systems, and sizing any per-die resources.
--- arch/x86/include/asm/processor.h | 1 - arch/x86/include/asm/topology.h | 10 ++++++++++ arch/x86/kernel/cpu/topology.c | 5 ++++- 3 files changed, 14 insertions(+), 2 deletions(-)
arch/x86/include/asm/processor.h +0 -1
@@ -106,7 +106,6 @@ struct cpuinfo_x86 {unsigned long loops_per_jiffy;/* cpuid returned max cores value: */ u16 x86_max_cores; -u16 x86_max_dies;u16 apicid;u16 initial_apicid;u16 x86_clflush_size;
arch/x86/include/asm/topology.h +10 -0
@@ -115,6 +115,13 @@ extern const struct cpumask *cpu_coregroup_mask(int cpu);extern unsigned int __max_logical_packages;#define topology_max_packages () (__max_logical_packages) +extern unsigned int __max_die_per_package; + +static inline int topology_max_die_per_package (void ) +{ +return __max_die_per_package; +} +extern int __max_smt_threads;static inline int topology_max_smt_threads (void )
@@ -131,6 +138,9 @@ bool topology_smt_supported(void);static inline int topology_update_package_map (unsigned int apicid,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_die_per_package (void ) {return 1 ; }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/topology.c +4 -1
@@ -26,6 +26,9 @@#define LEVEL_MAX_SIBLINGS (ebx) ((ebx) & 0xffff)#ifdef CONFIG_SMP +unsigned int __max_die_per_package__read_mostly =1 ; +EXPORT_SYMBOL (__max_die_per_package); +/* * Check if given CPUID extended toplogy "leaf" is implemented */
@@ -146,7 +149,7 @@ int detect_extended_topology(struct cpuinfo_x86 *c) c->apicid = apic->phys_pkg_id (c->initial_apicid,0 ); c->x86_max_cores = (core_level_siblings / smp_num_siblings); - c->x86_max_dies = (die_level_siblings / core_level_siblings); + __max_die_per_package = (die_level_siblings / core_level_siblings);#endif return 0 ; }
tip-bot for Len Brown
merge bot[tip:x86/topology] cpu/topology: Export die_id
In reply to Len Browncpu/topology: Export die_id
Commit-ID: 0e344d8c709fe01d882fc0fb5452bedfe5eba67a Gitweb: https://git.kernel.org/tip/0e344d8c709fe01d882fc0fb5452bedfe5eba67a Author: Len Brown <[email protected]> AuthorDate: Mon, 13 May 2019 13:58:47 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 23 May 2019 10:08:31 +0200
cpu/topology: Export die_id
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
tip-bot for Len Brown
merge bot[tip:x86/topology] x86/topology: Define topology_die_id()
In reply to Len Brownx86/topology: Define topology_die_id()
Commit-ID: 306a0de329f77537f29022c2982006f9145d782d Gitweb: https://git.kernel.org/tip/306a0de329f77537f29022c2982006f9145d782d Author: Len Brown <[email protected]> AuthorDate: Mon, 13 May 2019 13:58:48 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 23 May 2019 10:08:31 +0200
x86/topology: Define topology_die_id()
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
tip-bot for Len Brown
merge bot[tip:x86/topology] x86/topology: Define topology_logical_die_id()
In reply to Len Brownx86/topology: Define topology_logical_die_id()
Commit-ID: 212bf4fdb7f9eeeb99afd97ebad677d43e7b55ac Gitweb: https://git.kernel.org/tip/212bf4fdb7f9eeeb99afd97ebad677d43e7b55ac Author: Len Brown <[email protected]> AuthorDate: Mon, 13 May 2019 13:58:49 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 23 May 2019 10:08:32 +0200
x86/topology: Define topology_logical_die_id()
Define topology_logical_die_id() ala existing topology_logical_package_id()
--- arch/x86/include/asm/processor.h | 1 + arch/x86/include/asm/topology.h | 5 +++++ arch/x86/kernel/cpu/common.c | 1 + arch/x86/kernel/smpboot.c | 45 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+)
arch/x86/include/asm/processor.h +1 -0
@@ -118,6 +118,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 +5 -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)
@@ -131,13 +132,17 @@ 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 ; }
arch/x86/kernel/cpu/common.c +1 -0
@@ -1298,6 +1298,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
tip-bot for Zhang Rui
merge bot[tip:x86/topology] powercap/intel_rapl: Simplify rapl_find_package()
In reply to Len Brownpowercap/intel_rapl: Simplify rapl_find_package()
Commit-ID: aadf7b38337108627b014fb285147aacdfafe42e Gitweb: https://git.kernel.org/tip/aadf7b38337108627b014fb285147aacdfafe42e Author: Zhang Rui <[email protected]> AuthorDate: Mon, 13 May 2019 13:58:50 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 23 May 2019 10:08:32 +0200
powercap/intel_rapl: Simplify rapl_find_package()
Simplify how the code to discover a package is called. Rename find_package_by_id() to rapl_find_package_domain()
Syntax only, no functional or semantic change.
--- 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) {
@@ -1300,7 +1301,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,
@@ -1456,8 +1457,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;
@@ -1466,7 +1468,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 */
@@ -1497,12 +1499,11 @@ err_free_package:*/ 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); }
@@ -1512,11 +1513,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 ;
tip-bot for Zhang Rui
merge bot[tip:x86/topology] powercap/intel_rapl: Support multi-die/package
In reply to Len Brownpowercap/intel_rapl: Support multi-die/package
Commit-ID: 32fb480e0a2cf1f71e4174d6477198c94dbc746c Gitweb: https://git.kernel.org/tip/32fb480e0a2cf1f71e4174d6477198c94dbc746c Author: Zhang Rui <[email protected]> AuthorDate: Mon, 13 May 2019 13:58:51 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 23 May 2019 10:08:32 +0200
powercap/intel_rapl: Support multi-die/package
RAPL "package" domains are actually implemented in hardware per-die. Thus, the new multi-die/package systems have mulitple domains within each physical package.
Update the intel_rapl driver to be "die aware" -- exporting multiple domains within a single package, when present. No change on single die/package systems.
--- 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) {
@@ -1459,7 +1459,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;
tip-bot for Zhang Rui
merge bot[tip:x86/topology] thermal/x86_pkg_temp_thermal: Support multi-die/package
In reply to Len Brownthermal/x86_pkg_temp_thermal: Support multi-die/package
Commit-ID: 724adec33c2491f26f739f285ddca25fca226e48 Gitweb: https://git.kernel.org/tip/724adec33c2491f26f739f285ddca25fca226e48 Author: Zhang Rui <[email protected]> AuthorDate: Mon, 13 May 2019 13:58:52 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 23 May 2019 10:08:33 +0200
thermal/x86_pkg_temp_thermal: Support multi-die/package
Package temperature sensors are actually implemented in hardware per-die. Thus, the new multi-die/package systems sport mulitple package thermal zones for each package.
Update the x86_pkg_temp_thermal to be "multi-die-aware", so it can expose multiple zones per package, instead of just one.
--- drivers/thermal/intel/x86_pkg_temp_thermal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/thermal/intel/x86_pkg_temp_thermal.c +4 -4
@@ -122,7 +122,7 @@ err_out:*/ 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);
@@ -515,7 +515,7 @@ static int __init pkg_temp_thermal_init(void)if (!x86_match_cpu (pkg_temp_thermal_ids))return -ENODEV ; - max_packages =topology_max_packages (); + max_packages =topology_max_packages () *topology_max_die_per_package (); packages =kcalloc (max_packages,sizeof (struct pkg_device *),GFP_KERNEL );if (!packages)
tip-bot for Zhang Rui
merge bot[tip:x86/topology] powercap/intel_rapl: Update RAPL domain name and debug messages
In reply to Len Brownpowercap/intel_rapl: Update RAPL domain name and debug messages
Commit-ID: 9ea7612c46586d9eacfd517e73ff76ef294feca0 Gitweb: https://git.kernel.org/tip/9ea7612c46586d9eacfd517e73ff76ef294feca0 Author: Zhang Rui <[email protected]> AuthorDate: Mon, 13 May 2019 13:58:53 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 23 May 2019 10:08:33 +0200
powercap/intel_rapl: Update RAPL domain name and debug messages
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/package.
Update driver debug messages.
--- 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 ; }
@@ -1181,7 +1185,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++) {
@@ -1206,7 +1210,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;
@@ -1217,20 +1220,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 */
@@ -1256,8 +1255,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; }
@@ -1270,7 +1269,7 @@ err_cleanup:* 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); }
@@ -1380,8 +1379,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 ; } }
@@ -1410,10 +1409,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 );
@@ -1446,8 +1445,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 */
@@ -1461,6 +1460,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 );
@@ -1471,6 +1471,13 @@ static struct rapl_package *rapl_add_package(int cpu) rp->id = id; rp->lead_cpu = cpu; +if (topology_max_die_per_package () >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)) {
tip-bot for Zhang Rui
merge bot[tip:x86/topology] hwmon/coretemp: Support multi-die/package
In reply to Len Brownhwmon/coretemp: Support multi-die/package
Commit-ID: cfcd82e632882372db960b50782a439a8ba56c09 Gitweb: https://git.kernel.org/tip/cfcd82e632882372db960b50782a439a8ba56c09 Author: Zhang Rui <[email protected]> AuthorDate: Mon, 13 May 2019 13:58:54 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 23 May 2019 10:08:33 +0200
hwmon/coretemp: Support multi-die/package
Package temperature sensors are actually implemented in hardware per-die.
Update coretemp to be "die-aware", so it can expose mulitple sensors per package, instead of just one. No change to single-die/package systems.
--- drivers/hwmon/coretemp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/coretemp.c +4 -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 ; }
@@ -741,7 +741,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 () *topology_max_die_per_package (); pkg_devices =kcalloc (max_packages,sizeof (struct platform_device *),GFP_KERNEL );if (!pkg_devices)
tip-bot for Len Brown
merge bot[tip:x86/topology] topology: Create package_cpus sysfs attribute
In reply to Len Browntopology: Create package_cpus sysfs attribute
Commit-ID: b73ed8dc0597c11ec5064d06b9bbd4e541b6d4e7 Gitweb: https://git.kernel.org/tip/b73ed8dc0597c11ec5064d06b9bbd4e541b6d4e7 Author: Len Brown <[email protected]> AuthorDate: Mon, 13 May 2019 13:58:55 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 23 May 2019 10:08:34 +0200
topology: Create package_cpus sysfs attribute
The existing sysfs cpu/topology/core_siblings (and core_siblings_list) attributes are documented, implemented, and used by programs to represent set of logical CPUs 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 and its definition become inconsistent.
So without changing its function, add a name for this map that describes what it actually is -- package CPUs -- the set of CPUs 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 | 12 ++++++------ drivers/base/topology.c | 6 ++++++ 2 files changed, 12 insertions(+), 6 deletions(-)
Documentation/cputopology.txt +6 -6
@@ -46,15 +46,15 @@ thread_siblings_list: human-readable list of cpuX's hardware threads within the same core as cpuX. -core_siblings: +package_cpus: - internal kernel map of cpuX's hardware threads within the same - physical_package_id. + internal kernel map of the CPUs sharing the same physical_package_id. + (deprecated name: "core_siblings") -core_siblings_list: +package_cpus_list: - human-readable list of cpuX's hardware threads within the same - physical_package_id. + human-readable list of CPUs sharing the same 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_cpus, core_cpumask); +static DEVICE_ATTR_RO (package_cpus); +static DEVICE_ATTR_RO (package_cpus_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_cpus.attr, + &dev_attr_package_cpus_list.attr, #ifdef CONFIG_SCHED_BOOK &dev_attr_book_id.attr, &dev_attr_book_siblings.attr,
tip-bot for Len Brown
merge bot[tip:x86/topology] topology: Create core_cpus and die_cpus sysfs attributes
In reply to Len Browntopology: Create core_cpus and die_cpus sysfs attributes
Commit-ID: 2e4c54dac7b360c3820399bdf06cde9134a4495b Gitweb: https://git.kernel.org/tip/2e4c54dac7b360c3820399bdf06cde9134a4495b Author: Len Brown <[email protected]> AuthorDate: Mon, 13 May 2019 13:58:56 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 23 May 2019 10:08:34 +0200
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.
--- Documentation/cputopology.txt | 21 +++++++++++++++------ 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(+), 6 deletions(-)
Documentation/cputopology.txt +15 -6
@@ -36,15 +36,15 @@ drawer_id: identifier (rather than the kernel's). The actual value is architecture and platform dependent. -thread_siblings: +core_cpus: - internal kernel map of cpuX's hardware threads within the same - core as cpuX. + internal kernel map of CPUs within the same core. + (deprecated name: "thread_siblings") -thread_siblings_list: +core_cpus_list: - human-readable list of cpuX's hardware threads within the same - core as cpuX. + human-readable list of CPUs within the same core. + (deprecated name: "thread_siblings_list"); package_cpus:
@@ -56,6 +56,14 @@ package_cpus_list: human-readable list of CPUs sharing the same physical_package_id. (deprecated name: "core_siblings_list") +die_cpus: + + internal kernel map of CPUs within the same die. + +die_cpus_list: + + human-readable list of CPUs within the same die. + book_siblings: internal kernel map of cpuX's hardware threads within the same
@@ -93,6 +101,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
@@ -91,6 +91,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 */
@@ -509,6 +513,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 ) {
@@ -571,6 +584,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 ; }
@@ -619,6 +633,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));
@@ -1223,6 +1240,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 )); }/*
@@ -1318,6 +1336,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 ); }
@@ -1538,6 +1557,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))
@@ -1545,6 +1566,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_cpus, sibling_cpumask); +static DEVICE_ATTR_RO (core_cpus); +static DEVICE_ATTR_RO (core_cpus_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_cpus, die_cpumask); +static DEVICE_ATTR_RO (die_cpus); +static DEVICE_ATTR_RO (die_cpus_list); +define_siblings_show_func (package_cpus, core_cpumask);static DEVICE_ATTR_RO (package_cpus);static DEVICE_ATTR_RO (package_cpus_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_cpus.attr, + &dev_attr_core_cpus_list.attr, &dev_attr_core_siblings.attr, &dev_attr_core_siblings_list.attr, + &dev_attr_die_cpus.attr, + &dev_attr_die_cpus_list.attr, &dev_attr_package_cpus.attr, &dev_attr_package_cpus_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)
tip-bot for Kan Liang
merge bot[tip:x86/topology] perf/x86/intel/rapl: Support multi-die/package
In reply to Len Brownperf/x86/intel/rapl: Support multi-die/package
Commit-ID: b10b3efb88e7bba12f09f71740bab9b7225631c9 Gitweb: https://git.kernel.org/tip/b10b3efb88e7bba12f09f71740bab9b7225631c9 Author: Kan Liang <[email protected]> AuthorDate: Mon, 13 May 2019 13:58:58 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 23 May 2019 10:08:35 +0200
perf/x86/intel/rapl: Support multi-die/package
RAPL becomes die-scope on Xeon Cascade Lake-AP. Perf RAPL driver needs to support die-scope RAPL domain.
Use topology_logical_die_id() to replace topology_logical_package_id(). For previous platforms which doesn't have multi-die, topology_logical_die_id() is identical as topology_logical_package_id().
Use topology_die_cpumask() to replace topology_core_cpumask(). For previous platforms which doesn't have multi-die, topology_die_cpumask() is identical as topology_core_cpumask().
There is no functional change for previous platforms.
--- arch/x86/events/intel/rapl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/x86/events/intel/rapl.c +5 -5
@@ -161,7 +161,7 @@ static u64 rapl_timer_ms;static inline struct rapl_pmu *cpu_to_rapl_pmu (unsigned int cpu) { -unsigned int pkgid =topology_logical_package_id (cpu); +unsigned int pkgid =topology_logical_die_id (cpu);/* * The unsigned check also catches the '-1' return value for non
@@ -571,7 +571,7 @@ static int rapl_cpu_offline(unsigned int cpu) pmu->cpu =-1 ;/* Find a new cpu to collect rapl events */ - target =cpumask_any_but (topology_core_cpumask (cpu), cpu); + target =cpumask_any_but (topology_die_cpumask (cpu), cpu);/* Migrate rapl events to the new target */ if (target < nr_cpu_ids) {
@@ -598,14 +598,14 @@ static int rapl_cpu_online(unsigned int cpu) pmu->timer_interval =ms_to_ktime (rapl_timer_ms);rapl_hrtimer_init (pmu); - rapl_pmus->pmus[topology_logical_package_id (cpu)] = pmu; + rapl_pmus->pmus[topology_logical_die_id (cpu)] = pmu; }/* * Check if there is an online cpu in the package which collects rapl * events already. */ - target =cpumask_any_and (&rapl_cpu_mask,topology_core_cpumask (cpu)); + target =cpumask_any_and (&rapl_cpu_mask,topology_die_cpumask (cpu));if (target < nr_cpu_ids)return 0 ;
@@ -675,7 +675,7 @@ static void cleanup_rapl_pmus(void)static int __init init_rapl_pmus (void ) { -int maxpkg =topology_max_packages (); +int maxpkg =topology_max_packages () *topology_max_die_per_package ();size_t size; size =sizeof (*rapl_pmus) + maxpkg *sizeof (struct rapl_pmu *);
tip-bot for Kan Liang
merge bot[tip:x86/topology] perf/x86/intel/uncore: Support multi-die/package
In reply to Len Brownperf/x86/intel/uncore: Support multi-die/package
Commit-ID: 1ff4a47b2d0c13b755b2eeeb0e23be6c056d5dd9 Gitweb: https://git.kernel.org/tip/1ff4a47b2d0c13b755b2eeeb0e23be6c056d5dd9 Author: Kan Liang <[email protected]> AuthorDate: Mon, 13 May 2019 13:58:57 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 23 May 2019 10:08:35 +0200
perf/x86/intel/uncore: Support multi-die/package
Uncore becomes die-scope on Xeon Cascade Lake-AP. Uncore driver needs to support die-scope uncore units.
Use topology_logical_die_id() to replace topology_logical_package_id(). For previous platforms which doesn't have multi-die, topology_logical_die_id() is identical as topology_logical_package_id().
In pci_probe()/remove(), the group id reads from PCI BUS is logical die id for multi-die systems.
Use topology_die_cpumask() to replace topology_core_cpumask(). For previous platforms which doesn't have multi-die, topology_die_cpumask() is identical as topology_core_cpumask().
There is no functional change for previous platforms.
--- arch/x86/events/intel/uncore.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
arch/x86/events/intel/uncore.c +11 -9
@@ -100,7 +100,7 @@ ssize_t uncore_event_show(struct kobject *kobj,struct intel_uncore_box *uncore_pmu_to_box (struct intel_uncore_pmu *pmu,int cpu) { -unsigned int pkgid =topology_logical_package_id (cpu); +unsigned int pkgid =topology_logical_die_id (cpu);/* * The unsigned check also catches the '-1' return value for non
@@ -942,7 +942,8 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *idif (phys_id <0 )return -ENODEV ; - pkg =topology_phys_to_logical_pkg (phys_id); + pkg = (topology_max_die_per_package () >1 ) ? phys_id : +topology_phys_to_logical_pkg (phys_id);if (pkg <0 )return -EINVAL ;
@@ -1033,7 +1034,8 @@ static void uncore_pci_remove(struct pci_dev *pdev) box =pci_get_drvdata (pdev);if (!box) { - pkg =topology_phys_to_logical_pkg (phys_id); + pkg = (topology_max_die_per_package () >1 ) ? phys_id : +topology_phys_to_logical_pkg (phys_id);for (i =0 ; i <UNCORE_EXTRA_PCI_DEV_MAX ; i++) {if (uncore_extra_pci_dev[pkg].dev[i] == pdev) { uncore_extra_pci_dev[pkg].dev[i] =NULL ;
@@ -1110,7 +1112,7 @@ static void uncore_change_type_ctx(struct intel_uncore_type *type, int old_cpu,struct intel_uncore_box *box;int i, pkg; - pkg =topology_logical_package_id (old_cpu <0 ? new_cpu : old_cpu); + pkg =topology_logical_die_id (old_cpu <0 ? new_cpu : old_cpu);for (i =0 ; i < type->num_boxes; i++, pmu++) { box = pmu->boxes[pkg];if (!box)
@@ -1151,7 +1153,7 @@ static int uncore_event_cpu_offline(unsigned int cpu)if (!cpumask_test_and_clear_cpu (cpu, &uncore_cpu_mask)) goto unref;/* Find a new cpu to collect uncore events */ - target =cpumask_any_but (topology_core_cpumask (cpu), cpu); + target =cpumask_any_but (topology_die_cpumask (cpu), cpu);/* Migrate uncore events to the new target */ if (target < nr_cpu_ids)
@@ -1164,7 +1166,7 @@ static int uncore_event_cpu_offline(unsigned int cpu) unref:/* Clear the references */ - pkg =topology_logical_package_id (cpu); + pkg =topology_logical_die_id (cpu);for (; *types; types++) { type = *types; pmu = type->pmus;
@@ -1223,7 +1225,7 @@ static int uncore_event_cpu_online(unsigned int cpu)struct intel_uncore_box *box;int i, ret, pkg, target; - pkg =topology_logical_package_id (cpu); + pkg =topology_logical_die_id (cpu); ret =allocate_boxes (types, pkg, cpu);if (ret)return ret;
@@ -1242,7 +1244,7 @@ static int uncore_event_cpu_online(unsigned int cpu)* Check if there is an online cpu in the package * which collects uncore events already. */ - target =cpumask_any_and (&uncore_cpu_mask,topology_core_cpumask (cpu)); + target =cpumask_any_and (&uncore_cpu_mask,topology_die_cpumask (cpu));if (target < nr_cpu_ids)return 0 ;
@@ -1417,7 +1419,7 @@ static int __init intel_uncore_init(void)if (boot_cpu_has (X86_FEATURE_HYPERVISOR ))return -ENODEV ; - max_packages =topology_max_packages (); + max_packages =topology_max_packages () *topology_max_die_per_package (); uncore_init = (struct intel_uncore_init_fun *)id->driver_data;if (uncore_init->pci_init) {
tip-bot for Len Brown
merge bot[tip:x86/topology] thermal/x86_pkg_temp_thermal: Cosmetic: Rename internal variables to zones from packages
In reply to Len Brownthermal/x86_pkg_temp_thermal: Cosmetic: Rename internal variables to zones from packages
Commit-ID: b2ce1c883df91a231f8138935167273c1767ad66 Gitweb: https://git.kernel.org/tip/b2ce1c883df91a231f8138935167273c1767ad66 Author: Len Brown <[email protected]> AuthorDate: Mon, 13 May 2019 13:59:00 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 23 May 2019 10:08:36 +0200
thermal/x86_pkg_temp_thermal: Cosmetic: Rename internal variables to zones from packages
Syntax update only -- no logical or functional change.
In response to the new multi-die/package changes, update variable names to use the more generic thermal "zone" terminology, instead of "package", as the zones can refer to either packages or die.
--- drivers/thermal/intel/x86_pkg_temp_thermal.c | 142 ++++++++++++++------------- 1 file changed, 72 insertions(+), 70 deletions(-)
drivers/thermal/intel/x86_pkg_temp_thermal.c +72 -70
@@ -55,7 +55,7 @@ MODULE_PARM_DESC(notify_delay_ms,*/ #define MAX_NUMBER_OF_TRIPS 2 -struct pkg_device { +struct zone_device {int cpu;bool work_scheduled;u32 tj_max;
@@ -70,10 +70,10 @@ static struct thermal_zone_params pkg_temp_tz_params = { .no_hwmon = true, }; -/* Keep track of how many package pointers we allocated in init() */ -static int max_packages__read_mostly ; -/* Array of package pointers */ -static struct pkg_device **packages; +/* Keep track of how many zone pointers we allocated in init() */ +static int max_id__read_mostly ; +/* Array of zone pointers */ +static struct zone_device **zones;/* Serializes interrupt notification, work and hotplug */ static DEFINE_SPINLOCK (pkg_temp_lock);/* Protects zone operation in the work function against hotplug removal */
@@ -120,12 +120,12 @@ err_out:* * - Other callsites: Must hold pkg_temp_lock */ -static struct pkg_device *pkg_temp_thermal_get_dev (unsigned int cpu) +static struct zone_device *pkg_temp_thermal_get_dev (unsigned int cpu) { -int pkgid =topology_logical_die_id (cpu); +int id =topology_logical_die_id (cpu); -if (pkgid >=0 && pkgid < max_packages) -return packages[pkgid]; +if (id >=0 && id < max_id) +return zones[id];return NULL ; }
@@ -150,12 +150,13 @@ static int get_tj_max(int cpu, u32 *tj_max)static int sys_get_curr_temp (struct thermal_zone_device *tzd,int *temp) { -struct pkg_device *pkgdev = tzd->devdata; +struct zone_device *zonedev = tzd->devdata;u32 eax, edx; -rdmsr_on_cpu (pkgdev->cpu,MSR_IA32_PACKAGE_THERM_STATUS , &eax, &edx); +rdmsr_on_cpu (zonedev->cpu,MSR_IA32_PACKAGE_THERM_STATUS , + &eax, &edx);if (eax &0x80000000 ) { - *temp = pkgdev->tj_max - ((eax >>16 ) &0x7f ) *1000 ; + *temp = zonedev->tj_max - ((eax >>16 ) &0x7f ) *1000 ;pr_debug ("sys_get_curr_temp %d\n" , *temp);return 0 ; }
@@ -165,7 +166,7 @@ static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp)static int sys_get_trip_temp (struct thermal_zone_device *tzd,int trip,int *temp) { -struct pkg_device *pkgdev = tzd->devdata; +struct zone_device *zonedev = tzd->devdata;unsigned long thres_reg_value;u32 mask, shift, eax, edx;int ret;
@@ -181,14 +182,14 @@ static int sys_get_trip_temp(struct thermal_zone_device *tzd, shift =THERM_SHIFT_THRESHOLD0 ; } - ret =rdmsr_on_cpu (pkgdev->cpu,MSR_IA32_PACKAGE_THERM_INTERRUPT , + ret =rdmsr_on_cpu (zonedev->cpu,MSR_IA32_PACKAGE_THERM_INTERRUPT , &eax, &edx);if (ret <0 )return ret; thres_reg_value = (eax & mask) >> shift;if (thres_reg_value) - *temp = pkgdev->tj_max - thres_reg_value *1000 ; + *temp = zonedev->tj_max - thres_reg_value *1000 ;else *temp =0 ;pr_debug ("sys_get_trip_temp %d\n" , *temp);
@@ -199,14 +200,14 @@ static int sys_get_trip_temp(struct thermal_zone_device *tzd,static int sys_set_trip_temp (struct thermal_zone_device *tzd,int trip,int temp) { -struct pkg_device *pkgdev = tzd->devdata; +struct zone_device *zonedev = tzd->devdata;u32 l, h, mask, shift, intr;int ret; -if (trip >=MAX_NUMBER_OF_TRIPS || temp >= pkgdev->tj_max) +if (trip >=MAX_NUMBER_OF_TRIPS || temp >= zonedev->tj_max)return -EINVAL ; - ret =rdmsr_on_cpu (pkgdev->cpu,MSR_IA32_PACKAGE_THERM_INTERRUPT , + ret =rdmsr_on_cpu (zonedev->cpu,MSR_IA32_PACKAGE_THERM_INTERRUPT , &l, &h);if (ret <0 )return ret;
@@ -228,11 +229,12 @@ sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp)if (!temp) { l &= ~intr; }else { - l |= (pkgdev->tj_max - temp)/1000 << shift; + l |= (zonedev->tj_max - temp)/1000 << shift; l |= intr; } -return wrmsr_on_cpu (pkgdev->cpu,MSR_IA32_PACKAGE_THERM_INTERRUPT , l, h); +return wrmsr_on_cpu (zonedev->cpu,MSR_IA32_PACKAGE_THERM_INTERRUPT , + l, h); } static int sys_get_trip_type(struct thermal_zone_device *thermal, int trip,
@@ -287,26 +289,26 @@ static void pkg_temp_thermal_threshold_work_fn(struct work_struct *work) {struct thermal_zone_device *tzone =NULL ;int cpu =smp_processor_id (); -struct pkg_device *pkgdev; +struct zone_device *zonedev;u64 msr_val, wr_val;mutex_lock (&thermal_zone_mutex);spin_lock_irq (&pkg_temp_lock); ++pkg_work_cnt; - pkgdev =pkg_temp_thermal_get_dev (cpu); -if (!pkgdev) { + zonedev =pkg_temp_thermal_get_dev (cpu); +if (!zonedev) {spin_unlock_irq (&pkg_temp_lock);mutex_unlock (&thermal_zone_mutex);return ; } - pkgdev->work_scheduled = false; + zonedev->work_scheduled = false;rdmsrl (MSR_IA32_PACKAGE_THERM_STATUS , msr_val); wr_val = msr_val & ~(THERM_LOG_THRESHOLD0 |THERM_LOG_THRESHOLD1 );if (wr_val != msr_val) {wrmsrl (MSR_IA32_PACKAGE_THERM_STATUS , wr_val); - tzone = pkgdev->tzone; + tzone = zonedev->tzone; }enable_pkg_thres_interrupt ();
@@ -332,7 +334,7 @@ static void pkg_thermal_schedule_work(int cpu, struct delayed_work *work)static int pkg_thermal_notify (u64 msr_val) {int cpu =smp_processor_id (); -struct pkg_device *pkgdev; +struct zone_device *zonedev;unsigned long flags;spin_lock_irqsave (&pkg_temp_lock, flags);
@@ -341,10 +343,10 @@ static int pkg_thermal_notify(u64 msr_val)disable_pkg_thres_interrupt ();/* Work is per package, so scheduling it once is enough. */ - pkgdev =pkg_temp_thermal_get_dev (cpu); -if (pkgdev && !pkgdev->work_scheduled) { - pkgdev->work_scheduled = true; -pkg_thermal_schedule_work (pkgdev->cpu, &pkgdev->work); + zonedev =pkg_temp_thermal_get_dev (cpu); +if (zonedev && !zonedev->work_scheduled) { + zonedev->work_scheduled = true; +pkg_thermal_schedule_work (zonedev->cpu, &zonedev->work); }spin_unlock_irqrestore (&pkg_temp_lock, flags);
@@ -353,12 +355,12 @@ static int pkg_thermal_notify(u64 msr_val)static int pkg_temp_thermal_device_add (unsigned int cpu) { -int pkgid =topology_logical_die_id (cpu); +int id =topology_logical_die_id (cpu);u32 tj_max, eax, ebx, ecx, edx; -struct pkg_device *pkgdev; +struct zone_device *zonedev;int thres_count, err; -if (pkgid >= max_packages) +if (id >= max_id)return -ENOMEM ;cpuid (6 , &eax, &ebx, &ecx, &edx);
@@ -372,51 +374,51 @@ static int pkg_temp_thermal_device_add(unsigned int cpu)if (err)return err; - pkgdev =kzalloc (sizeof (*pkgdev),GFP_KERNEL ); -if (!pkgdev) + zonedev =kzalloc (sizeof (*zonedev),GFP_KERNEL ); +if (!zonedev)return -ENOMEM ; -INIT_DELAYED_WORK (&pkgdev->work, pkg_temp_thermal_threshold_work_fn); - pkgdev->cpu = cpu; - pkgdev->tj_max = tj_max; - pkgdev->tzone =thermal_zone_device_register ("x86_pkg_temp" , +INIT_DELAYED_WORK (&zonedev->work, pkg_temp_thermal_threshold_work_fn); + zonedev->cpu = cpu; + zonedev->tj_max = tj_max; + zonedev->tzone =thermal_zone_device_register ("x86_pkg_temp" , thres_count, (thres_count ==MAX_NUMBER_OF_TRIPS ) ?0x03 :0x01 , - pkgdev, &tzone_ops, &pkg_temp_tz_params,0 ,0 ); -if (IS_ERR (pkgdev->tzone)) { - err =PTR_ERR (pkgdev->tzone); -kfree (pkgdev); + zonedev, &tzone_ops, &pkg_temp_tz_params,0 ,0 ); +if (IS_ERR (zonedev->tzone)) { + err =PTR_ERR (zonedev->tzone); +kfree (zonedev);return err; }/* Store MSR value for package thermal interrupt, to restore at exit */ -rdmsr (MSR_IA32_PACKAGE_THERM_INTERRUPT , pkgdev->msr_pkg_therm_low, - pkgdev->msr_pkg_therm_high); +rdmsr (MSR_IA32_PACKAGE_THERM_INTERRUPT , zonedev->msr_pkg_therm_low, + zonedev->msr_pkg_therm_high); -cpumask_set_cpu (cpu, &pkgdev->cpumask); +cpumask_set_cpu (cpu, &zonedev->cpumask);spin_lock_irq (&pkg_temp_lock); - packages[pkgid] = pkgdev; + zones[id] = zonedev;spin_unlock_irq (&pkg_temp_lock);return 0 ; }static int pkg_thermal_cpu_offline (unsigned int cpu) { -struct pkg_device *pkgdev =pkg_temp_thermal_get_dev (cpu); +struct zone_device *zonedev =pkg_temp_thermal_get_dev (cpu);bool lastcpu, was_target;int target; -if (!pkgdev) +if (!zonedev)return 0 ; - target =cpumask_any_but (&pkgdev->cpumask, cpu); -cpumask_clear_cpu (cpu, &pkgdev->cpumask); + target =cpumask_any_but (&zonedev->cpumask, cpu); +cpumask_clear_cpu (cpu, &zonedev->cpumask); lastcpu = target >= nr_cpu_ids;/* * Remove the sysfs files, if this is the last cpu in the package * before doing further cleanups. */ if (lastcpu) { -struct thermal_zone_device *tzone = pkgdev->tzone; +struct thermal_zone_device *tzone = zonedev->tzone;/* * We must protect against a work function calling
@@ -425,7 +427,7 @@ static int pkg_thermal_cpu_offline(unsigned int cpu)* won't try to call. */ mutex_lock (&thermal_zone_mutex); - pkgdev->tzone =NULL ; + zonedev->tzone =NULL ;mutex_unlock (&thermal_zone_mutex);thermal_zone_device_unregister (tzone);
@@ -439,8 +441,8 @@ static int pkg_thermal_cpu_offline(unsigned int cpu)* one. When we drop the lock, then the interrupt notify function * will see the new target. */ - was_target = pkgdev->cpu == cpu; - pkgdev->cpu = target; + was_target = zonedev->cpu == cpu; + zonedev->cpu = target;/* * If this is the last CPU in the package remove the package
@@ -449,23 +451,23 @@ static int pkg_thermal_cpu_offline(unsigned int cpu)* worker will see the package anymore. */ if (lastcpu) { - packages[topology_logical_die_id (cpu)] =NULL ; + zones[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); + zonedev->msr_pkg_therm_low, zonedev->msr_pkg_therm_high); }/* * Check whether there is work scheduled and whether the work is * targeted at the outgoing CPU. */ -if (pkgdev->work_scheduled && was_target) { +if (zonedev->work_scheduled && was_target) {/* * To cancel the work we need to drop the lock, otherwise * we might deadlock if the work needs to be flushed. */ spin_unlock_irq (&pkg_temp_lock); -cancel_delayed_work_sync (&pkgdev->work); +cancel_delayed_work_sync (&zonedev->work);spin_lock_irq (&pkg_temp_lock);/* * If this is not the last cpu in the package and the work
@@ -473,21 +475,21 @@ static int pkg_thermal_cpu_offline(unsigned int cpu)* need to reschedule the work, otherwise the interrupt * stays disabled forever. */ -if (!lastcpu && pkgdev->work_scheduled) -pkg_thermal_schedule_work (target, &pkgdev->work); +if (!lastcpu && zonedev->work_scheduled) +pkg_thermal_schedule_work (target, &zonedev->work); }spin_unlock_irq (&pkg_temp_lock);/* Final cleanup if this is the last cpu */ if (lastcpu) -kfree (pkgdev); +kfree (zonedev);return 0 ; }static int pkg_thermal_cpu_online (unsigned int cpu) { -struct pkg_device *pkgdev =pkg_temp_thermal_get_dev (cpu); +struct zone_device *zonedev =pkg_temp_thermal_get_dev (cpu);struct cpuinfo_x86 *c = &cpu_data (cpu);/* Paranoia check */
@@ -495,8 +497,8 @@ static int pkg_thermal_cpu_online(unsigned int cpu)return -ENODEV ;/* If the package exists, nothing to do */ -if (pkgdev) { -cpumask_set_cpu (cpu, &pkgdev->cpumask); +if (zonedev) { +cpumask_set_cpu (cpu, &zonedev->cpumask);return 0 ; }return pkg_temp_thermal_device_add (cpu);
@@ -515,10 +517,10 @@ static int __init pkg_temp_thermal_init(void)if (!x86_match_cpu (pkg_temp_thermal_ids))return -ENODEV ; - max_packages =topology_max_packages () *topology_max_die_per_package (); - packages =kcalloc (max_packages,sizeof (struct pkg_device *), + max_id =topology_max_packages () *topology_max_die_per_package (); + zones =kcalloc (max_id,sizeof (struct zone_device *),GFP_KERNEL ); -if (!packages) +if (!zones)return -ENOMEM ; ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "thermal/x86_pkg:online",
@@ -537,7 +539,7 @@ static int __init pkg_temp_thermal_init(void)return 0 ; err: -kfree (packages); +kfree (zones);return ret; }module_init (pkg_temp_thermal_init)
@@ -549,7 +551,7 @@ static void __exit pkg_temp_thermal_exit(void)cpuhp_remove_state (pkg_thermal_hp_state);debugfs_remove_recursive (debugfs); -kfree (packages); +kfree (zones); }module_exit (pkg_temp_thermal_exit)
tip-bot for Len Brown
merge bot[tip:x86/topology] hwmon/coretemp: Cosmetic: Rename internal variables to zones from packages
In reply to Len Brownhwmon/coretemp: Cosmetic: Rename internal variables to zones from packages
Commit-ID: 835896a59b9577d0bc2131e027c37bdde5b979af Gitweb: https://git.kernel.org/tip/835896a59b9577d0bc2131e027c37bdde5b979af Author: Len Brown <[email protected]> AuthorDate: Mon, 13 May 2019 13:59:01 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 23 May 2019 10:08:36 +0200
hwmon/coretemp: Cosmetic: Rename internal variables to zones from packages
Syntax update only -- no logical or functional change.
In response to the new multi-die/package changes, update variable names to use the more generic thermal "zone" terminology, instead of "package", as the zones can refer to either packages or die.
--- drivers/hwmon/coretemp.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/hwmon/coretemp.c +18 -18
@@ -109,10 +109,10 @@ struct platform_data {struct device_attribute name_attr; }; -/* Keep track of how many package pointers we allocated in init() */ -static int max_packages__read_mostly ; -/* Array of package pointers. Serialized by cpu hotplug lock */ -static struct platform_device **pkg_devices; +/* Keep track of how many zone pointers we allocated in init() */ +static int max_zones__read_mostly ; +/* Array of zone pointers. Serialized by cpu hotplug lock */ +static struct platform_device **zone_devices;static ssize_t show_label (struct device *dev,struct device_attribute *devattr,char *buf)
@@ -435,10 +435,10 @@ static int chk_ucode_version(unsigned int cpu)static struct platform_device *coretemp_get_pdev (unsigned int cpu) { -int pkgid =topology_logical_die_id (cpu); +int id =topology_logical_die_id (cpu); -if (pkgid >=0 && pkgid < max_packages) -return pkg_devices[pkgid]; +if (id >=0 && id < max_zones) +return zone_devices[id];return NULL ; }
@@ -544,7 +544,7 @@ static int coretemp_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct platform_data *pdata; -/* Initialize the per-package data structures */ +/* Initialize the per-zone data structures */ pdata =devm_kzalloc (dev,sizeof (struct platform_data ),GFP_KERNEL );if (!pdata)return -ENOMEM ;
@@ -579,13 +579,13 @@ static struct platform_driver coretemp_driver = {static struct platform_device *coretemp_device_add (unsigned int cpu) { -int err, pkgid =topology_logical_die_id (cpu); +int err, zoneid =topology_logical_die_id (cpu);struct platform_device *pdev; -if (pkgid <0 ) +if (zoneid <0 )return ERR_PTR (-ENOMEM ); - pdev =platform_device_alloc (DRVNAME , pkgid); + pdev =platform_device_alloc (DRVNAME , zoneid);if (!pdev)return ERR_PTR (-ENOMEM );
@@ -595,7 +595,7 @@ static struct platform_device *coretemp_device_add(unsigned int cpu)return ERR_PTR (err); } - pkg_devices[pkgid] = pdev; + zone_devices[zoneid] = pdev;return pdev; }
@@ -703,7 +703,7 @@ static int coretemp_cpu_offline(unsigned int cpu)* the rest. */ if (cpumask_empty (&pd->cpumask)) { - pkg_devices[topology_logical_die_id (cpu)] =NULL ; + zone_devices[topology_logical_die_id (cpu)] =NULL ;platform_device_unregister (pdev);return 0 ; }
@@ -741,10 +741,10 @@ static int __init coretemp_init(void)if (!x86_match_cpu (coretemp_ids))return -ENODEV ; - max_packages =topology_max_packages () *topology_max_die_per_package (); - pkg_devices =kcalloc (max_packages,sizeof (struct platform_device *), + max_zones =topology_max_packages () *topology_max_die_per_package (); + zone_devices =kcalloc (max_zones,sizeof (struct platform_device *),GFP_KERNEL ); -if (!pkg_devices) +if (!zone_devices)return -ENOMEM ; err =platform_driver_register (&coretemp_driver);
@@ -760,7 +760,7 @@ static int __init coretemp_init(void) outdrv:platform_driver_unregister (&coretemp_driver); -kfree (pkg_devices); +kfree (zone_devices);return err; }module_init (coretemp_init)
@@ -769,7 +769,7 @@ static void __exit coretemp_exit(void) {cpuhp_remove_state (coretemp_hp_online);platform_driver_unregister (&coretemp_driver); -kfree (pkg_devices); +kfree (zone_devices); }module_exit (coretemp_exit)
tip-bot for Kan Liang
merge bot[tip:x86/topology] perf/x86/intel/cstate: Support multi-die/package
In reply to Len Brownperf/x86/intel/cstate: Support multi-die/package
Commit-ID: cb63ba0f670df1f0ddf21c6cc4bbe74db398742c Gitweb: https://git.kernel.org/tip/cb63ba0f670df1f0ddf21c6cc4bbe74db398742c Author: Kan Liang <[email protected]> AuthorDate: Mon, 13 May 2019 13:58:59 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 23 May 2019 10:08:35 +0200
perf/x86/intel/cstate: Support multi-die/package
Some cstate counters become die-scoped on Xeon Cascade Lake-AP. Perf cstate driver needs to support die-scope cstate counters.
Use topology_die_cpumask() to replace topology_core_cpumask(). For previous platforms which doesn't have multi-die, topology_die_cpumask() is identical as topology_core_cpumask(). There is no functional change for previous platforms.
Name the die-scope PMU "cstate_die".
--- arch/x86/events/intel/cstate.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
arch/x86/events/intel/cstate.c +10 -4
@@ -302,7 +302,7 @@ static int cstate_pmu_event_init(struct perf_event *event)return -EINVAL ; event->hw.event_base = pkg_msr[cfg].msr; cpu =cpumask_any_and (&cstate_pkg_cpu_mask, -topology_core_cpumask (event->cpu)); +topology_die_cpumask (event->cpu)); }else {return -ENOENT ; }
@@ -385,7 +385,7 @@ static int cstate_cpu_exit(unsigned int cpu)if (has_cstate_pkg &&cpumask_test_and_clear_cpu (cpu, &cstate_pkg_cpu_mask)) { - target =cpumask_any_but (topology_core_cpumask (cpu), cpu); + target =cpumask_any_but (topology_die_cpumask (cpu), cpu);/* Migrate events if there is a valid target */ if (target < nr_cpu_ids) {cpumask_set_cpu (target, &cstate_pkg_cpu_mask);
@@ -414,7 +414,7 @@ static int cstate_cpu_init(unsigned int cpu)* in the package cpu mask as the designated reader. */ target =cpumask_any_and (&cstate_pkg_cpu_mask, -topology_core_cpumask (cpu)); +topology_die_cpumask (cpu));if (has_cstate_pkg && target >= nr_cpu_ids)cpumask_set_cpu (cpu, &cstate_pkg_cpu_mask);
@@ -663,7 +663,13 @@ static int __init cstate_init(void) }if (has_cstate_pkg) { - err =perf_pmu_register (&cstate_pkg_pmu, cstate_pkg_pmu.name,-1 ); +if (topology_max_die_per_package () >1 ) { + err =perf_pmu_register (&cstate_pkg_pmu, +"cstate_die" ,-1 ); + }else { + err =perf_pmu_register (&cstate_pkg_pmu, + cstate_pkg_pmu.name,-1 ); + }if (err) { has_cstate_pkg = false;pr_info ("Failed to register cstate pkg pmu\n" );
tip-bot for Kan Liang
merge bot[tip:x86/topology] perf/x86/intel/uncore: Cosmetic renames in response to multi-die/pkg support
In reply to Len Brownperf/x86/intel/uncore: Cosmetic renames in response to multi-die/pkg support
Commit-ID: b0529b9cafacfd054837ea6b8c4ef7b402716744 Gitweb: https://git.kernel.org/tip/b0529b9cafacfd054837ea6b8c4ef7b402716744 Author: Kan Liang <[email protected]> AuthorDate: Mon, 13 May 2019 13:59:02 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 23 May 2019 10:08:36 +0200
perf/x86/intel/uncore: Cosmetic renames in response to multi-die/pkg support
Syntax update only -- no logical or functional change.
In response to the new multi-die/package changes, update variable names to use "die" terminology, instead of "pkg".
For previous platforms which doesn't have multi-die, "die" is identical as "pkg".
--- arch/x86/events/intel/uncore.c | 74 ++++++++++++++++++------------------ arch/x86/events/intel/uncore.h | 4 +- arch/x86/events/intel/uncore_snbep.c | 4 +- 3 files changed, 41 insertions(+), 41 deletions(-)
arch/x86/events/intel/uncore.c +37 -37
@@ -14,7 +14,7 @@ struct pci_driver *uncore_pci_driver;DEFINE_RAW_SPINLOCK (pci2phy_map_lock);struct list_head pci2phy_map_head =LIST_HEAD_INIT (pci2phy_map_head);struct pci_extra_dev *uncore_extra_pci_dev; -static int max_packages; +static int max_dies;/* mask of cpus that collect uncore events */ static cpumask_t uncore_cpu_mask;
@@ -100,13 +100,13 @@ ssize_t uncore_event_show(struct kobject *kobj,struct intel_uncore_box *uncore_pmu_to_box (struct intel_uncore_pmu *pmu,int cpu) { -unsigned int pkgid =topology_logical_die_id (cpu); +unsigned int dieid =topology_logical_die_id (cpu);/* * The unsigned check also catches the '-1' return value for non * existent mappings in the topology map. */ -return pkgid < max_packages ? pmu->boxes[pkgid] :NULL ; +return dieid < max_dies ? pmu->boxes[dieid] :NULL ; }u64 uncore_msr_read_counter (struct intel_uncore_box *box,struct perf_event *event)
@@ -311,7 +311,7 @@ static struct intel_uncore_box *uncore_alloc_box(struct intel_uncore_type *type,uncore_pmu_init_hrtimer (box); box->cpu =-1 ; box->pci_phys_id =-1 ; - box->pkgid =-1 ; + box->dieid =-1 ;/* set default hrtimer timeout */ box->hrtimer_duration =UNCORE_PMU_HRTIMER_INTERVAL ;
@@ -826,10 +826,10 @@ static void uncore_pmu_unregister(struct intel_uncore_pmu *pmu)static void uncore_free_boxes (struct intel_uncore_pmu *pmu) { -int pkg; +int die; -for (pkg =0 ; pkg < max_packages; pkg++) -kfree (pmu->boxes[pkg]); +for (die =0 ; die < max_dies; die++) +kfree (pmu->boxes[die]);kfree (pmu->boxes); }
@@ -866,7 +866,7 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid)if (!pmus)return -ENOMEM ; - size = max_packages *sizeof (struct intel_uncore_box *); + size = max_dies *sizeof (struct intel_uncore_box *);for (i =0 ; i < type->num_boxes; i++) { pmus[i].func_id = setid ? i :-1 ;
@@ -936,21 +936,21 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *idstruct intel_uncore_type *type;struct intel_uncore_pmu *pmu =NULL ;struct intel_uncore_box *box; -int phys_id, pkg, ret; +int phys_id, die, ret; phys_id =uncore_pcibus_to_physid (pdev->bus);if (phys_id <0 )return -ENODEV ; - pkg = (topology_max_die_per_package () >1 ) ? phys_id : + die = (topology_max_die_per_package () >1 ) ? phys_id :topology_phys_to_logical_pkg (phys_id); -if (pkg <0 ) +if (die <0 )return -EINVAL ;if (UNCORE_PCI_DEV_TYPE (id->driver_data) ==UNCORE_EXTRA_PCI_DEV ) {int idx =UNCORE_PCI_DEV_IDX (id->driver_data); - uncore_extra_pci_dev[pkg].dev[idx] = pdev; + uncore_extra_pci_dev[die].dev[idx] = pdev;pci_set_drvdata (pdev,NULL );return 0 ; }
@@ -989,7 +989,7 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id pmu = &type->pmus[UNCORE_PCI_DEV_IDX (id->driver_data)]; } -if (WARN_ON_ONCE (pmu->boxes[pkg] !=NULL )) +if (WARN_ON_ONCE (pmu->boxes[die] !=NULL ))return -EINVAL ; box =uncore_alloc_box (type,NUMA_NO_NODE );
@@ -1003,13 +1003,13 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *idatomic_inc (&box->refcnt); box->pci_phys_id = phys_id; - box->pkgid = pkg; + box->dieid = die; box->pci_dev = pdev; box->pmu = pmu;uncore_box_init (box);pci_set_drvdata (pdev, box); - pmu->boxes[pkg] = box; + pmu->boxes[die] = box;if (atomic_inc_return (&pmu->activeboxes) >1 )return 0 ;
@@ -1017,7 +1017,7 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id ret =uncore_pmu_register (pmu);if (ret) {pci_set_drvdata (pdev,NULL ); - pmu->boxes[pkg] =NULL ; + pmu->boxes[die] =NULL ;uncore_box_exit (box);kfree (box); }
@@ -1028,17 +1028,17 @@ static void uncore_pci_remove(struct pci_dev *pdev) {struct intel_uncore_box *box;struct intel_uncore_pmu *pmu; -int i, phys_id, pkg; +int i, phys_id, die; phys_id =uncore_pcibus_to_physid (pdev->bus); box =pci_get_drvdata (pdev);if (!box) { - pkg = (topology_max_die_per_package () >1 ) ? phys_id : + die = (topology_max_die_per_package () >1 ) ? phys_id :topology_phys_to_logical_pkg (phys_id);for (i =0 ; i <UNCORE_EXTRA_PCI_DEV_MAX ; i++) { -if (uncore_extra_pci_dev[pkg].dev[i] == pdev) { - uncore_extra_pci_dev[pkg].dev[i] =NULL ; +if (uncore_extra_pci_dev[die].dev[i] == pdev) { + uncore_extra_pci_dev[die].dev[i] =NULL ;break ; } }
@@ -1051,7 +1051,7 @@ static void uncore_pci_remove(struct pci_dev *pdev)return ;pci_set_drvdata (pdev,NULL ); - pmu->boxes[box->pkgid] =NULL ; + pmu->boxes[box->dieid] =NULL ;if (atomic_dec_return (&pmu->activeboxes) ==0 )uncore_pmu_unregister (pmu);uncore_box_exit (box);
@@ -1063,7 +1063,7 @@ static int __init uncore_pci_init(void)size_t size;int ret; - size = max_packages *sizeof (struct pci_extra_dev ); + size = max_dies *sizeof (struct pci_extra_dev ); uncore_extra_pci_dev =kzalloc (size,GFP_KERNEL );if (!uncore_extra_pci_dev) { ret = -ENOMEM ;
@@ -1110,11 +1110,11 @@ static void uncore_change_type_ctx(struct intel_uncore_type *type, int old_cpu, {struct intel_uncore_pmu *pmu = type->pmus;struct intel_uncore_box *box; -int i, pkg; +int i, die; - pkg =topology_logical_die_id (old_cpu <0 ? new_cpu : old_cpu); + die =topology_logical_die_id (old_cpu <0 ? new_cpu : old_cpu);for (i =0 ; i < type->num_boxes; i++, pmu++) { - box = pmu->boxes[pkg]; + box = pmu->boxes[die];if (!box)continue ;
@@ -1147,7 +1147,7 @@ static int uncore_event_cpu_offline(unsigned int cpu)struct intel_uncore_type *type, **types = uncore_msr_uncores;struct intel_uncore_pmu *pmu;struct intel_uncore_box *box; -int i, pkg, target; +int i, die, target;/* Check if exiting cpu is used for collecting uncore events */ if (!cpumask_test_and_clear_cpu (cpu, &uncore_cpu_mask))
@@ -1166,12 +1166,12 @@ static int uncore_event_cpu_offline(unsigned int cpu) unref:/* Clear the references */ - pkg =topology_logical_die_id (cpu); + die =topology_logical_die_id (cpu);for (; *types; types++) { type = *types; pmu = type->pmus;for (i =0 ; i < type->num_boxes; i++, pmu++) { - box = pmu->boxes[pkg]; + box = pmu->boxes[die];if (box &&atomic_dec_return (&box->refcnt) ==0 )uncore_box_exit (box); }
@@ -1180,7 +1180,7 @@ unref: }static int allocate_boxes (struct intel_uncore_type **types, -unsigned int pkg,unsigned int cpu) +unsigned int die,unsigned int cpu) {struct intel_uncore_box *box, *tmp;struct intel_uncore_type *type;
@@ -1193,20 +1193,20 @@ static int allocate_boxes(struct intel_uncore_type **types, type = *types; pmu = type->pmus;for (i =0 ; i < type->num_boxes; i++, pmu++) { -if (pmu->boxes[pkg]) +if (pmu->boxes[die])continue ; box =uncore_alloc_box (type,cpu_to_node (cpu));if (!box) goto cleanup; box->pmu = pmu; - box->pkgid = pkg; + box->dieid = die;list_add (&box->active_list, &allocated); } }/* Install them in the pmus */ list_for_each_entry_safe (box, tmp, &allocated, active_list) {list_del_init (&box->active_list); - box->pmu->boxes[pkg] = box; + box->pmu->boxes[die] = box; }return 0 ;
@@ -1223,10 +1223,10 @@ static int uncore_event_cpu_online(unsigned int cpu)struct intel_uncore_type *type, **types = uncore_msr_uncores;struct intel_uncore_pmu *pmu;struct intel_uncore_box *box; -int i, ret, pkg, target; +int i, ret, die, target; - pkg =topology_logical_die_id (cpu); - ret =allocate_boxes (types, pkg, cpu); + die =topology_logical_die_id (cpu); + ret =allocate_boxes (types, die, cpu);if (ret)return ret;
@@ -1234,7 +1234,7 @@ static int uncore_event_cpu_online(unsigned int cpu) type = *types; pmu = type->pmus;for (i =0 ; i < type->num_boxes; i++, pmu++) { - box = pmu->boxes[pkg]; + box = pmu->boxes[die];if (box &&atomic_inc_return (&box->refcnt) ==1 )uncore_box_init (box); }
@@ -1419,7 +1419,7 @@ static int __init intel_uncore_init(void)if (boot_cpu_has (X86_FEATURE_HYPERVISOR ))return -ENODEV ; - max_packages =topology_max_packages () *topology_max_die_per_package (); + max_dies =topology_max_packages () *topology_max_die_per_package (); uncore_init = (struct intel_uncore_init_fun *)id->driver_data;if (uncore_init->pci_init) {
arch/x86/events/intel/uncore.h +2 -2
@@ -108,7 +108,7 @@ struct intel_uncore_extra_reg {struct intel_uncore_box {int pci_phys_id; -int pkgid;/* Logical package ID */ +int dieid;/* Logical die ID */ int n_active;/* number of active events */ int n_events;int cpu;/* cpu to collect events */
@@ -467,7 +467,7 @@ static inline void uncore_box_exit(struct intel_uncore_box *box)static inline bool uncore_box_is_fake (struct intel_uncore_box *box) { -return (box->pkgid <0 ); +return (box->dieid <0 ); }static inline struct intel_uncore_pmu *uncore_event_to_pmu (struct perf_event *event)
arch/x86/events/intel/uncore_snbep.c +2 -2
@@ -1058,8 +1058,8 @@ static void snbep_qpi_enable_event(struct intel_uncore_box *box, struct perf_eveif (reg1->idx !=EXTRA_REG_NONE ) {int idx = box->pmu->pmu_idx +SNBEP_PCI_QPI_PORT0_FILTER ; -int pkg = box->pkgid; -struct pci_dev *filter_pdev = uncore_extra_pci_dev[pkg].dev[idx]; +int die = box->dieid; +struct pci_dev *filter_pdev = uncore_extra_pci_dev[die].dev[idx];if (filter_pdev) { pci_write_config_dword(filter_pdev, reg1->reg,
tip-bot for Kan Liang
merge bot[tip:x86/topology] perf/x86/intel/rapl: Cosmetic rename internal variables in response to multi-die/pkg support
In reply to Len Brownperf/x86/intel/rapl: Cosmetic rename internal variables in response to multi-die/pkg support
Commit-ID: eb876fbc248e6eb4773a5bc80d205ff7262b1bb5 Gitweb: https://git.kernel.org/tip/eb876fbc248e6eb4773a5bc80d205ff7262b1bb5 Author: Kan Liang <[email protected]> AuthorDate: Mon, 13 May 2019 13:59:03 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 23 May 2019 10:08:37 +0200
perf/x86/intel/rapl: Cosmetic rename internal variables in response to multi-die/pkg support
Syntax update only -- no logical or functional change.
In response to the new multi-die/package changes, update variable names to use "die" terminology, instead of "pkg".
For previous platforms which doesn't have multi-die, "die" is identical as "pkg".
--- arch/x86/events/intel/rapl.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
arch/x86/events/intel/rapl.c +7 -7
@@ -148,7 +148,7 @@ struct rapl_pmu {struct rapl_pmus {struct pmu pmu; -unsigned int maxpkg; +unsigned int maxdie;struct rapl_pmu *pmus[]; };
@@ -161,13 +161,13 @@ static u64 rapl_timer_ms;static inline struct rapl_pmu *cpu_to_rapl_pmu (unsigned int cpu) { -unsigned int pkgid =topology_logical_die_id (cpu); +unsigned int dieid =topology_logical_die_id (cpu);/* * The unsigned check also catches the '-1' return value for non * existent mappings in the topology map. */ -return pkgid < rapl_pmus->maxpkg ? rapl_pmus->pmus[pkgid] :NULL ; +return dieid < rapl_pmus->maxdie ? rapl_pmus->pmus[dieid] :NULL ; }static inline u64 rapl_read_counter (struct perf_event *event)
@@ -668,22 +668,22 @@ static void cleanup_rapl_pmus(void) {int i; -for (i =0 ; i < rapl_pmus->maxpkg; i++) +for (i =0 ; i < rapl_pmus->maxdie; i++)kfree (rapl_pmus->pmus[i]);kfree (rapl_pmus); }static int __init init_rapl_pmus (void ) { -int maxpkg =topology_max_packages () *topology_max_die_per_package (); +int maxdie =topology_max_packages () *topology_max_die_per_package ();size_t size; - size =sizeof (*rapl_pmus) + maxpkg *sizeof (struct rapl_pmu *); + size =sizeof (*rapl_pmus) + maxdie *sizeof (struct rapl_pmu *); rapl_pmus =kzalloc (size,GFP_KERNEL );if (!rapl_pmus)return -ENOMEM ; - rapl_pmus->maxpkg = maxpkg; + rapl_pmus->maxdie = maxdie; rapl_pmus->pmu.attr_groups = rapl_attr_groups; rapl_pmus->pmu.task_ctx_nr = perf_invalid_context; rapl_pmus->pmu.event_init = rapl_pmu_event_init;