cpufreq: intel_pstate: Support raw epp and energy_efficiency
Subsystems (4)
Srinivas Pandruvada
maintainerv4 cover cpufreq: intel_pstate: Support raw epp and energy_efficiency
v4
Changes suggested by Borislav
- msr-index file is sorted for the MSR_IA32_POWER_CTL
- Remove "_enable" from the new attribute
- Changes related to documentation
Changes suggested by Peter
- Use of kstrtobool
Suspend/resume restore
v3
Some edits for the description as suggested by Doug
v2
Remove raw value support for EPB
Srinivas Pandruvada (2):
cpufreq: intel_pstate: Allow enable/disable energy efficiency
cpufreq: intel_pstate: Allow raw energy performance preference value
Documentation/admin-guide/pm/intel_pstate.rst | 17 +- arch/x86/include/asm/msr-index.h | 6 +- drivers/cpufreq/intel_pstate.c | 147 ++++++++++++++---- 3 files changed, 133 insertions(+), 37 deletions(-)
Signature · 1 line
2.25.4
Srinivas Pandruvada
maintainerPATCH v4 1/2 cpufreq: intel_pstate: Allow enable/disable energy efficiency
By default intel_pstate driver disables energy efficiency by setting MSR_IA32_POWER_CTL bit 19 for Kaby Lake desktop CPU model in HWP mode. This CPU model is also shared by Coffee Lake desktop CPUs. This allows these systems to reach maximum possible frequency. But this adds power penalty, which some customers don't want. They want some way to enable/ disable dynamically.
So, add an additional attribute "energy_efficiency" under /sys/devices/system/cpu/intel_pstate/ for these CPU models. This allows to read and write bit 19 ("Disable Energy Efficiency Optimization") in the MSR IA32_POWER_CTL.
This attribute is present in both HWP and non-HWP mode as this has an effect in both modes. Refer to Intel Software Developer's manual for details.
The scope of this bit is package wide. Also these systems are single package systems. So read/write MSR on the current CPU is enough.
The energy efficiency (EE) bit setting needs to be preserved during suspend/resume and CPU offline/online operation. To do this:
- Restoring the EE setting from the cpufreq resume() callback, if there is change from the system default.
- By default, don't disable EE from cpufreq init() callback for matching CPU models. Since the scope is package wide and is a single package system, move the disable EE calls from init() callback to intel_pstate_init() function, which is called only once.
--- Documentation/admin-guide/pm/intel_pstate.rst | 11 +++ arch/x86/include/asm/msr-index.h | 6 +- drivers/cpufreq/intel_pstate.c | 97 ++++++++++++++----- 3 files changed, 88 insertions(+), 26 deletions(-)
Documentation/admin-guide/pm/intel_pstate.rst +11 -0
@@ -431,6 +431,17 @@ argument is passed to the kernel in the command line. supported in the current configuration, writes to this attribute will fail with an appropriate error. +``energy_efficiency`` + This attribute is only present on platforms, which have CPUs matching + Kaby Lake or Coffee Lake desktop CPU model. By default + energy efficiency optimizations are disabled on these CPU models in HWP + mode by this driver. Enabling energy efficiency may limit maximum + operating frequency in both HWP and non HWP mode. In non HWP mode, + optimizations are done only in the turbo frequency range. In HWP mode, + optimizations are done in the entire frequency range. Setting this + attribute to "1" enables energy efficiency optimizations and setting + to "0" disables energy efficiency optimizations. + Interpretation of Policy Attributes -----------------------------------
arch/x86/include/asm/msr-index.h +4 -2
@@ -149,6 +149,10 @@#define MSR_LBR_SELECT 0x000001c8#define MSR_LBR_TOS 0x000001c9 + +#define MSR_IA32_POWER_CTL 0x000001fc +#define MSR_IA32_POWER_CTL_BIT_EE 19 +#define MSR_LBR_NHM_FROM 0x00000680#define MSR_LBR_NHM_TO 0x000006c0#define MSR_LBR_CORE_FROM 0x00000040
@@ -253,8 +257,6 @@#define MSR_PEBS_FRONTEND 0x000003f7 -#define MSR_IA32_POWER_CTL 0x000001fc -#define MSR_IA32_MC0_CTL 0x00000400#define MSR_IA32_MC0_STATUS 0x00000401#define MSR_IA32_MC0_ADDR 0x00000402
drivers/cpufreq/intel_pstate.c +73 -24
150 lines not on this page · raw message
Signature · 1 line
2.25.4
Srinivas Pandruvada
maintainerPATCH v4 2/2 cpufreq: intel_pstate: Allow raw energy performance preference value
In reply to Srinivas PandruvadaCurrently using attribute "energy_performance_preference", user space can write one of the four per-defined preference string. These preference strings gets mapped to a hard-coded Energy-Performance Preference (EPP) or Energy-Performance Bias (EPB) knob.
These four values are supposed to cover broad spectrum of use cases, but are not uniformly distributed in the range. There are number of cases, where this is not enough. For example:
Suppose user wants more performance when connected to AC. Instead of using default "balance performance", the "performance" setting can be used. This changes EPP value from 0x80 to 0x00. But setting EPP to 0, results in electrical and thermal issues on some platforms. This results in aggressive throttling, which causes a drop in performance. But some value between 0x80 and 0x00 results in better performance. But that value can't be fixed as the power curve is not linear. In some cases just changing EPP from 0x80 to 0x75 is enough to get significant performance gain.
Similarly on battery the default "balance_performance" mode can be aggressive in power consumption. But picking up the next choice "balance power" results in too much loss of performance, which results in bad user experience in use cases like "Google Hangout". It was observed that some value between these two EPP is optimal.
This change allows fine grain EPP tuning for platform like Chromebook or for users who wants to fine tune power and performance.
Here based on the product and use cases, different EPP values can be set. This change is similar to the change done for:/sys/devices/system/cpu/cpu*/power/energy_perf_bias
where user has choice to write a predefined string or raw value.
The change itself is trivial. When user preference doesn't match predefined string preferences and value is an unsigned integer and in range, use that value for EPP. When the EPP feature is not present writing raw value is not supported.
--- Documentation/admin-guide/pm/intel_pstate.rst | 6 ++- drivers/cpufreq/intel_pstate.c | 50 +++++++++++++++---- 2 files changed, 45 insertions(+), 11 deletions(-)
Documentation/admin-guide/pm/intel_pstate.rst +5 -1
@@ -565,7 +565,11 @@ somewhere between the two extremes: Strings written to the ``energy_performance_preference`` attribute are internally translated to integer values written to the processor's Energy-Performance Preference (EPP) knob (if supported) or its -Energy-Performance Bias (EPB) knob. +Energy-Performance Bias (EPB) knob. It is also possible to write a positive +integer value between 0 to 255, if the EPP feature is present. If the EPP +feature is not present, writing integer value to this attribute is not +supported. In this case, user can use + "/sys/devices/system/cpu/cpu*/power/energy_perf_bias" interface. [Note that tasks may by migrated from one CPU to another by the scheduler's load-balancing algorithm and if different energy vs performance hints are
drivers/cpufreq/intel_pstate.c +40 -10
105 lines not on this page · raw message
Signature · 1 line
2.25.4
RE: [PATCH v4 2/2] cpufreq: intel_pstate: Allow raw energy performance preference value
Hi Srinivas,
Thanks for all your work on this.
I have fallen behind, and not sure when I can catch up. However...
Quoted 5 lines · On 2020.06.26 11:34 Srinivas Pandruvada wrote:
Similarly on battery the default "
balance_performance" mode can be aggressive in power consumption. But picking up the next choice "balance power" results in too much loss of performance, which results in bad user experience in use cases like "Google Hangout". It was observed that some value between these two EPP is optimal.
There is a possibility that one of the issues I have been ranting about could be a contributing factor to things like this. (I don't know if it actually is.)
One way to compensate is to lower EPP.
I am going to send a new e-mail in a minute about it. Please consider the possibility that some of these EPP adjustments might just be programming around the issue.
... Doug
Rafael J. Wysocki
maintainerQuoted 20 lines · Srinivas Pandruvada
v4
Changes suggested by Borislav
- msr-index file is sorted for theMSR_IA32_POWER_CTL
- Remove "_enable" from the new attribute
- Changes related to documentation
Changes suggested by Peter
- Use of kstrtobool
Suspend/resume restorev3
Some edits for the description as suggested by Dougv2
Remove raw value support for EPBSrinivas Pandruvada (2):
cpufreq:intel_pstate: Allow enable/disable energy efficiency
cpufreq:intel_pstate: Allow raw energy performance preference value
Quoted 6 lines
Documentation/admin-guide/pm/intel_pstate.rst | 17 +- arch/x86/include/asm/msr-index.h | 6 +- drivers/cpufreq/intel_pstate.c | 147 ++++++++++++++---- 3 files changed, 133 insertions(+), 37 deletions(-)--
Both applied as 5.9 material, thanks!