The Intel Hardware Feedback Interface (HFI) [1] provides information about
the performance and energy efficiency of each CPU in the system. It uses a
table that is shared between hardware and the operating system. The
contents of the table may be updated as a result of changes in the
operating conditions of the system (e.g., reaching a thermal limit) or the
action of external factors (e.g., changes in the thermal design power).
The information that HFI provides are specified as numeric, unit-less
capabilities relative to other CPUs in the system. These capabilities have
a range of [0-255] where higher numbers represent higher capabilities.
Energy efficiency and performance are reported in separate capabilities.
If either the performance or energy capabilities efficiency of a CPU are 0,
the hardware recommends to not schedule any tasks on such CPU for
performance, energy efficiency or thermal reasons, respectively.
The kernel or user space may use the information from the HFI to modify
task placement and/or adjust power limits. This patchset focuses on the
user space. The thermal notification framework is extended to relay
updates of CPU capacity. Thus, a userspace daemon can affinitize workloads
to certain CPUs and/or offline CPUs whose capabilities are zero.
The frequency of HFI updates is specific to each processor model. On some
systems, there is just a single HFI update at boot. On other systems, there
may be updates every tens of milliseconds. In order to not overwhelm
userspace with too many updates, they are limited to one update every
CONFIG_HZ jiffies.
Thanks and BR,
Ricardo
[1]. https://www.intel.com/sdm
Ricardo Neri (5):
x86/Documentation: Describe the Intel Hardware Feedback Interface
x86: Add definitions for the Intel Hardware Feedback Interface
thermal: intel: hfi: Minimally initialize the Hardware Feedback
Interface
thermal: intel: hfi: Handle CPU hotplug events
thermal: intel: hfi: Enable notification interrupt
Srinivas Pandruvada (2):
thermal: netlink: Add a new event to notify CPU capabilities change
thermal: intel: hfi: Notify user space for HFI events
Documentation/x86/index.rst | 1 +
Documentation/x86/intel-hfi.rst | 68 ++++
arch/x86/include/asm/cpufeatures.h | 1 +
arch/x86/include/asm/msr-index.h | 6 +
drivers/thermal/intel/Kconfig | 13 +
drivers/thermal/intel/Makefile | 1 +
drivers/thermal/intel/intel_hfi.c | 508 ++++++++++++++++++++++++++++
drivers/thermal/intel/intel_hfi.h | 40 +++
drivers/thermal/intel/therm_throt.c | 21 ++
drivers/thermal/thermal_netlink.c | 52 +++
drivers/thermal/thermal_netlink.h | 13 +
include/uapi/linux/thermal.h | 6 +-
12 files changed, 729 insertions(+), 1 deletion(-)
create mode 100644 Documentation/x86/intel-hfi.rst
create mode 100644 drivers/thermal/intel/intel_hfi.c
create mode 100644 drivers/thermal/intel/intel_hfi.h
--
2.17.1
Start a documentation file to describe the purpose and operation of Intel's
Hardware Feedback Interface. Describe how this interface is used in Linux
to relay performance and energy efficiency updates to userspace.
Cc: Andi Kleen <redacted>
Cc: Aubrey Li <redacted>
Cc: Tim Chen <redacted>
Cc: "Ravi V. Shankar" <redacted>
Reviewed-by: Len Brown <redacted>
Suggested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Ricardo Neri <redacted>
---
Documentation/x86/index.rst | 1 +
Documentation/x86/intel-hfi.rst | 68 +++++++++++++++++++++++++++++++++
2 files changed, 69 insertions(+)
create mode 100644 Documentation/x86/intel-hfi.rst
@@ -0,0 +1,68 @@+.. SPDX-License-Identifier: GPL-2.0++============================================================+Hardware-Feedback Interface for scheduling on Intel Hardware+============================================================++Overview+--------++Intel has described the Hardware Feedback Interface (HFI) in the Intel 64 and+IA-32 Architectures Software Developer's Manual (Intel SDM) Volume 3 Section+14.6 [1]_.++The HFI gives the operating system a performance and energy efficiency+capability data for each CPU in the system. Linux can use the information from+the HFI to influence task placement decisions.++The Hardware Feedback Interface+-------------------------------++The Hardware Feedback Interface provides to the operating system information+about the performance and energy efficiency of each CPU in the system. Each+capability is given as a unit-less quantity in the range [0-255]. Higher values+indicate higher capability. Energy efficiency and performance are reported in+separate capabilities.++These capabilities may change at runtime as a result of changes in the+operating conditions of the system or the action of external factors. The rate+at which these capabilities are updated is specific to each processor model. On+some models, capabilities are set at boot time and never change. On others,+capabilities may change every tens of milliseconds.++The kernel or a userspace policy daemon can use these capabilities to modify+task placement decisions. For instance, if either the performance or energy+capabilities of a given logical processor becomes zero, it is an indication that+the hardware recommends to the operating system to not schedule any tasks on+that processor for performance or energy efficiency reasons, respectively.++Implementation details for Linux+--------------------------------++The infrastructure to handle thermal event interrupts has two parts. In the+Local Vector Table of a CPU's local APIC, there exists a register for the+Thermal Monitor Register. This register controls how interrupts are delivered+to a CPU when the thermal monitor generates and interrupt. Further details+can be found in the Intel SDM Vol. 3 Section 10.5 [1]_.++The thermal monitor may generate interrupts per CPU or per package. The HFI+generates package-level interrupts. This monitor is configured and initialized+via a set of machine-specific registers. Specifically, the HFI interrupt and+status are controlled via designated bits in the IA32_PACKAGE_THERM_INTERRUPT+and IA32_PACKAGE_THERM_STATUS registers, respectively. There exists one HFI+table per package. Further details can be found in the Intel SDM Vol. 3+Section 14.9 [1]_.++The hardware issues an HFI interrupt after updating the HFI table and is ready+for the operating system to consume it. CPUs receive such interrupt via the+thermal entry in the Local APIC's Local Vector Table.++When servicing such interrupt, the HFI driver parses the updated table and+relays the update to userspace using the thermal notification framework. Given+that there may be many HFI updates every second, the updates relayed to+userspace are throttled at a rate of CONFIG_HZ jiffies.++References+----------++..[1] https://www.intel.com/sdm
From: Daniel Lezcano <hidden> Date: 2021-11-30 09:24:43
Hi Ricardo,
On 06/11/2021 02:33, Ricardo Neri wrote:
quoted hunk
Start a documentation file to describe the purpose and operation of Intel's
Hardware Feedback Interface. Describe how this interface is used in Linux
to relay performance and energy efficiency updates to userspace.
Cc: Andi Kleen <redacted>
Cc: Aubrey Li <redacted>
Cc: Tim Chen <redacted>
Cc: "Ravi V. Shankar" <redacted>
Reviewed-by: Len Brown <redacted>
Suggested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Ricardo Neri <redacted>
---
Documentation/x86/index.rst | 1 +
Documentation/x86/intel-hfi.rst | 68 +++++++++++++++++++++++++++++++++
2 files changed, 69 insertions(+)
create mode 100644 Documentation/x86/intel-hfi.rst
@@ -0,0 +1,68 @@+.. SPDX-License-Identifier: GPL-2.0++============================================================+Hardware-Feedback Interface for scheduling on Intel Hardware+============================================================++Overview+--------++Intel has described the Hardware Feedback Interface (HFI) in the Intel 64 and+IA-32 Architectures Software Developer's Manual (Intel SDM) Volume 3 Section+14.6 [1]_.++The HFI gives the operating system a performance and energy efficiency+capability data for each CPU in the system. Linux can use the information from+the HFI to influence task placement decisions.++The Hardware Feedback Interface+-------------------------------++The Hardware Feedback Interface provides to the operating system information+about the performance and energy efficiency of each CPU in the system. Each+capability is given as a unit-less quantity in the range [0-255]. Higher values+indicate higher capability. Energy efficiency and performance are reported in+separate capabilities.
Are they linked together (eg. higher energy efficiency => lower
performance)?
+These capabilities may change at runtime as a result of changes in the
+operating conditions of the system or the action of external factors.
Is it possible to give examples?
The rate
+at which these capabilities are updated is specific to each processor model. On
+some models, capabilities are set at boot time and never change. On others,
+capabilities may change every tens of milliseconds.
+
+The kernel or a userspace policy daemon can use these capabilities to modify
+task placement decisions. For instance, if either the performance or energy
+capabilities of a given logical processor becomes zero, it is an indication that
+the hardware recommends to the operating system to not schedule any tasks on
+that processor for performance or energy efficiency reasons, respectively.
How the userspace can be involved in these decisions? If the performance
is impacted then that should be reflected in the CPU capacity. The
scheduler will prevent to put task on CPU with a low capacity, no?
I'm also worried about the overhead of the userspace notifications.
That sounds like similar to the thermal pressure? Wouldn't make sense to
create a generic component where HFI, cpufreq cooling, LMh, etc ... are
the backend?
+Implementation details for Linux
+--------------------------------
+
+The infrastructure to handle thermal event interrupts has two parts. In the
+Local Vector Table of a CPU's local APIC, there exists a register for the
+Thermal Monitor Register. This register controls how interrupts are delivered
+to a CPU when the thermal monitor generates and interrupt. Further details
+can be found in the Intel SDM Vol. 3 Section 10.5 [1]_.
+
+The thermal monitor may generate interrupts per CPU or per package. The HFI
+generates package-level interrupts. This monitor is configured and initialized
+via a set of machine-specific registers. Specifically, the HFI interrupt and
+status are controlled via designated bits in the IA32_PACKAGE_THERM_INTERRUPT
+and IA32_PACKAGE_THERM_STATUS registers, respectively. There exists one HFI
+table per package. Further details can be found in the Intel SDM Vol. 3
+Section 14.9 [1]_.
+
+The hardware issues an HFI interrupt after updating the HFI table and is ready
+for the operating system to consume it. CPUs receive such interrupt via the
+thermal entry in the Local APIC's Local Vector Table.
+
+When servicing such interrupt, the HFI driver parses the updated table and
+relays the update to userspace using the thermal notification framework. Given
+that there may be many HFI updates every second, the updates relayed to
+userspace are throttled at a rate of CONFIG_HZ jiffies.
+
+References
+----------
+
+.. [1] https://www.intel.com/sdm
Hi Daniel,
On Tue, 2021-11-30 at 10:24 +0100, Daniel Lezcano wrote:
Hi Ricardo,
quoted
[...]
quoted
+The Hardware Feedback Interface
+-------------------------------
+
+The Hardware Feedback Interface provides to the operating system
information
+about the performance and energy efficiency of each CPU in the
system. Each
+capability is given as a unit-less quantity in the range [0-255].
Higher values
+indicate higher capability. Energy efficiency and performance are
reported in
+separate capabilities.
Are they linked together (eg. higher energy efficiency => lower
performance)?
Generally true.
But for some workload and condition higher energy efficient point
doesn't mean lower performance.
quoted
+These capabilities may change at runtime as a result of changes in
the
+operating conditions of the system or the action of external
factors.
Is it possible to give examples?
For example a server farm decide to save power by reduce cooling cost,
by lowering TDP. This can be done remotely. This will result in
notification of a lower performance value or even perf=eff=0 on some
CPUs via HFI. Intel CPU has capability to change TDP level runtime.
Or if the system is over heating the firmware can indicate lower
performance, so OSPM can take action.
quoted
The rate
+at which these capabilities are updated is specific to each
processor model. On
+some models, capabilities are set at boot time and never change.
On others,
+capabilities may change every tens of milliseconds.
+
+The kernel or a userspace policy daemon can use these capabilities
to modify
+task placement decisions. For instance, if either the performance
or energy
+capabilities of a given logical processor becomes zero, it is an
indication that
+the hardware recommends to the operating system to not schedule
any tasks on
+that processor for performance or energy efficiency reasons,
respectively.
How the userspace can be involved in these decisions? If the
performance
is impacted then that should be reflected in the CPU capacity. The
scheduler will prevent to put task on CPU with a low capacity, no?
I'm also worried about the overhead of the userspace notifications.
That sounds like similar to the thermal pressure? Wouldn't make sense
to
create a generic component where HFI, cpufreq cooling, LMh, etc ...
are
the backend?
The problem is treatment of perf/eff == 0 of a CPU, which we can
indicate as capacity = 0 to scheduler. But this doesn't prevent
scheduler for using that CPU on a overloaded system. We can offline
that CPU in kernel, which will be intrusive without notifying user
space or may fail for CPU0. Tried cpu idle injection, remove from cpu
sets. But doesn't work when interrupt are affined to that CPU, soft
irqs or timer scheduled there.
Here the notification are in order of several ms in order ( In reality
they are in seconds for current use cases). These are not emergency
events. Same as other thermal notifications, if something urgent FW can
already force to lowest performance without even notifying user space.
Thanks,
Srinivas
quoted
+Implementation details for Linux
+--------------------------------
+
+The infrastructure to handle thermal event interrupts has two
parts. In the
+Local Vector Table of a CPU's local APIC, there exists a register
for the
+Thermal Monitor Register. This register controls how interrupts
are delivered
+to a CPU when the thermal monitor generates and interrupt. Further
details
+can be found in the Intel SDM Vol. 3 Section 10.5 [1]_.
+
+The thermal monitor may generate interrupts per CPU or per
package. The HFI
+generates package-level interrupts. This monitor is configured and
initialized
+via a set of machine-specific registers. Specifically, the HFI
interrupt and
+status are controlled via designated bits in the
IA32_PACKAGE_THERM_INTERRUPT
+and IA32_PACKAGE_THERM_STATUS registers, respectively. There
exists one HFI
+table per package. Further details can be found in the Intel SDM
Vol. 3
+Section 14.9 [1]_.
+
+The hardware issues an HFI interrupt after updating the HFI table
and is ready
+for the operating system to consume it. CPUs receive such
interrupt via the
+thermal entry in the Local APIC's Local Vector Table.
+
+When servicing such interrupt, the HFI driver parses the updated
table and
+relays the update to userspace using the thermal notification
framework. Given
+that there may be many HFI updates every second, the updates
relayed to
+userspace are throttled at a rate of CONFIG_HZ jiffies.
+
+References
+----------
+
+.. [1] https://www.intel.com/sdm
The Intel Hardware Feedback Interface provides guidance to the operating
system about the performance and energy efficiency capabilities of each
CPU in the system. Capabilities are numbers between 0 and 255 where a
higher number represents a higher capability. For each CPU, energy
efficiency and performance are reported as separate capabilities.
Hardware computes these capabilities based on the operating conditions of
the system such as power and thermal limits. These capabilities are shared
with the operating system in a table resident in memory. Each package in
the system has its own HFI instance. Every logical CPU in the package is
represented in the table. More than one logical CPUs may be represented in
a single table entry. When the hardware updates the table, it generates a
package-level thermal interrupt.
The size and format of the HFI table depend on the supported features and
can only be determined at runtime. To minimally initialize the HFI, parse
its features and allocate one instance per package of a data structure with
the necessary parameters to read and navigate individual HFI tables.
A subsequent changeset will provide per-CPU initialization and interrupt
handling.
Cc: Andi Kleen <redacted>
Cc: Aubrey Li <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Tim Chen <redacted>
Cc: "Ravi V. Shankar" <redacted>
Reviewed-by: Len Brown <redacted>
Co-developed by: Aubrey Li [off-list ref]
Signed-off-by: Aubrey Li <redacted>
Signed-off-by: Ricardo Neri <redacted>
---
drivers/thermal/intel/Kconfig | 12 +++
drivers/thermal/intel/Makefile | 1 +
drivers/thermal/intel/intel_hfi.c | 155 ++++++++++++++++++++++++++++
drivers/thermal/intel/intel_hfi.h | 34 ++++++
drivers/thermal/intel/therm_throt.c | 3 +
5 files changed, 205 insertions(+)
create mode 100644 drivers/thermal/intel/intel_hfi.c
create mode 100644 drivers/thermal/intel/intel_hfi.h
@@ -0,0 +1,155 @@+// SPDX-License-Identifier: GPL-2.0-only+/*+*HardwareFeedbackInterfaceDriver+*+*Copyright(c)2021,IntelCorporation.+*+*Authors:AubreyLi<aubrey.li@linux.intel.com>+*RicardoNeri<ricardo.neri-calderon@linux.intel.com>+*+*+*TheHardwareFeedbackInterfaceprovidesaperformanceandenergyefficiency+*capabilityinformationforeachCPUinthesystem.Dependingontheprocessor+*model,hardwaremayperiodicallyupdatethesecapabilitiesasaresultof+*changesintheoperatingconditions(e.g.,powerlimitsorthermal+*constraints).Onotherprocessormodels,thereisasingleHFIupdate+*atboot.+*+*ThisfileprovidesfunctionalitytoprocessHFIupdatesandrelaythese+*updatestouserspace.+*/++#define pr_fmt(fmt) "intel-hfi: " fmt++#include<linux/slab.h>++#include"intel_hfi.h"++/**+*structhfi_cpu_data-HFIcapabilitiesperCPU+*@perf_cap:Performancecapability+*@ee_cap:Energyefficiencycapability+*+*CapabilitiesofalogicalprocessorintheHFItable.Thesecapabilitiesare+*unitless.+*/+structhfi_cpu_data{+u8perf_cap;+u8ee_cap;+}__packed;++/**+*structhfi_hdr-HeaderoftheHFItable+*@perf_updated:Hardwareupdatedperformancecapabilities+*@ee_updated:Hardwareupdatedenergyefficiencycapabilities+*+*PropertiesofthedatainanHFItable.+*/+structhfi_hdr{+u8perf_updated;+u8ee_updated;+}__packed;++/**+*structhfi_instance-RepresentationofanHFIinstance(i.e.,atable)+*@ts_counter:Timestampofthelastupdateofthetable+*@hdr:Baseaddressofthetableheader+*@data:Baseaddressofthetabledata+*+*AsetofparameterstoparseandnavigateaspecificHFItable.+*/+structhfi_instance{+u64*ts_counter;+void*hdr;+void*data;+};++/**+*structhfi_features-SupportedHFIfeatures+*@capabilities:Bitmaskofsupportedcapabilities+*@nr_table_pages:SizeoftheHFItablein4KBpages+*@cpu_stride:Stridesizetolocatecapabilitydataofalogical+*processorwithinthetable(i.e.,rowstride)+*@hdr_size:Sizeoftableheader+*@parsed:TrueifHFIfeatureshavebeenparsed+*+*ParametersandsupportedfeaturesthatarecommontoallHFIinstances+*/+structhfi_features{+unsignedlongcapabilities;+unsignedintnr_table_pages;+unsignedintcpu_stride;+unsignedinthdr_size;+boolparsed;+};++staticintmax_hfi_instances;+staticstructhfi_instance*hfi_instances;++staticstructhfi_featureshfi_features;++static__initinthfi_parse_features(void)+{+unsignedintnr_capabilities,reg;++if(!boot_cpu_has(X86_FEATURE_INTEL_HFI))+return-ENODEV;++if(hfi_features.parsed)+return0;++/*+*IfwearehereweknowthatCPUID_HFI_LEAFexists.Parsethe+*supportedcapabilitiesandthesizeoftheHFItable.+*/+reg=cpuid_edx(CPUID_HFI_LEAF);++hfi_features.capabilities=reg&HFI_CAPABILITIES_MASK;+if(!(hfi_features.capabilities&HFI_CAPABILITIES_PERFORMANCE)){+pr_err("Performance reporting not supported! Not using HFI\n");+return-ENODEV;+}++/* The number of 4KB pages required by the table */+hfi_features.nr_table_pages=((reg&CPUID_HFI_TABLE_SIZE_MASK)>>+CPUID_HFI_TABLE_SIZE_SHIFT)+1;++/*+*Thenumberofsupportedcapabilitiesdeterminesthenumberof+*columnsintheHFItable.+*/+nr_capabilities=bitmap_weight(&hfi_features.capabilities,+HFI_CAPABILITIES_NR);++/*+*Theheadercontainschangeindicationsforeachsupportedfeature.+*Thesizeofthetableheaderisroundeduptobeamultipleof8+*bytes.+*/+hfi_features.hdr_size=DIV_ROUND_UP(nr_capabilities,8)*8;++/*+*Dataofeachlogicalprocessorisalsoroundeduptobeamultiple+*of8bytes.+*/+hfi_features.cpu_stride=DIV_ROUND_UP(nr_capabilities,8)*8;++hfi_features.parsed=true;+return0;+}++void__initintel_hfi_init(void)+{+if(hfi_parse_features())+return;++max_hfi_instances=topology_max_packages()*+topology_max_die_per_package();++/*+*Thisallocationmayfail.CPUhotplugcallbacksmustcheck+*foranullpointer.+*/+hfi_instances=kcalloc(max_hfi_instances,sizeof(*hfi_instances),+GFP_KERNEL);+}
@@ -32,6 +32,7 @@#include<asm/irq.h>#include<asm/msr.h>+#include"intel_hfi.h"#include"thermal_interrupt.h"/* How long to wait between reporting thermal events */
@@ -509,6 +510,8 @@ static __init int thermal_throttle_init_device(void)if(!atomic_read(&therm_throt_en))return0;+intel_hfi_init();+ret=cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,"x86/therm:online",thermal_throttle_online,thermal_throttle_offline);
From: Peter Zijlstra <peterz@infradead.org> Date: 2021-11-08 08:48:12
On Fri, Nov 05, 2021 at 06:33:08PM -0700, Ricardo Neri wrote:
+static __init int hfi_parse_features(void)
+{
+ unsigned int nr_capabilities, reg;
+
+ /*
+ * If we are here we know that CPUID_HFI_LEAF exists. Parse the
+ * supported capabilities and the size of the HFI table.
+ */
+ reg = cpuid_edx(CPUID_HFI_LEAF);
+
+ hfi_features.capabilities = reg & HFI_CAPABILITIES_MASK;
+ if (!(hfi_features.capabilities & HFI_CAPABILITIES_PERFORMANCE)) {
+ pr_err("Performance reporting not supported! Not using HFI\n");
+ return -ENODEV;
+ }
+
+ /* The number of 4KB pages required by the table */
+ hfi_features.nr_table_pages = ((reg & CPUID_HFI_TABLE_SIZE_MASK) >>
+ CPUID_HFI_TABLE_SIZE_SHIFT) + 1;
+
So personally I prefer a bitfield union a-la cpuid10_eax, cpuid10_ebx
cpuid10_edx etc.. Barring that, the above can also be written more
concise using FIELD_GET() from bitfields.
union cpuid6_edx {
struct {
unsigned int capabilities : 8;
unsigned int table_size : 4;
unsigned int __reserved : 4;
unsigned int cpu_index : 16;
};
unsigned int full;
};
On Mon, Nov 08, 2021 at 09:47:54AM +0100, Peter Zijlstra wrote:
On Fri, Nov 05, 2021 at 06:33:08PM -0700, Ricardo Neri wrote:
quoted
+static __init int hfi_parse_features(void)
+{
+ unsigned int nr_capabilities, reg;
+
quoted
+ /*
+ * If we are here we know that CPUID_HFI_LEAF exists. Parse the
+ * supported capabilities and the size of the HFI table.
+ */
+ reg = cpuid_edx(CPUID_HFI_LEAF);
+
+ hfi_features.capabilities = reg & HFI_CAPABILITIES_MASK;
+ if (!(hfi_features.capabilities & HFI_CAPABILITIES_PERFORMANCE)) {
+ pr_err("Performance reporting not supported! Not using HFI\n");
+ return -ENODEV;
+ }
+
+ /* The number of 4KB pages required by the table */
+ hfi_features.nr_table_pages = ((reg & CPUID_HFI_TABLE_SIZE_MASK) >>
+ CPUID_HFI_TABLE_SIZE_SHIFT) + 1;
+
So personally I prefer a bitfield union a-la cpuid10_eax, cpuid10_ebx
cpuid10_edx etc.. Barring that, the above can also be written more
concise using FIELD_GET() from bitfields.
union cpuid6_edx {
struct {
unsigned int capabilities : 8;
unsigned int table_size : 4;
unsigned int __reserved : 4;
unsigned int cpu_index : 16;
};
unsigned int full;
};
Sure Peter. This looks more readable. I'll implement it like this.
Thanks and BR,
Ricardo
From: "Rafael J. Wysocki" <rafael@kernel.org> Date: 2021-11-24 14:12:16
On Sat, Nov 6, 2021 at 2:34 AM Ricardo Neri
[off-list ref] wrote:
quoted hunk
The Intel Hardware Feedback Interface provides guidance to the operating
system about the performance and energy efficiency capabilities of each
CPU in the system. Capabilities are numbers between 0 and 255 where a
higher number represents a higher capability. For each CPU, energy
efficiency and performance are reported as separate capabilities.
Hardware computes these capabilities based on the operating conditions of
the system such as power and thermal limits. These capabilities are shared
with the operating system in a table resident in memory. Each package in
the system has its own HFI instance. Every logical CPU in the package is
represented in the table. More than one logical CPUs may be represented in
a single table entry. When the hardware updates the table, it generates a
package-level thermal interrupt.
The size and format of the HFI table depend on the supported features and
can only be determined at runtime. To minimally initialize the HFI, parse
its features and allocate one instance per package of a data structure with
the necessary parameters to read and navigate individual HFI tables.
A subsequent changeset will provide per-CPU initialization and interrupt
handling.
Cc: Andi Kleen <redacted>
Cc: Aubrey Li <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Tim Chen <redacted>
Cc: "Ravi V. Shankar" <redacted>
Reviewed-by: Len Brown <redacted>
Co-developed by: Aubrey Li [off-list ref]
Signed-off-by: Aubrey Li <redacted>
Signed-off-by: Ricardo Neri <redacted>
---
drivers/thermal/intel/Kconfig | 12 +++
drivers/thermal/intel/Makefile | 1 +
drivers/thermal/intel/intel_hfi.c | 155 ++++++++++++++++++++++++++++
drivers/thermal/intel/intel_hfi.h | 34 ++++++
drivers/thermal/intel/therm_throt.c | 3 +
5 files changed, 205 insertions(+)
create mode 100644 drivers/thermal/intel/intel_hfi.c
create mode 100644 drivers/thermal/intel/intel_hfi.h
I'm not sure why this field is needed.
It looks like it is only checked by hfi_parse_features() which is only
called by intel_hfi_init() which is invoked by
thermal_throttle_init_device() which can happen only once if I'm not
mistaken.
+};
+
+static int max_hfi_instances;
+static struct hfi_instance *hfi_instances;
+
+static struct hfi_features hfi_features;
+
+static __init int hfi_parse_features(void)
+{
+ unsigned int nr_capabilities, reg;
+
+ if (!boot_cpu_has(X86_FEATURE_INTEL_HFI))
+ return -ENODEV;
+
+ if (hfi_features.parsed)
+ return 0;
+
+ /*
+ * If we are here we know that CPUID_HFI_LEAF exists. Parse the
+ * supported capabilities and the size of the HFI table.
+ */
+ reg = cpuid_edx(CPUID_HFI_LEAF);
+
+ hfi_features.capabilities = reg & HFI_CAPABILITIES_MASK;
+ if (!(hfi_features.capabilities & HFI_CAPABILITIES_PERFORMANCE)) {
+ pr_err("Performance reporting not supported! Not using HFI\n");
This doesn't need to be pr_err().
quoted hunk
+ return -ENODEV;
+ }
+
+ /* The number of 4KB pages required by the table */
+ hfi_features.nr_table_pages = ((reg & CPUID_HFI_TABLE_SIZE_MASK) >>
+ CPUID_HFI_TABLE_SIZE_SHIFT) + 1;
+
+ /*
+ * The number of supported capabilities determines the number of
+ * columns in the HFI table.
+ */
+ nr_capabilities = bitmap_weight(&hfi_features.capabilities,
+ HFI_CAPABILITIES_NR);
+
+ /*
+ * The header contains change indications for each supported feature.
+ * The size of the table header is rounded up to be a multiple of 8
+ * bytes.
+ */
+ hfi_features.hdr_size = DIV_ROUND_UP(nr_capabilities, 8) * 8;
+
+ /*
+ * Data of each logical processor is also rounded up to be a multiple
+ * of 8 bytes.
+ */
+ hfi_features.cpu_stride = DIV_ROUND_UP(nr_capabilities, 8) * 8;
+
+ hfi_features.parsed = true;
+ return 0;
+}
+
+void __init intel_hfi_init(void)
+{
+ if (hfi_parse_features())
+ return;
+
+ max_hfi_instances = topology_max_packages() *
+ topology_max_die_per_package();
+
+ /*
+ * This allocation may fail. CPU hotplug callbacks must check
+ * for a null pointer.
+ */
+ hfi_instances = kcalloc(max_hfi_instances, sizeof(*hfi_instances),
+ GFP_KERNEL);
+}
@@ -32,6 +32,7 @@#include<asm/irq.h>#include<asm/msr.h>+#include"intel_hfi.h"#include"thermal_interrupt.h"/* How long to wait between reporting thermal events */
@@ -509,6 +510,8 @@ static __init int thermal_throttle_init_device(void)if(!atomic_read(&therm_throt_en))return0;+intel_hfi_init();+ret=cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,"x86/therm:online",thermal_throttle_online,thermal_throttle_offline);--
On Wed, Nov 24, 2021 at 03:09:20PM +0100, Rafael J. Wysocki wrote:
On Sat, Nov 6, 2021 at 2:34 AM Ricardo Neri
[off-list ref] wrote:
quoted
The Intel Hardware Feedback Interface provides guidance to the operating
system about the performance and energy efficiency capabilities of each
CPU in the system. Capabilities are numbers between 0 and 255 where a
higher number represents a higher capability. For each CPU, energy
efficiency and performance are reported as separate capabilities.
Hardware computes these capabilities based on the operating conditions of
the system such as power and thermal limits. These capabilities are shared
with the operating system in a table resident in memory. Each package in
the system has its own HFI instance. Every logical CPU in the package is
represented in the table. More than one logical CPUs may be represented in
a single table entry. When the hardware updates the table, it generates a
package-level thermal interrupt.
The size and format of the HFI table depend on the supported features and
can only be determined at runtime. To minimally initialize the HFI, parse
its features and allocate one instance per package of a data structure with
the necessary parameters to read and navigate individual HFI tables.
A subsequent changeset will provide per-CPU initialization and interrupt
handling.
Cc: Andi Kleen <redacted>
Cc: Aubrey Li <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Tim Chen <redacted>
Cc: "Ravi V. Shankar" <redacted>
Reviewed-by: Len Brown <redacted>
Co-developed by: Aubrey Li [off-list ref]
Signed-off-by: Aubrey Li <redacted>
Signed-off-by: Ricardo Neri <redacted>
---
drivers/thermal/intel/Kconfig | 12 +++
drivers/thermal/intel/Makefile | 1 +
drivers/thermal/intel/intel_hfi.c | 155 ++++++++++++++++++++++++++++
drivers/thermal/intel/intel_hfi.h | 34 ++++++
drivers/thermal/intel/therm_throt.c | 3 +
5 files changed, 205 insertions(+)
create mode 100644 drivers/thermal/intel/intel_hfi.c
create mode 100644 drivers/thermal/intel/intel_hfi.h
I'm not sure why this field is needed.
It looks like it is only checked by hfi_parse_features() which is only
called by intel_hfi_init() which is invoked by
thermal_throttle_init_device() which can happen only once if I'm not
mistaken.
This is very true. It is not needed. I will remove it.
quoted
+};
+
+static int max_hfi_instances;
+static struct hfi_instance *hfi_instances;
+
+static struct hfi_features hfi_features;
+
+static __init int hfi_parse_features(void)
+{
+ unsigned int nr_capabilities, reg;
+
+ if (!boot_cpu_has(X86_FEATURE_INTEL_HFI))
+ return -ENODEV;
+
+ if (hfi_features.parsed)
+ return 0;
+
+ /*
+ * If we are here we know that CPUID_HFI_LEAF exists. Parse the
+ * supported capabilities and the size of the HFI table.
+ */
+ reg = cpuid_edx(CPUID_HFI_LEAF);
+
+ hfi_features.capabilities = reg & HFI_CAPABILITIES_MASK;
+ if (!(hfi_features.capabilities & HFI_CAPABILITIES_PERFORMANCE)) {
+ pr_err("Performance reporting not supported! Not using HFI\n");
This doesn't need to be pr_err().
Should it be a pr_warn() or perhaps pr_info()?
Thanks and BR,
Ricardo
On Mon, 2021-11-29 at 19:20 -0800, Ricardo Neri wrote:
On Wed, Nov 24, 2021 at 03:09:20PM +0100, Rafael J. Wysocki wrote:
quoted
On Sat, Nov 6, 2021 at 2:34 AM Ricardo Neri
[off-list ref] wrote:
quoted
The Intel Hardware Feedback Interface provides guidance to the
operating
system about the performance and energy efficiency capabilities
of each
CPU in the system. Capabilities are numbers between 0 and 255
where a
higher number represents a higher capability. For each CPU,
energy
efficiency and performance are reported as separate capabilities.
Hardware computes these capabilities based on the operating
conditions of
the system such as power and thermal limits. These capabilities
are shared
with the operating system in a table resident in memory. Each
package in
the system has its own HFI instance. Every logical CPU in the
package is
represented in the table. More than one logical CPUs may be
represented in
a single table entry. When the hardware updates the table, it
generates a
package-level thermal interrupt.
The size and format of the HFI table depend on the supported
features and
can only be determined at runtime. To minimally initialize the
HFI, parse
its features and allocate one instance per package of a data
structure with
the necessary parameters to read and navigate individual HFI
tables.
A subsequent changeset will provide per-CPU initialization and
interrupt
handling.
[...]
quoted
quoted
+ /*
+ * If we are here we know that CPUID_HFI_LEAF exists.
Parse the
+ * supported capabilities and the size of the HFI table.
+ */
+ reg = cpuid_edx(CPUID_HFI_LEAF);
+
+ hfi_features.capabilities = reg & HFI_CAPABILITIES_MASK;
+ if (!(hfi_features.capabilities &
HFI_CAPABILITIES_PERFORMANCE)) {
+ pr_err("Performance reporting not supported! Not
using HFI\n");
This doesn't need to be pr_err().
Should it be a pr_warn() or perhaps pr_info()?
May be even pr_debug as we can always enable dynamic debug, where we
need to debug.
Thanks,
Srinivas
On Mon, Nov 29, 2021 at 07:55:18PM -0800, Srinivas Pandruvada wrote:
On Mon, 2021-11-29 at 19:20 -0800, Ricardo Neri wrote:
quoted
On Wed, Nov 24, 2021 at 03:09:20PM +0100, Rafael J. Wysocki wrote:
quoted
On Sat, Nov 6, 2021 at 2:34 AM Ricardo Neri
[off-list ref] wrote:
quoted
The Intel Hardware Feedback Interface provides guidance to the
operating
system about the performance and energy efficiency capabilities
of each
CPU in the system. Capabilities are numbers between 0 and 255
where a
higher number represents a higher capability. For each CPU,
energy
efficiency and performance are reported as separate capabilities.
Hardware computes these capabilities based on the operating
conditions of
the system such as power and thermal limits. These capabilities
are shared
with the operating system in a table resident in memory. Each
package in
the system has its own HFI instance. Every logical CPU in the
package is
represented in the table. More than one logical CPUs may be
represented in
a single table entry. When the hardware updates the table, it
generates a
package-level thermal interrupt.
The size and format of the HFI table depend on the supported
features and
can only be determined at runtime. To minimally initialize the
HFI, parse
its features and allocate one instance per package of a data
structure with
the necessary parameters to read and navigate individual HFI
tables.
A subsequent changeset will provide per-CPU initialization and
interrupt
handling.
[...]
quoted
quoted
quoted
+ /*
+ * If we are here we know that CPUID_HFI_LEAF exists.
Parse the
+ * supported capabilities and the size of the HFI table.
+ */
+ reg = cpuid_edx(CPUID_HFI_LEAF);
+
+ hfi_features.capabilities = reg & HFI_CAPABILITIES_MASK;
+ if (!(hfi_features.capabilities &
HFI_CAPABILITIES_PERFORMANCE)) {
+ pr_err("Performance reporting not supported! Not
using HFI\n");
This doesn't need to be pr_err().
Should it be a pr_warn() or perhaps pr_info()?
May be even pr_debug as we can always enable dynamic debug, where we
need to debug.
Fair enough. That sounds good. I will make the change.
Thanks and BR,
Ricardo
All CPUs in a package are represented in an HFI table. There exists an
HFI table per package. Thus, CPUs in a package need to coordinate to
initialize and access the table. Do such coordination during CPU hotplug.
Use the first CPU to come online in a package to initialize the HFI table
and the data structure representing it. Other CPUs in the same package need
only to register or unregister themselves in that data structure.
The HFI depends on both the package-level thermal management and the local
APIC thermal local vector. Thus, ensure that both are properly configured
before calling intel_hfi_online(). The CPU hotplug callbacks of the thermal
throttle events code already meet these conditions. Enable the HFI from
thermal_throttle_online().
Cc: Andi Kleen <redacted>
Cc: Aubrey Li <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Tim Chen <redacted>
Cc: "Ravi V. Shankar" <redacted>
Reviewed-by: Len Brown <redacted>
Signed-off-by: Ricardo Neri <redacted>
---
drivers/thermal/intel/intel_hfi.c | 211 ++++++++++++++++++++++++++++
drivers/thermal/intel/intel_hfi.h | 4 +
drivers/thermal/intel/therm_throt.c | 8 ++
3 files changed, 223 insertions(+)
@@ -83,10 +94,210 @@ struct hfi_features {boolparsed;};+/**+*structhfi_cpu_info-Per-CPUattributestoconsumeHFIdata+*@index:RowofthisCPUinitsHFItable+*@hfi_instance:AttributesoftheHFItabletowhichthisCPUbelongs+*+*ParameterstolinkalogicalprocessortoanHFItableandarowwithinit.+*/+structhfi_cpu_info{+s16index;+structhfi_instance*hfi_instance;+};++staticDEFINE_PER_CPU(structhfi_cpu_info,hfi_cpu_info)={.index=-1};+staticintmax_hfi_instances;staticstructhfi_instance*hfi_instances;staticstructhfi_featureshfi_features;+staticDEFINE_MUTEX(hfi_lock);++staticvoidinit_hfi_cpu_index(unsignedintcpu)+{+s16hfi_idx;+u32edx;++/* Do not re-read @cpu's index if it has already been initialized. */+if(per_cpu(hfi_cpu_info,cpu).index>-1)+return;++edx=cpuid_edx(CPUID_HFI_LEAF);+hfi_idx=(edx&CPUID_HFI_CPU_INDEX_MASK)>>CPUID_HFI_CPU_INDEX_SHIFT;++per_cpu(hfi_cpu_info,cpu).index=hfi_idx;+}++/*+*TheformatoftheHFItabledependsonthenumberofcapabilitiesthatthe+*hardwaresupports.Keepadatastructuretonavigatethetable.+*/+staticvoidinit_hfi_instance(structhfi_instance*hfi_instance)+{+/* The HFI time-stamp is located at the base of the table. */+hfi_instance->ts_counter=hfi_instance->table_base;++/* The HFI header is below the time-stamp. */+hfi_instance->hdr=hfi_instance->table_base++sizeof(*hfi_instance->ts_counter);++/* The HFI data starts below the header. */+hfi_instance->data=hfi_instance->hdr+hfi_features.hdr_size;+}++/**+*intel_hfi_online()-EnableHFIon@cpu+*@cpu:CPUinwhichtheHFIwillbeenabled+*+*EnabletheHFItobeusedin@cpu.TheHFIisenabledatthedie/package+*level.ThefirstCPUinthedie/packagetocomeonlinedoesthefullHFI+*initialization.SubsequentCPUswilljustlinkthemselvestotheHFI+*instanceoftheirdie/package.+*/+voidintel_hfi_online(unsignedintcpu)+{+structhfi_cpu_info*info=&per_cpu(hfi_cpu_info,cpu);+u16die_id=topology_logical_die_id(cpu);+structhfi_instance*hfi_instance;+phys_addr_thw_table_pa;+u64msr_val;++if(!boot_cpu_has(X86_FEATURE_INTEL_HFI))+return;++init_hfi_cpu_index(cpu);++/*+*TheHFIinstanceofthis@cpumayexistalreadybuttheyhavenot+*beenlinkedto@cpu.+*/+hfi_instance=info->hfi_instance;+if(!hfi_instance){+if(!hfi_instances)+return;++if(die_id>=0&&die_id<max_hfi_instances)+hfi_instance=&hfi_instances[die_id];++if(!hfi_instance)+return;+}++/*+*NowcheckiftheHFIinstanceofthepackage/dieofthisCPUhas+*beeninitialized.Insuchcase,allwehavetodoislink@cpu'sinfo+*totheHFIinstanceofitsdie/package.+*/+mutex_lock(&hfi_lock);+if(hfi_instance->initialized){+info->hfi_instance=hfi_instance;++/*+*@cpuisthefirstoneinitsdie/packagetocomebackonline.+*UseittotracktheCPUsinthedie/package.+*/+if(!hfi_instance->cpus)+hfi_instance->cpus=topology_core_cpumask(cpu);++mutex_unlock(&hfi_lock);+return;+}++/*+*Hardwareisprogrammedwiththephysicaladdressofthefirstpage+*frameofthetable.Hence,theallocatedmemorymustbepage-aligned.+*/+hfi_instance->hw_table=alloc_pages_exact(hfi_features.nr_table_pages,+GFP_KERNEL|__GFP_ZERO);+if(!hfi_instance->hw_table)+gotoerr_out;++hw_table_pa=virt_to_phys(hfi_instance->hw_table);++hfi_instance->table_base=kzalloc(hfi_features.nr_table_pages<<PAGE_SHIFT,+GFP_KERNEL);+if(!hfi_instance->table_base)+gotofree_hw_table;++/*+*Programtheaddressofthefeedbacktableofthisdie/package.On+*someprocessors,hardwarerememberstheoldaddressoftheHFItable+*evenafterhavingbeenreprogrammedandre-enabled.Thus,donotfree+*pagesallocatedforthetableorreprogramthehardwarewithanew+*baseaddress.Namely,programthehardwareonlyonce.+*/+msr_val=hw_table_pa|HFI_PTR_VALID_BIT;+wrmsrl(MSR_IA32_HW_FEEDBACK_PTR,msr_val);++init_hfi_instance(hfi_instance);++hfi_instance->die_id=die_id;++/*+*Wecanusethecorecpumaskofanycpuinthedie/package.Anyof+*themwillreflectalltheCPUsthesamepackagethatareonline.+*/+hfi_instance->cpus=topology_core_cpumask(cpu);+info->hfi_instance=hfi_instance;+hfi_instance->initialized=true;++mutex_unlock(&hfi_lock);++return;++free_hw_table:+free_pages_exact(hfi_instance->hw_table,hfi_features.nr_table_pages);+err_out:+mutex_unlock(&hfi_lock);+}++/**+*intel_hfi_offline()-DisableHFIon@cpu+*@cpu:CPUinwhichtheHFIwillbedisabled+*+*Remove@cpufromthosecoveredbyitsHFIinstance.+*+*Onsomeprocessors,hardwarerememberspreviousprogrammingsettingseven+*afterbeingreprogrammed.Thus,keepHFIenabledevenifallCPUsinthe+*die/packageof@cpuareoffline.Seenoteinintel_hfi_online().+*/+voidintel_hfi_offline(unsignedintcpu)+{+structcpumask*die_cpumask=topology_core_cpumask(cpu);+structhfi_cpu_info*info=&per_cpu(hfi_cpu_info,cpu);+structhfi_instance*hfi_instance;++if(!boot_cpu_has(X86_FEATURE_INTEL_HFI))+return;++hfi_instance=info->hfi_instance;+if(!hfi_instance)+return;++if(!hfi_instance->initialized)+return;++mutex_lock(&hfi_lock);++/*+*Wewereusingthecorecpumaskof@cputotrackCPUsinthesame+*die/package.Nowitisgoingofflineandweneedtofindanother+*CPUwecanuse.+*/+if(die_cpumask==hfi_instance->cpus){+intnew_cpu;++new_cpu=cpumask_any_but(hfi_instance->cpus,cpu);+if(new_cpu>=nr_cpu_ids)+/* All other CPUs in the package are offline. */+hfi_instance->cpus=NULL;+else+hfi_instance->cpus=topology_core_cpumask(new_cpu);+}++mutex_unlock(&hfi_lock);+}static__initinthfi_parse_features(void){
@@ -480,6 +480,12 @@ static int thermal_throttle_online(unsigned int cpu)l=apic_read(APIC_LVTTHMR);apic_write(APIC_LVTTHMR,l&~APIC_LVT_MASKED);+/*+*Enablethepackage-levelHFIinterrupt.BynowthelocalAPICis+*readytogetthermalinterrupts.+*/+intel_hfi_online(cpu);+returnthermal_throttle_add_dev(dev,cpu);}
@@ -489,6 +495,8 @@ static int thermal_throttle_offline(unsigned int cpu)structdevice*dev=get_cpu_device(cpu);u32l;+intel_hfi_offline(cpu);+/* Mask the thermal vector before draining evtl. pending work */l=apic_read(APIC_LVTTHMR);apic_write(APIC_LVTTHMR,l|APIC_LVT_MASKED);
From: "Rafael J. Wysocki" <rafael@kernel.org> Date: 2021-11-24 14:49:17
On Sat, Nov 6, 2021 at 2:34 AM Ricardo Neri
[off-list ref] wrote:
quoted hunk
All CPUs in a package are represented in an HFI table. There exists an
HFI table per package. Thus, CPUs in a package need to coordinate to
initialize and access the table. Do such coordination during CPU hotplug.
Use the first CPU to come online in a package to initialize the HFI table
and the data structure representing it. Other CPUs in the same package need
only to register or unregister themselves in that data structure.
The HFI depends on both the package-level thermal management and the local
APIC thermal local vector. Thus, ensure that both are properly configured
before calling intel_hfi_online(). The CPU hotplug callbacks of the thermal
throttle events code already meet these conditions. Enable the HFI from
thermal_throttle_online().
Cc: Andi Kleen <redacted>
Cc: Aubrey Li <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Tim Chen <redacted>
Cc: "Ravi V. Shankar" <redacted>
Reviewed-by: Len Brown <redacted>
Signed-off-by: Ricardo Neri <redacted>
---
drivers/thermal/intel/intel_hfi.c | 211 ++++++++++++++++++++++++++++
drivers/thermal/intel/intel_hfi.h | 4 +
drivers/thermal/intel/therm_throt.c | 8 ++
3 files changed, 223 insertions(+)
I would make this function take a (struct hfi_cpu_info *) argument
instead of the CPU number. It would be more concise then.
+{
+ s16 hfi_idx;
+ u32 edx;
+
+ /* Do not re-read @cpu's index if it has already been initialized. */
+ if (per_cpu(hfi_cpu_info, cpu).index > -1)
+ return;
+
+ edx = cpuid_edx(CPUID_HFI_LEAF);
+ hfi_idx = (edx & CPUID_HFI_CPU_INDEX_MASK) >> CPUID_HFI_CPU_INDEX_SHIFT;
+
+ per_cpu(hfi_cpu_info, cpu).index = hfi_idx;
+}
+
+/*
+ * The format of the HFI table depends on the number of capabilities that the
+ * hardware supports. Keep a data structure to navigate the table.
+ */
+static void init_hfi_instance(struct hfi_instance *hfi_instance)
+{
+ /* The HFI time-stamp is located at the base of the table. */
+ hfi_instance->ts_counter = hfi_instance->table_base;
+
+ /* The HFI header is below the time-stamp. */
+ hfi_instance->hdr = hfi_instance->table_base +
+ sizeof(*hfi_instance->ts_counter);
+
+ /* The HFI data starts below the header. */
+ hfi_instance->data = hfi_instance->hdr + hfi_features.hdr_size;
+}
+
+/**
+ * intel_hfi_online() - Enable HFI on @cpu
+ * @cpu: CPU in which the HFI will be enabled
+ *
+ * Enable the HFI to be used in @cpu. The HFI is enabled at the die/package
+ * level. The first CPU in the die/package to come online does the full HFI
+ * initialization. Subsequent CPUs will just link themselves to the HFI
+ * instance of their die/package.
+ */
+void intel_hfi_online(unsigned int cpu)
+{
+ struct hfi_cpu_info *info = &per_cpu(hfi_cpu_info, cpu);
+ u16 die_id = topology_logical_die_id(cpu);
+ struct hfi_instance *hfi_instance;
+ phys_addr_t hw_table_pa;
+ u64 msr_val;
+
+ if (!boot_cpu_has(X86_FEATURE_INTEL_HFI))
+ return;
IMO it is not useful to do anything below in this function if
hfi_instances is NULL, so I would check it along with the above.
+
+ init_hfi_cpu_index(cpu);
+
+ /*
+ * The HFI instance of this @cpu may exist already but they have not
+ * been linked to @cpu.
+ */
+ hfi_instance = info->hfi_instance;
+ if (!hfi_instance) {
+ if (!hfi_instances)
+ return;
+
+ if (die_id >= 0 && die_id < max_hfi_instances)
+ hfi_instance = &hfi_instances[die_id];
+
+ if (!hfi_instance)
+ return;
And here I would do
if (die_id < 0 || die_id >= max_hfi_instances)
return;
hfi_instance = &hfi_instances[die_id];
which is one branch less and fewer LOC.
+ }
+
+ /*
+ * Now check if the HFI instance of the package/die of this CPU has
+ * been initialized. In such case, all we have to do is link @cpu's info
+ * to the HFI instance of its die/package.
+ */
+ mutex_lock(&hfi_lock);
+ if (hfi_instance->initialized) {
+ info->hfi_instance = hfi_instance;
+
+ /*
+ * @cpu is the first one in its die/package to come back online.
+ * Use it to track the CPUs in the die/package.
+ */
+ if (!hfi_instance->cpus)
+ hfi_instance->cpus = topology_core_cpumask(cpu);
+
+ mutex_unlock(&hfi_lock);
+ return;
+ }
+
+ /*
+ * Hardware is programmed with the physical address of the first page
+ * frame of the table. Hence, the allocated memory must be page-aligned.
+ */
+ hfi_instance->hw_table = alloc_pages_exact(hfi_features.nr_table_pages,
+ GFP_KERNEL | __GFP_ZERO);
+ if (!hfi_instance->hw_table)
+ goto err_out;
+
+ hw_table_pa = virt_to_phys(hfi_instance->hw_table);
+
+ hfi_instance->table_base = kzalloc(hfi_features.nr_table_pages << PAGE_SHIFT,
+ GFP_KERNEL);
+ if (!hfi_instance->table_base)
+ goto free_hw_table;
+
+ /*
+ * Program the address of the feedback table of this die/package. On
+ * some processors, hardware remembers the old address of the HFI table
+ * even after having been reprogrammed and re-enabled. Thus, do not free
+ * pages allocated for the table or reprogram the hardware with a new
+ * base address. Namely, program the hardware only once.
+ */
+ msr_val = hw_table_pa | HFI_PTR_VALID_BIT;
+ wrmsrl(MSR_IA32_HW_FEEDBACK_PTR, msr_val);
+
+ init_hfi_instance(hfi_instance);
+
+ hfi_instance->die_id = die_id;
+
+ /*
+ * We can use the core cpumask of any cpu in the die/package. Any of
+ * them will reflect all the CPUs the same package that are online.
+ */
+ hfi_instance->cpus = topology_core_cpumask(cpu);
+ info->hfi_instance = hfi_instance;
+ hfi_instance->initialized = true;
+
+ mutex_unlock(&hfi_lock);
+
+ return;
+
+free_hw_table:
+ free_pages_exact(hfi_instance->hw_table, hfi_features.nr_table_pages);
+err_out:
+ mutex_unlock(&hfi_lock);
+}
+
+/**
+ * intel_hfi_offline() - Disable HFI on @cpu
+ * @cpu: CPU in which the HFI will be disabled
+ *
+ * Remove @cpu from those covered by its HFI instance.
+ *
+ * On some processors, hardware remembers previous programming settings even
+ * after being reprogrammed. Thus, keep HFI enabled even if all CPUs in the
+ * die/package of @cpu are offline. See note in intel_hfi_online().
+ */
+void intel_hfi_offline(unsigned int cpu)
+{
+ struct cpumask *die_cpumask = topology_core_cpumask(cpu);
+ struct hfi_cpu_info *info = &per_cpu(hfi_cpu_info, cpu);
+ struct hfi_instance *hfi_instance;
+
+ if (!boot_cpu_has(X86_FEATURE_INTEL_HFI))
+ return;
+
+ hfi_instance = info->hfi_instance;
+ if (!hfi_instance)
+ return;
+
+ if (!hfi_instance->initialized)
+ return;
+
+ mutex_lock(&hfi_lock);
+
+ /*
+ * We were using the core cpumask of @cpu to track CPUs in the same
+ * die/package. Now it is going offline and we need to find another
+ * CPU we can use.
+ */
+ if (die_cpumask == hfi_instance->cpus) {
+ int new_cpu;
+
+ new_cpu = cpumask_any_but(hfi_instance->cpus, cpu);
+ if (new_cpu >= nr_cpu_ids)
+ /* All other CPUs in the package are offline. */
+ hfi_instance->cpus = NULL;
+ else
+ hfi_instance->cpus = topology_core_cpumask(new_cpu);
Hmmm. Is topology_core_cpumask() updated when CPUs go offline and online?
@@ -480,6 +480,12 @@ static int thermal_throttle_online(unsigned int cpu)l=apic_read(APIC_LVTTHMR);apic_write(APIC_LVTTHMR,l&~APIC_LVT_MASKED);+/*+*Enablethepackage-levelHFIinterrupt.BynowthelocalAPICis+*readytogetthermalinterrupts.+*/+intel_hfi_online(cpu);+returnthermal_throttle_add_dev(dev,cpu);}
@@ -489,6 +495,8 @@ static int thermal_throttle_offline(unsigned int cpu)structdevice*dev=get_cpu_device(cpu);u32l;+intel_hfi_offline(cpu);+/* Mask the thermal vector before draining evtl. pending work */l=apic_read(APIC_LVTTHMR);apic_write(APIC_LVTTHMR,l|APIC_LVT_MASKED);--
On Wed, Nov 24, 2021 at 03:48:49PM +0100, Rafael J. Wysocki wrote:
On Sat, Nov 6, 2021 at 2:34 AM Ricardo Neri
[off-list ref] wrote:
quoted
All CPUs in a package are represented in an HFI table. There exists an
HFI table per package. Thus, CPUs in a package need to coordinate to
initialize and access the table. Do such coordination during CPU hotplug.
Use the first CPU to come online in a package to initialize the HFI table
and the data structure representing it. Other CPUs in the same package need
only to register or unregister themselves in that data structure.
The HFI depends on both the package-level thermal management and the local
APIC thermal local vector. Thus, ensure that both are properly configured
before calling intel_hfi_online(). The CPU hotplug callbacks of the thermal
throttle events code already meet these conditions. Enable the HFI from
thermal_throttle_online().
Cc: Andi Kleen <redacted>
Cc: Aubrey Li <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Tim Chen <redacted>
Cc: "Ravi V. Shankar" <redacted>
Reviewed-by: Len Brown <redacted>
Signed-off-by: Ricardo Neri <redacted>
---
drivers/thermal/intel/intel_hfi.c | 211 ++++++++++++++++++++++++++++
drivers/thermal/intel/intel_hfi.h | 4 +
drivers/thermal/intel/therm_throt.c | 8 ++
3 files changed, 223 insertions(+)
I would make this function take a (struct hfi_cpu_info *) argument
instead of the CPU number. It would be more concise then.
Sure Rafael, it would be more concise. I will make the change.
quoted
+{
+ s16 hfi_idx;
+ u32 edx;
+
+ /* Do not re-read @cpu's index if it has already been initialized. */
+ if (per_cpu(hfi_cpu_info, cpu).index > -1)
+ return;
+
+ edx = cpuid_edx(CPUID_HFI_LEAF);
+ hfi_idx = (edx & CPUID_HFI_CPU_INDEX_MASK) >> CPUID_HFI_CPU_INDEX_SHIFT;
+
+ per_cpu(hfi_cpu_info, cpu).index = hfi_idx;
+}
+
+/*
+ * The format of the HFI table depends on the number of capabilities that the
+ * hardware supports. Keep a data structure to navigate the table.
+ */
+static void init_hfi_instance(struct hfi_instance *hfi_instance)
+{
+ /* The HFI time-stamp is located at the base of the table. */
+ hfi_instance->ts_counter = hfi_instance->table_base;
+
+ /* The HFI header is below the time-stamp. */
+ hfi_instance->hdr = hfi_instance->table_base +
+ sizeof(*hfi_instance->ts_counter);
+
+ /* The HFI data starts below the header. */
+ hfi_instance->data = hfi_instance->hdr + hfi_features.hdr_size;
+}
+
+/**
+ * intel_hfi_online() - Enable HFI on @cpu
+ * @cpu: CPU in which the HFI will be enabled
+ *
+ * Enable the HFI to be used in @cpu. The HFI is enabled at the die/package
+ * level. The first CPU in the die/package to come online does the full HFI
+ * initialization. Subsequent CPUs will just link themselves to the HFI
+ * instance of their die/package.
+ */
+void intel_hfi_online(unsigned int cpu)
+{
+ struct hfi_cpu_info *info = &per_cpu(hfi_cpu_info, cpu);
+ u16 die_id = topology_logical_die_id(cpu);
+ struct hfi_instance *hfi_instance;
+ phys_addr_t hw_table_pa;
+ u64 msr_val;
+
+ if (!boot_cpu_has(X86_FEATURE_INTEL_HFI))
+ return;
IMO it is not useful to do anything below in this function if
hfi_instances is NULL, so I would check it along with the above.
Indeed, there is no point on keep going it we didn't find memory for
hfi_instances. I will make the change.
quoted
+
+ init_hfi_cpu_index(cpu);
+
+ /*
+ * The HFI instance of this @cpu may exist already but they have not
+ * been linked to @cpu.
+ */
+ hfi_instance = info->hfi_instance;
+ if (!hfi_instance) {
+ if (!hfi_instances)
+ return;
+
+ if (die_id >= 0 && die_id < max_hfi_instances)
+ hfi_instance = &hfi_instances[die_id];
+
+ if (!hfi_instance)
+ return;
And here I would do
if (die_id < 0 || die_id >= max_hfi_instances)
return;
hfi_instance = &hfi_instances[die_id];
which is one branch less and fewer LOC.
Thanks Rafael, this looks better.
quoted
+ }
+
+ /*
+ * Now check if the HFI instance of the package/die of this CPU has
+ * been initialized. In such case, all we have to do is link @cpu's info
+ * to the HFI instance of its die/package.
+ */
+ mutex_lock(&hfi_lock);
+ if (hfi_instance->initialized) {
+ info->hfi_instance = hfi_instance;
+
+ /*
+ * @cpu is the first one in its die/package to come back online.
+ * Use it to track the CPUs in the die/package.
+ */
+ if (!hfi_instance->cpus)
+ hfi_instance->cpus = topology_core_cpumask(cpu);
+
+ mutex_unlock(&hfi_lock);
+ return;
+ }
+
+ /*
+ * Hardware is programmed with the physical address of the first page
+ * frame of the table. Hence, the allocated memory must be page-aligned.
+ */
+ hfi_instance->hw_table = alloc_pages_exact(hfi_features.nr_table_pages,
+ GFP_KERNEL | __GFP_ZERO);
+ if (!hfi_instance->hw_table)
+ goto err_out;
+
+ hw_table_pa = virt_to_phys(hfi_instance->hw_table);
+
+ hfi_instance->table_base = kzalloc(hfi_features.nr_table_pages << PAGE_SHIFT,
+ GFP_KERNEL);
+ if (!hfi_instance->table_base)
+ goto free_hw_table;
+
+ /*
+ * Program the address of the feedback table of this die/package. On
+ * some processors, hardware remembers the old address of the HFI table
+ * even after having been reprogrammed and re-enabled. Thus, do not free
+ * pages allocated for the table or reprogram the hardware with a new
+ * base address. Namely, program the hardware only once.
+ */
+ msr_val = hw_table_pa | HFI_PTR_VALID_BIT;
+ wrmsrl(MSR_IA32_HW_FEEDBACK_PTR, msr_val);
+
+ init_hfi_instance(hfi_instance);
+
+ hfi_instance->die_id = die_id;
+
+ /*
+ * We can use the core cpumask of any cpu in the die/package. Any of
+ * them will reflect all the CPUs the same package that are online.
+ */
+ hfi_instance->cpus = topology_core_cpumask(cpu);
+ info->hfi_instance = hfi_instance;
+ hfi_instance->initialized = true;
+
+ mutex_unlock(&hfi_lock);
+
+ return;
+
+free_hw_table:
+ free_pages_exact(hfi_instance->hw_table, hfi_features.nr_table_pages);
+err_out:
+ mutex_unlock(&hfi_lock);
+}
+
+/**
+ * intel_hfi_offline() - Disable HFI on @cpu
+ * @cpu: CPU in which the HFI will be disabled
+ *
+ * Remove @cpu from those covered by its HFI instance.
+ *
+ * On some processors, hardware remembers previous programming settings even
+ * after being reprogrammed. Thus, keep HFI enabled even if all CPUs in the
+ * die/package of @cpu are offline. See note in intel_hfi_online().
+ */
+void intel_hfi_offline(unsigned int cpu)
+{
+ struct cpumask *die_cpumask = topology_core_cpumask(cpu);
+ struct hfi_cpu_info *info = &per_cpu(hfi_cpu_info, cpu);
+ struct hfi_instance *hfi_instance;
+
+ if (!boot_cpu_has(X86_FEATURE_INTEL_HFI))
+ return;
+
+ hfi_instance = info->hfi_instance;
+ if (!hfi_instance)
+ return;
+
+ if (!hfi_instance->initialized)
+ return;
+
+ mutex_lock(&hfi_lock);
+
+ /*
+ * We were using the core cpumask of @cpu to track CPUs in the same
+ * die/package. Now it is going offline and we need to find another
+ * CPU we can use.
+ */
+ if (die_cpumask == hfi_instance->cpus) {
+ int new_cpu;
+
+ new_cpu = cpumask_any_but(hfi_instance->cpus, cpu);
+ if (new_cpu >= nr_cpu_ids)
+ /* All other CPUs in the package are offline. */
+ hfi_instance->cpus = NULL;
+ else
+ hfi_instance->cpus = topology_core_cpumask(new_cpu);
Hmmm. Is topology_core_cpumask() updated when CPUs go offline and online?
From: "Rafael J. Wysocki" <rafael@kernel.org> Date: 2021-11-30 13:33:01
On Tue, Nov 30, 2021 at 2:22 PM Ricardo Neri
[off-list ref] wrote:
On Wed, Nov 24, 2021 at 03:48:49PM +0100, Rafael J. Wysocki wrote:
quoted
On Sat, Nov 6, 2021 at 2:34 AM Ricardo Neri
[off-list ref] wrote:
[cut]
quoted
quoted
+/**
+ * intel_hfi_offline() - Disable HFI on @cpu
+ * @cpu: CPU in which the HFI will be disabled
+ *
+ * Remove @cpu from those covered by its HFI instance.
+ *
+ * On some processors, hardware remembers previous programming settings even
+ * after being reprogrammed. Thus, keep HFI enabled even if all CPUs in the
+ * die/package of @cpu are offline. See note in intel_hfi_online().
+ */
+void intel_hfi_offline(unsigned int cpu)
+{
+ struct cpumask *die_cpumask = topology_core_cpumask(cpu);
+ struct hfi_cpu_info *info = &per_cpu(hfi_cpu_info, cpu);
+ struct hfi_instance *hfi_instance;
+
+ if (!boot_cpu_has(X86_FEATURE_INTEL_HFI))
+ return;
+
+ hfi_instance = info->hfi_instance;
+ if (!hfi_instance)
+ return;
+
+ if (!hfi_instance->initialized)
+ return;
+
+ mutex_lock(&hfi_lock);
+
+ /*
+ * We were using the core cpumask of @cpu to track CPUs in the same
+ * die/package. Now it is going offline and we need to find another
+ * CPU we can use.
+ */
+ if (die_cpumask == hfi_instance->cpus) {
+ int new_cpu;
+
+ new_cpu = cpumask_any_but(hfi_instance->cpus, cpu);
+ if (new_cpu >= nr_cpu_ids)
+ /* All other CPUs in the package are offline. */
+ hfi_instance->cpus = NULL;
+ else
+ hfi_instance->cpus = topology_core_cpumask(new_cpu);
Hmmm. Is topology_core_cpumask() updated when CPUs go offline and online?
Yes. A CPU going offline is cleared from its siblings' cpumask [1] and its own [2]
in remove_siblinginfo() via cpu_disable_common(). A CPU going online is set
in its siblings' cpumask and its own in set_cpu_sibling_map() [3].
OK, so it is necessary to ensure that intel_hfi_offline() will always
run after remove_siblinginfo() so it sees the updated mask. How do we
ensure that?
On Tue, Nov 30, 2021 at 02:32:42PM +0100, Rafael J. Wysocki wrote:
On Tue, Nov 30, 2021 at 2:22 PM Ricardo Neri
[off-list ref] wrote:
quoted
On Wed, Nov 24, 2021 at 03:48:49PM +0100, Rafael J. Wysocki wrote:
quoted
On Sat, Nov 6, 2021 at 2:34 AM Ricardo Neri
[off-list ref] wrote:
[cut]
quoted
quoted
quoted
+/**
+ * intel_hfi_offline() - Disable HFI on @cpu
+ * @cpu: CPU in which the HFI will be disabled
+ *
+ * Remove @cpu from those covered by its HFI instance.
+ *
+ * On some processors, hardware remembers previous programming settings even
+ * after being reprogrammed. Thus, keep HFI enabled even if all CPUs in the
+ * die/package of @cpu are offline. See note in intel_hfi_online().
+ */
+void intel_hfi_offline(unsigned int cpu)
+{
+ struct cpumask *die_cpumask = topology_core_cpumask(cpu);
+ struct hfi_cpu_info *info = &per_cpu(hfi_cpu_info, cpu);
+ struct hfi_instance *hfi_instance;
+
+ if (!boot_cpu_has(X86_FEATURE_INTEL_HFI))
+ return;
+
+ hfi_instance = info->hfi_instance;
+ if (!hfi_instance)
+ return;
+
+ if (!hfi_instance->initialized)
+ return;
+
+ mutex_lock(&hfi_lock);
+
+ /*
+ * We were using the core cpumask of @cpu to track CPUs in the same
+ * die/package. Now it is going offline and we need to find another
+ * CPU we can use.
+ */
+ if (die_cpumask == hfi_instance->cpus) {
+ int new_cpu;
+
+ new_cpu = cpumask_any_but(hfi_instance->cpus, cpu);
+ if (new_cpu >= nr_cpu_ids)
+ /* All other CPUs in the package are offline. */
+ hfi_instance->cpus = NULL;
+ else
+ hfi_instance->cpus = topology_core_cpumask(new_cpu);
Hmmm. Is topology_core_cpumask() updated when CPUs go offline and online?
Yes. A CPU going offline is cleared from its siblings' cpumask [1] and its own [2]
in remove_siblinginfo() via cpu_disable_common(). A CPU going online is set
in its siblings' cpumask and its own in set_cpu_sibling_map() [3].
OK, so it is necessary to ensure that intel_hfi_offline() will always
run after remove_siblinginfo() so it sees the updated mask. How do we
ensure that?
I don't think that is possible. remove_siblinginfo() is called from
CPUHP_TEARDOWN_CPU, which always happens after CPUHP_AP_OFFLINE, if I
understand correctly.
I guess that I will need to use a local cpumask as other drivers do.
Thanks and BR,
Ricardo
When hardware wants to inform the operating system about updates in the HFI
table, it issues a package-level thermal event interrupt. For this,
hardware has new interrupt and status bits in the IA32_PACKAGE_THERM_
INTERRUPT and IA32_PACKAGE_THERM_STATUS registers. The existing thermal
throttle driver already handles thermal event interrupts: it initializes
the thermal vector of the local APIC as well as per-CPU and package-level
interrupt reporting. It also provides routines to service such interrupts.
Extend its functionality to also handle HFI interrupts.
The frequency of the thermal HFI interrupt is specific to each processor
model. On some processors, a single interrupt happens as soon as the HFI is
enabled and hardware will never update HFI capabilities afterwards. On
other processors, thermal and power constraints may cause thermal HFI
interrupts every tens of milliseconds.
To not overwhelm consumers of the HFI data, use delayed work to throttle
the rate at which HFI updates are processed.
Cc: Andi Kleen <redacted>
Cc: Aubrey Li <redacted>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Tim Chen <redacted>
Cc: "Ravi V. Shankar" <redacted>
Reviewed-by: Len Brown <redacted>
Signed-off-by: Ricardo Neri <redacted>
---
drivers/thermal/intel/intel_hfi.c | 89 +++++++++++++++++++++++++++++
drivers/thermal/intel/intel_hfi.h | 2 +
drivers/thermal/intel/therm_throt.c | 10 ++++
3 files changed, 101 insertions(+)
From: Peter Zijlstra <peterz@infradead.org> Date: 2021-11-08 09:01:18
On Fri, Nov 05, 2021 at 06:33:10PM -0700, Ricardo Neri wrote:
+ /*
+ * On most systems, all CPUs in the package receive a package-level
+ * thermal interrupt when there is an HFI update. Since they all are
+ * dealing with the same update (as indicated by the update timestamp),
+ * it is sufficient to let a single CPU to acknowledge the update and
+ * schedule work to process it.
+ */
That's pretty crap hardware behaviour. Is there really no way to steer
these interrupts?
On Mon, Nov 08, 2021 at 10:01:04AM +0100, Peter Zijlstra wrote:
On Fri, Nov 05, 2021 at 06:33:10PM -0700, Ricardo Neri wrote:
quoted
+ /*
+ * On most systems, all CPUs in the package receive a package-level
+ * thermal interrupt when there is an HFI update. Since they all are
+ * dealing with the same update (as indicated by the update timestamp),
+ * it is sufficient to let a single CPU to acknowledge the update and
+ * schedule work to process it.
+ */
That's pretty crap hardware behaviour. Is there really no way to steer
these interrupts?
The HFI is a package-level thermal interrupt. Hence, all CPUs get it.
AFAIK there is no way to steer the interrupts.
Thanks and BR,
Ricardo
// this here uses ->event_lock to serialize against the
// interrupt below changing the data...
+}
+
+void intel_hfi_process_event(__u64 pkg_therm_status_msr_val)
+{
+ struct hfi_instance *hfi_instance;
+ int cpu = smp_processor_id();
+ struct hfi_cpu_info *info;
+ unsigned long flags;
+ u64 timestamp;
+
+ if (!pkg_therm_status_msr_val)
+ return;
+
+ info = &per_cpu(hfi_cpu_info, cpu);
+ if (!info)
+ return;
+
+ /*
+ * It is possible that we get an HFI thermal interrupt on this CPU
+ * before its HFI instance is initialized. This is not a problem. The
+ * CPU that enabled the interrupt for this package will also get the
+ * interrupt and is fully initialized.
+ */
+ hfi_instance = info->hfi_instance;
+ if (!hfi_instance)
+ return;
+
/*
* If someone is already handling the interrupt, we shouldn't be
* burning time waiting for them to then do more nothing.
*/
if (!raw_spin_trylock(&hfi_instance->interrupt_lock))
return;
+ raw_spin_lock_irqsave(&hfi_instance->event_lock, flags);
+
+ /*
+ * On most systems, all CPUs in the package receive a package-level
+ * thermal interrupt when there is an HFI update. Since they all are
+ * dealing with the same update (as indicated by the update timestamp),
+ * it is sufficient to let a single CPU to acknowledge the update and
+ * schedule work to process it.
+ */
+ timestamp = *(u64 *)hfi_instance->hw_table;
+ if (hfi_instance->timestamp >= timestamp)
+ goto unlock_spinlock;
This can go the way of the dodo.
+
+ hfi_instance->timestamp = timestamp;
+
+ memcpy(hfi_instance->table_base, hfi_instance->hw_table,
+ hfi_features.nr_table_pages << PAGE_SHIFT);
+ /*
+ * Let hardware and other CPUs know that we are done reading the HFI
+ * table and it is free to update it again.
+ */
+ pkg_therm_status_msr_val &= THERM_STATUS_CLEAR_PKG_MASK &
+ ~PACKAGE_THERM_STATUS_HFI_UPDATED;
+ wrmsrl(MSR_IA32_PACKAGE_THERM_STATUS, pkg_therm_status_msr_val);
+ schedule_delayed_work(&hfi_instance->update_work, HFI_UPDATE_INTERVAL);
+
+unlock_spinlock:
+ raw_spin_unlock_irqrestore(&hfi_instance->event_lock, flags);
Thank you very much for your feedback Peter!
I would like to confirm that I understand your feedback correctly: you are
suggesting to use to spinlocks...
// this here uses ->event_lock to serialize against the
// interrupt below changing the data...
Anyone reading the HFI table would need to take ->event_lock.
quoted
+}
+
+void intel_hfi_process_event(__u64 pkg_therm_status_msr_val)
+{
+ struct hfi_instance *hfi_instance;
+ int cpu = smp_processor_id();
+ struct hfi_cpu_info *info;
+ unsigned long flags;
+ u64 timestamp;
+
+ if (!pkg_therm_status_msr_val)
+ return;
+
+ info = &per_cpu(hfi_cpu_info, cpu);
+ if (!info)
+ return;
+
+ /*
+ * It is possible that we get an HFI thermal interrupt on this CPU
+ * before its HFI instance is initialized. This is not a problem. The
+ * CPU that enabled the interrupt for this package will also get the
+ * interrupt and is fully initialized.
+ */
+ hfi_instance = info->hfi_instance;
+ if (!hfi_instance)
+ return;
+
/*
* If someone is already handling the interrupt, we shouldn't be
* burning time waiting for them to then do more nothing.
*/
if (!raw_spin_trylock(&hfi_instance->interrupt_lock))
return;
The CPU who acquired ->interrupt_lock successfully now will acquire
->event_lock to serialize writes and reads to the HFI table.
quoted
+
+ /*
+ * On most systems, all CPUs in the package receive a package-level
+ * thermal interrupt when there is an HFI update. Since they all are
+ * dealing with the same update (as indicated by the update timestamp),
+ * it is sufficient to let a single CPU to acknowledge the update and
+ * schedule work to process it.
+ */
+ timestamp = *(u64 *)hfi_instance->hw_table;
+ if (hfi_instance->timestamp >= timestamp)
+ goto unlock_spinlock;
This can go the way of the dodo.
(I guess I can still check the timestamp in case buggy firmware triggers
updates with the same timestamp, right?)
quoted
+
+ hfi_instance->timestamp = timestamp;
+
+ memcpy(hfi_instance->table_base, hfi_instance->hw_table,
+ hfi_features.nr_table_pages << PAGE_SHIFT);
+ /*
+ * Let hardware and other CPUs know that we are done reading the HFI
+ * table and it is free to update it again.
+ */
+ pkg_therm_status_msr_val &= THERM_STATUS_CLEAR_PKG_MASK &
+ ~PACKAGE_THERM_STATUS_HFI_UPDATED;
+ wrmsrl(MSR_IA32_PACKAGE_THERM_STATUS, pkg_therm_status_msr_val);
+ schedule_delayed_work(&hfi_instance->update_work, HFI_UPDATE_INTERVAL);
+
+unlock_spinlock:
+ raw_spin_unlock_irqrestore(&hfi_instance->event_lock, flags);
raw_spin_unlock(&hfi_instance->interrupt_lock);
... and here we release both locks.
Thanks and BR,
Ricardo
// this here uses ->event_lock to serialize against the
// interrupt below changing the data...
Anyone reading the HFI table would need to take ->event_lock.
Right.. that implies ->event_lock can be taken while there is no
interrupt active, which then necessitates the additional lock.
quoted
quoted
+}
+
+void intel_hfi_process_event(__u64 pkg_therm_status_msr_val)
+{
+ struct hfi_instance *hfi_instance;
+ int cpu = smp_processor_id();
+ struct hfi_cpu_info *info;
+ unsigned long flags;
+ u64 timestamp;
+
+ if (!pkg_therm_status_msr_val)
+ return;
+
+ info = &per_cpu(hfi_cpu_info, cpu);
+ if (!info)
+ return;
+
+ /*
+ * It is possible that we get an HFI thermal interrupt on this CPU
+ * before its HFI instance is initialized. This is not a problem. The
+ * CPU that enabled the interrupt for this package will also get the
+ * interrupt and is fully initialized.
+ */
+ hfi_instance = info->hfi_instance;
+ if (!hfi_instance)
+ return;
+
/*
* If someone is already handling the interrupt, we shouldn't be
* burning time waiting for them to then do more nothing.
*/
if (!raw_spin_trylock(&hfi_instance->interrupt_lock))
return;
The CPU who acquired ->interrupt_lock successfully now will acquire
->event_lock to serialize writes and reads to the HFI table.
Right, so ->interrupt_lock is purely used to serialize interrupts, and
only one interrupt gets to do the update, while the others can exit and
resume with what they were doing asap, without wasting cycles spinning
on ->event_lock only to then not do anything.
quoted
quoted
+ /*
+ * On most systems, all CPUs in the package receive a package-level
+ * thermal interrupt when there is an HFI update. Since they all are
+ * dealing with the same update (as indicated by the update timestamp),
+ * it is sufficient to let a single CPU to acknowledge the update and
+ * schedule work to process it.
+ */
+ timestamp = *(u64 *)hfi_instance->hw_table;
+ if (hfi_instance->timestamp >= timestamp)
+ goto unlock_spinlock;
This can go the way of the dodo.
(I guess I can still check the timestamp in case buggy firmware triggers
updates with the same timestamp, right?)
I think we actually need to release ->interrupt_lock here, *before* the
WRMSR that ACKs the HFI update. Because I think the moment that WRMSR
goes through we can get another interrupt, and that *must* not find
->interrupt_lock taken, otherwise it will not process the update etc..
leading to lost interrupts.
quoted
quoted
+ /*
+ * Let hardware and other CPUs know that we are done reading the HFI
+ * table and it is free to update it again.
+ */
+ pkg_therm_status_msr_val &= THERM_STATUS_CLEAR_PKG_MASK &
+ ~PACKAGE_THERM_STATUS_HFI_UPDATED;
+ wrmsrl(MSR_IA32_PACKAGE_THERM_STATUS, pkg_therm_status_msr_val);
+ schedule_delayed_work(&hfi_instance->update_work, HFI_UPDATE_INTERVAL);
+
+unlock_spinlock:
+ raw_spin_unlock_irqrestore(&hfi_instance->event_lock, flags);
// this here uses ->event_lock to serialize against the
// interrupt below changing the data...
Anyone reading the HFI table would need to take ->event_lock.
Right.. that implies ->event_lock can be taken while there is no
interrupt active, which then necessitates the additional lock.
Correct.
With the raw_spin_trylock() optimization, we will need additional lock.
So need another lock to protect hfi_instance->table_base.
quoted
quoted
quoted
+}
+
+void intel_hfi_process_event(__u64 pkg_therm_status_msr_val)
+{
+ struct hfi_instance *hfi_instance;
+ int cpu = smp_processor_id();
+ struct hfi_cpu_info *info;
+ unsigned long flags;
+ u64 timestamp;
+
+ if (!pkg_therm_status_msr_val)
+ return;
+
+ info = &per_cpu(hfi_cpu_info, cpu);
+ if (!info)
+ return;
[...]
quoted
quoted
quoted
+ memcpy(hfi_instance->table_base, hfi_instance-
quoted
hw_table,
+ hfi_features.nr_table_pages << PAGE_SHIFT);
I think we actually need to release ->interrupt_lock here, *before*
the
WRMSR that ACKs the HFI update. Because I think the moment that WRMSR
goes through we can get another interrupt, and that *must* not find
->interrupt_lock taken, otherwise it will not process the update
etc..
leading to lost interrupts.
Correct.
Once we use raw_spin_trylock() change suggested above, then we need to
release lock here.
Thanks,
Srinivas
quoted
quoted
quoted
+ /*
+ * Let hardware and other CPUs know that we are done
reading the HFI
+ * table and it is free to update it again.
+ */
+ pkg_therm_status_msr_val &= THERM_STATUS_CLEAR_PKG_MASK
&
+
~PACKAGE_THERM_STATUS_HFI_UPDATED;
+ wrmsrl(MSR_IA32_PACKAGE_THERM_STATUS,
pkg_therm_status_msr_val);
+ schedule_delayed_work(&hfi_instance->update_work,
HFI_UPDATE_INTERVAL);
+
+unlock_spinlock:
+ raw_spin_unlock_irqrestore(&hfi_instance->event_lock,
flags);
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
When the hardware issues an HFI event, relay a notification to user space.
This allows user space to respond by reading performance and efficiency of
each CPU and take appropriate action.
For example, when performance and efficiency of a CPU is 0, user space can
either offline the CPU or inject idle. Also, if user space notices a
downward trend in performance, it may proactively adjust power limits to
avoid future situations in which performance drops to 0.
To avoid excessive notifications, the rate is limited by one HZ per event.
To limit netlink message size, parameters for only 16 CPUs at max are sent
in one message. If there are more than 16 CPUs, issue as many messages as
needed to notify the status of all CPUs.
Cc: Andi Kleen <redacted>
Cc: Aubrey Li <redacted>
Cc: Tim Chen <redacted>
Cc: "Ravi V. Shankar" <redacted>
Reviewed-by: Len Brown <redacted>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/thermal/intel/Kconfig | 1 +
drivers/thermal/intel/intel_hfi.c | 55 ++++++++++++++++++++++++++++++-
2 files changed, 55 insertions(+), 1 deletion(-)
From: "Rafael J. Wysocki" <rafael@kernel.org> Date: 2021-11-24 15:19:08
On Sat, Nov 6, 2021 at 2:34 AM Ricardo Neri
[off-list ref] wrote:
quoted hunk
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
When the hardware issues an HFI event, relay a notification to user space.
This allows user space to respond by reading performance and efficiency of
each CPU and take appropriate action.
For example, when performance and efficiency of a CPU is 0, user space can
either offline the CPU or inject idle. Also, if user space notices a
downward trend in performance, it may proactively adjust power limits to
avoid future situations in which performance drops to 0.
To avoid excessive notifications, the rate is limited by one HZ per event.
To limit netlink message size, parameters for only 16 CPUs at max are sent
in one message. If there are more than 16 CPUs, issue as many messages as
needed to notify the status of all CPUs.
Cc: Andi Kleen <redacted>
Cc: Aubrey Li <redacted>
Cc: Tim Chen <redacted>
Cc: "Ravi V. Shankar" <redacted>
Reviewed-by: Len Brown <redacted>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/thermal/intel/Kconfig | 1 +
drivers/thermal/intel/intel_hfi.c | 55 ++++++++++++++++++++++++++++++-
2 files changed, 55 insertions(+), 1 deletion(-)
On Wed, 2021-11-24 at 16:18 +0100, Rafael J. Wysocki wrote:
On Sat, Nov 6, 2021 at 2:34 AM Ricardo Neri
[off-list ref] wrote:
quoted
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
When the hardware issues an HFI event, relay a notification to user
space.
This allows user space to respond by reading performance and
efficiency of
each CPU and take appropriate action.
For example, when performance and efficiency of a CPU is 0, user
space can
either offline the CPU or inject idle. Also, if user space notices
a
downward trend in performance, it may proactively adjust power
limits to
avoid future situations in which performance drops to 0.
To avoid excessive notifications, the rate is limited by one HZ per
event.
To limit netlink message size, parameters for only 16 CPUs at max
are sent
in one message. If there are more than 16 CPUs, issue as many
messages as
needed to notify the status of all CPUs.
Cc: Andi Kleen <redacted>
Cc: Aubrey Li <redacted>
Cc: Tim Chen <redacted>
Cc: "Ravi V. Shankar" <redacted>
Reviewed-by: Len Brown <redacted>
Signed-off-by: Srinivas Pandruvada <
srinivas.pandruvada@linux.intel.com>
---
drivers/thermal/intel/Kconfig | 1 +
drivers/thermal/intel/intel_hfi.c | 55
++++++++++++++++++++++++++++++-
2 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/intel/Kconfig
b/drivers/thermal/intel/Kconfig
index d4c6bdcacddb..b6a1f777b8e7 100644
bool "Intel Hardware Feedback Interface"
depends on CPU_SUP_INTEL
depends on SCHED_MC && X86_THERMAL_VECTOR
+ select THERMAL_NETLINK
help
Select this option to enable the Hardware Feedback
Interface. If
selected, hardware provides guidance to the operating
system on
diff --git a/drivers/thermal/intel/intel_hfi.c
b/drivers/thermal/intel/intel_hfi.c
index 1df24b39f2e6..c669a037704e 100644
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Add a new netlink event to notify change in CPU capabilities in terms of
performance and efficiency.
Firmware may change CPU capabilities as a result of thermal events in the
system or to account for changes in the TDP (thermal design power) level.
This notification type will allow user space to avoid running workloads
on certain CPUs or proactively adjust power limits to avoid future events.
Cc: Andi Kleen <redacted>
Cc: Aubrey Li <redacted>
Cc: Tim Chen <redacted>
Cc: "Ravi V. Shankar" <redacted>
Reviewed-by: Len Brown <redacted>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/thermal/thermal_netlink.c | 52 +++++++++++++++++++++++++++++++
drivers/thermal/thermal_netlink.h | 13 ++++++++
include/uapi/linux/thermal.h | 6 +++-
3 files changed, 70 insertions(+), 1 deletion(-)
From: Lukasz Luba <lukasz.luba@arm.com> Date: 2021-11-09 12:39:48
Hi Ricardo,
On 11/6/21 1:33 AM, Ricardo Neri wrote:
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Add a new netlink event to notify change in CPU capabilities in terms of
performance and efficiency.
Is this going to be handled by some 'generic' tools? If yes, maybe
the values for 'performance' might be aligned with capacity
[0,1024] ? Or are they completely not related so the mapping is
simply impossible?
Firmware may change CPU capabilities as a result of thermal events in the
system or to account for changes in the TDP (thermal design power) level.
This notification type will allow user space to avoid running workloads
on certain CPUs or proactively adjust power limits to avoid future events.
Cc: Andi Kleen <redacted>
Cc: Aubrey Li <redacted>
Cc: Tim Chen <redacted>
Cc: "Ravi V. Shankar" <redacted>
Reviewed-by: Len Brown <redacted>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/thermal/thermal_netlink.c | 52 +++++++++++++++++++++++++++++++
drivers/thermal/thermal_netlink.h | 13 ++++++++
include/uapi/linux/thermal.h | 6 +++-
3 files changed, 70 insertions(+), 1 deletion(-)
[snip]
+struct cpu_capability {
+ int cpu;
+ int perf;
+ int eff;
Why not use the full names, instead of thse shortcuts? We use full
naming e.g. in cpufreq framework such as 'frequency' not 'freq'.
The 'eff' is really not meaningful ('perf' a bit less but it has
to meanings in kernel).
Regards,
Lukasz
Hi Lukasz,
On Tue, 2021-11-09 at 12:39 +0000, Lukasz Luba wrote:
Hi Ricardo,
On 11/6/21 1:33 AM, Ricardo Neri wrote:
quoted
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Add a new netlink event to notify change in CPU capabilities in
terms of
performance and efficiency.
Is this going to be handled by some 'generic' tools? If yes, maybe
the values for 'performance' might be aligned with capacity
[0,1024] ? Or are they completely not related so the mapping is
simply impossible?
That would have been very useful.
The problem is that we may not know the maximum performance as system
may be booting with few CPUs (using maxcpus kernel command line) and
then user hot adding them. So we may need to rescale when we get a new
maximum performance CPU and send to user space.
We can't just use max from HFI table at in instance as it is not
necessary that HFI table contains data for all CPUs.
If HFI max performance value of 255 is a scaled value to max
performance CPU value in the system, then this conversion would have
been easy. But that is not.
quoted
Firmware may change CPU capabilities as a result of thermal events
in the
system or to account for changes in the TDP (thermal design power)
level.
This notification type will allow user space to avoid running
workloads
on certain CPUs or proactively adjust power limits to avoid future
events.
Cc: Andi Kleen <redacted>
Cc: Aubrey Li <redacted>
Cc: Tim Chen <redacted>
Cc: "Ravi V. Shankar" <redacted>
Reviewed-by: Len Brown <redacted>
Signed-off-by: Srinivas Pandruvada <
srinivas.pandruvada@linux.intel.com>
---
drivers/thermal/thermal_netlink.c | 52
+++++++++++++++++++++++++++++++
drivers/thermal/thermal_netlink.h | 13 ++++++++
include/uapi/linux/thermal.h | 6 +++-
3 files changed, 70 insertions(+), 1 deletion(-)
[snip]
quoted
+struct cpu_capability {
+ int cpu;
+ int perf;
+ int eff;
Good idea.
Thanks,
Srinivas
Why not use the full names, instead of thse shortcuts? We use full
naming e.g. in cpufreq framework such as 'frequency' not 'freq'.
The 'eff' is really not meaningful ('perf' a bit less but it has
to meanings in kernel).
Regards,
Lukasz
From: Lukasz Luba <lukasz.luba@arm.com> Date: 2021-11-09 13:53:42
Hi Srinivas,
On 11/9/21 1:23 PM, Srinivas Pandruvada wrote:
Hi Lukasz,
On Tue, 2021-11-09 at 12:39 +0000, Lukasz Luba wrote:
quoted
Hi Ricardo,
On 11/6/21 1:33 AM, Ricardo Neri wrote:
quoted
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Add a new netlink event to notify change in CPU capabilities in
terms of
performance and efficiency.
Is this going to be handled by some 'generic' tools? If yes, maybe
the values for 'performance' might be aligned with capacity
[0,1024] ? Or are they completely not related so the mapping is
simply impossible?
That would have been very useful.
The problem is that we may not know the maximum performance as system
may be booting with few CPUs (using maxcpus kernel command line) and
then user hot adding them. So we may need to rescale when we get a new
maximum performance CPU and send to user space.
We can't just use max from HFI table at in instance as it is not
necessary that HFI table contains data for all CPUs.
If HFI max performance value of 255 is a scaled value to max
performance CPU value in the system, then this conversion would have
been easy. But that is not.
I see. I was asking because I'm working on similar interface and
just wanted to understand your approach better. In my case we
would probably simply use 'capacity' scale, or more
precisely available capacity after subtracting 'thermal pressure' value.
That might confuse a generic tool which listens to these socket
messages, though. So probably I would have to add a new
THERMAL_GENL_ATTR_CPU_CAPABILITY_* id
to handle this different normalized across CPUs scale.
On Tue, 2021-11-09 at 13:53 +0000, Lukasz Luba wrote:
Hi Srinivas,
On 11/9/21 1:23 PM, Srinivas Pandruvada wrote:
quoted
Hi Lukasz,
On Tue, 2021-11-09 at 12:39 +0000, Lukasz Luba wrote:
quoted
Hi Ricardo,
On 11/6/21 1:33 AM, Ricardo Neri wrote:
quoted
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Add a new netlink event to notify change in CPU capabilities in
terms of
performance and efficiency.
Is this going to be handled by some 'generic' tools? If yes,
maybe
the values for 'performance' might be aligned with capacity
[0,1024] ? Or are they completely not related so the mapping is
simply impossible?
That would have been very useful.
The problem is that we may not know the maximum performance as
system
may be booting with few CPUs (using maxcpus kernel command line)
and
then user hot adding them. So we may need to rescale when we get a
new
maximum performance CPU and send to user space.
We can't just use max from HFI table at in instance as it is not
necessary that HFI table contains data for all CPUs.
If HFI max performance value of 255 is a scaled value to max
performance CPU value in the system, then this conversion would
have
been easy. But that is not.
I see. I was asking because I'm working on similar interface and
just wanted to understand your approach better. In my case we
would probably simply use 'capacity' scale, or more
precisely available capacity after subtracting 'thermal pressure'
value.
That might confuse a generic tool which listens to these socket
messages, though. So probably I would have to add a new
THERMAL_GENL_ATTR_CPU_CAPABILITY_* id
to handle this different normalized across CPUs scale.
I can add a field capacity_scale. In HFI case it will always be 255. In
your cases it will 1024.
From: Lukasz Luba <lukasz.luba@arm.com> Date: 2021-11-09 17:51:11
On 11/9/21 2:15 PM, Srinivas Pandruvada wrote:
On Tue, 2021-11-09 at 13:53 +0000, Lukasz Luba wrote:
quoted
Hi Srinivas,
On 11/9/21 1:23 PM, Srinivas Pandruvada wrote:
quoted
Hi Lukasz,
On Tue, 2021-11-09 at 12:39 +0000, Lukasz Luba wrote:
quoted
Hi Ricardo,
On 11/6/21 1:33 AM, Ricardo Neri wrote:
quoted
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Add a new netlink event to notify change in CPU capabilities in
terms of
performance and efficiency.
Is this going to be handled by some 'generic' tools? If yes,
maybe
the values for 'performance' might be aligned with capacity
[0,1024] ? Or are they completely not related so the mapping is
simply impossible?
That would have been very useful.
The problem is that we may not know the maximum performance as
system
may be booting with few CPUs (using maxcpus kernel command line)
and
then user hot adding them. So we may need to rescale when we get a
new
maximum performance CPU and send to user space.
We can't just use max from HFI table at in instance as it is not
necessary that HFI table contains data for all CPUs.
If HFI max performance value of 255 is a scaled value to max
performance CPU value in the system, then this conversion would
have
been easy. But that is not.
I see. I was asking because I'm working on similar interface and
just wanted to understand your approach better. In my case we
would probably simply use 'capacity' scale, or more
precisely available capacity after subtracting 'thermal pressure'
value.
That might confuse a generic tool which listens to these socket
messages, though. So probably I would have to add a new
THERMAL_GENL_ATTR_CPU_CAPABILITY_* id
to handle this different normalized across CPUs scale.
I can add a field capacity_scale. In HFI case it will always be 255. In
your cases it will 1024.
Sounds good, with that upper limit those tools would not build
up assumptions (they would have to parse that scale value).
Although, I would prefer to call it 'performance_scale' if you don't
mind.
I've done similar renaming s/capacity/performance/ in the Energy Model
(EM) some time ago [1]. Some reasons:
- in the scheduler we have 'Performance Domains (PDs)'
- for GPUs we talk about 'performance', because 'capacity' sounds odd
in that case
[1]
https://lore.kernel.org/linux-pm/20200527095854.21714-2-lukasz.luba@arm.com/
On Tue, 2021-11-09 at 17:51 +0000, Lukasz Luba wrote:
On 11/9/21 2:15 PM, Srinivas Pandruvada wrote:
quoted
On Tue, 2021-11-09 at 13:53 +0000, Lukasz Luba wrote:
quoted
Hi Srinivas,
On 11/9/21 1:23 PM, Srinivas Pandruvada wrote:
quoted
Hi Lukasz,
On Tue, 2021-11-09 at 12:39 +0000, Lukasz Luba wrote:
quoted
Hi Ricardo,
On 11/6/21 1:33 AM, Ricardo Neri wrote:
quoted
From: Srinivas Pandruvada <
srinivas.pandruvada@linux.intel.com>
Add a new netlink event to notify change in CPU capabilities
in
terms of
performance and efficiency.
Is this going to be handled by some 'generic' tools? If yes,
maybe
the values for 'performance' might be aligned with capacity
[0,1024] ? Or are they completely not related so the mapping is
simply impossible?
That would have been very useful.
The problem is that we may not know the maximum performance as
system
may be booting with few CPUs (using maxcpus kernel command line)
and
then user hot adding them. So we may need to rescale when we get
a
new
maximum performance CPU and send to user space.
We can't just use max from HFI table at in instance as it is not
necessary that HFI table contains data for all CPUs.
If HFI max performance value of 255 is a scaled value to max
performance CPU value in the system, then this conversion would
have
been easy. But that is not.
I see. I was asking because I'm working on similar interface and
just wanted to understand your approach better. In my case we
would probably simply use 'capacity' scale, or more
precisely available capacity after subtracting 'thermal pressure'
value.
That might confuse a generic tool which listens to these socket
messages, though. So probably I would have to add a new
THERMAL_GENL_ATTR_CPU_CAPABILITY_* id
to handle this different normalized across CPUs scale.
I can add a field capacity_scale. In HFI case it will always be 255.
In
your cases it will 1024.
Sounds good, with that upper limit those tools would not build
up assumptions (they would have to parse that scale value).
Although, I would prefer to call it 'performance_scale' if you don't
mind.
Sure.
Thanks,
Srinivas
I've done similar renaming s/capacity/performance/ in the Energy Model
(EM) some time ago [1]. Some reasons:
- in the scheduler we have 'Performance Domains (PDs)'
- for GPUs we talk about 'performance', because 'capacity' sounds odd
in that case
[1]
https://lore.kernel.org/linux-pm/20200527095854.21714-2-lukasz.luba@arm.com/
From: Daniel Lezcano <hidden> Date: 2021-11-30 09:29:53
On 06/11/2021 02:33, Ricardo Neri wrote:
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Add a new netlink event to notify change in CPU capabilities in terms of
performance and efficiency.
Firmware may change CPU capabilities as a result of thermal events in the
system or to account for changes in the TDP (thermal design power) level.
This notification type will allow user space to avoid running workloads
on certain CPUs or proactively adjust power limits to avoid future events.
On Tue, Nov 30, 2021 at 10:29:46AM +0100, Daniel Lezcano wrote:
On 06/11/2021 02:33, Ricardo Neri wrote:
quoted
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Add a new netlink event to notify change in CPU capabilities in terms of
performance and efficiency.
Firmware may change CPU capabilities as a result of thermal events in the
system or to account for changes in the TDP (thermal design power) level.
This notification type will allow user space to avoid running workloads
on certain CPUs or proactively adjust power limits to avoid future events.
From: Daniel Lezcano <hidden> Date: 2021-12-09 16:57:41
On 09/12/2021 17:03, Ricardo Neri wrote:
On Tue, Nov 30, 2021 at 10:29:46AM +0100, Daniel Lezcano wrote:
quoted
On 06/11/2021 02:33, Ricardo Neri wrote:
quoted
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Add a new netlink event to notify change in CPU capabilities in terms of
performance and efficiency.
Firmware may change CPU capabilities as a result of thermal events in the
system or to account for changes in the TDP (thermal design power) level.
This notification type will allow user space to avoid running workloads
on certain CPUs or proactively adjust power limits to avoid future events.
AFAIU, 0 <= perf < 256 and 0 <= eff < 256, right?
Is the following true?
0 <= perf + eff < 256
No, they are not. They are set independently.
I understand they can be set independently but is the constraint above
correct? For example, can the system send perf=255 and eff=255 or perf=0
and eff=0 ?
May be I misunderstood but I was expecting at least some kind of
connection between perf and eff (when eff is high, perf is low and the
opposite).
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
On Thu, 2021-12-09 at 17:57 +0100, Daniel Lezcano wrote:
On 09/12/2021 17:03, Ricardo Neri wrote:
quoted
On Tue, Nov 30, 2021 at 10:29:46AM +0100, Daniel Lezcano wrote:
quoted
On 06/11/2021 02:33, Ricardo Neri wrote:
quoted
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Add a new netlink event to notify change in CPU capabilities in
terms of
performance and efficiency.
Firmware may change CPU capabilities as a result of thermal
events in the
system or to account for changes in the TDP (thermal design
power) level.
This notification type will allow user space to avoid running
workloads
on certain CPUs or proactively adjust power limits to avoid
future events.
AFAIU, 0 <= perf < 256 and 0 <= eff < 256, right?
Is the following true?
0 <= perf + eff < 256
No, they are not. They are set independently.
I understand they can be set independently but is the constraint
above
correct? For example, can the system send perf=255 and eff=255 or
perf=0
and eff=0 ?
perf = 0 and eff = 0 is already the case in the current processors.
Both FF is not the case as the current generation use real performance
which can't be FF. Also it is unlikely that at max performance you have
max efficiency.
Thanks,
Srinivas
May be I misunderstood but I was expecting at least some kind of
connection between perf and eff (when eff is high, perf is low and
the
opposite).