2019-04-04 06:08:18 +08:00
|
|
|
.. SPDX-License-Identifier: GPL-2.0
|
|
|
|
.. include:: <isonum.txt>
|
|
|
|
|
PM / arch: x86: Rework the MSR_IA32_ENERGY_PERF_BIAS handling
The current handling of MSR_IA32_ENERGY_PERF_BIAS in the kernel is
problematic, because it may cause changes made by user space to that
MSR (with the help of the x86_energy_perf_policy tool, for example)
to be lost every time a CPU goes offline and then back online as well
as during system-wide power management transitions into sleep states
and back into the working state.
The first problem is that if the current EPB value for a CPU going
online is 0 ('performance'), the kernel will change it to 6 ('normal')
regardless of whether or not this is the first bring-up of that CPU.
That also happens during system-wide resume from sleep states
(including, but not limited to, hibernation). However, the EPB may
have been adjusted by user space this way and the kernel should not
blindly override that setting.
The second problem is that if the platform firmware resets the EPB
values for any CPUs during system-wide resume from a sleep state,
the kernel will not restore their previous EPB values that may
have been set by user space before the preceding system-wide
suspend transition. Again, that behavior may at least be confusing
from the user space perspective.
In order to address these issues, rework the handling of
MSR_IA32_ENERGY_PERF_BIAS so that the EPB value is saved on CPU
offline and restored on CPU online as well as (for the boot CPU)
during the syscore stages of system-wide suspend and resume
transitions, respectively.
However, retain the policy by which the EPB is set to 6 ('normal')
on the first bring-up of each CPU if its initial value is 0, based
on the observation that 0 may mean 'not initialized' just as well as
'performance' in that case.
While at it, move the MSR_IA32_ENERGY_PERF_BIAS handling code into
a separate file and document it in Documentation/admin-guide.
Fixes: abe48b108247 (x86, intel, power: Initialize MSR_IA32_ENERGY_PERF_BIAS)
Fixes: b51ef52df71c (x86/cpu: Restore MSR_IA32_ENERGY_PERF_BIAS after resume)
Reported-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Acked-by: Borislav Petkov <bp@suse.de>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
2019-03-22 06:18:01 +08:00
|
|
|
======================================
|
|
|
|
Intel Performance and Energy Bias Hint
|
|
|
|
======================================
|
|
|
|
|
2019-04-04 06:08:18 +08:00
|
|
|
:Copyright: |copy| 2019 Intel Corporation
|
|
|
|
|
|
|
|
:Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
|
|
|
|
|
|
|
|
|
PM / arch: x86: Rework the MSR_IA32_ENERGY_PERF_BIAS handling
The current handling of MSR_IA32_ENERGY_PERF_BIAS in the kernel is
problematic, because it may cause changes made by user space to that
MSR (with the help of the x86_energy_perf_policy tool, for example)
to be lost every time a CPU goes offline and then back online as well
as during system-wide power management transitions into sleep states
and back into the working state.
The first problem is that if the current EPB value for a CPU going
online is 0 ('performance'), the kernel will change it to 6 ('normal')
regardless of whether or not this is the first bring-up of that CPU.
That also happens during system-wide resume from sleep states
(including, but not limited to, hibernation). However, the EPB may
have been adjusted by user space this way and the kernel should not
blindly override that setting.
The second problem is that if the platform firmware resets the EPB
values for any CPUs during system-wide resume from a sleep state,
the kernel will not restore their previous EPB values that may
have been set by user space before the preceding system-wide
suspend transition. Again, that behavior may at least be confusing
from the user space perspective.
In order to address these issues, rework the handling of
MSR_IA32_ENERGY_PERF_BIAS so that the EPB value is saved on CPU
offline and restored on CPU online as well as (for the boot CPU)
during the syscore stages of system-wide suspend and resume
transitions, respectively.
However, retain the policy by which the EPB is set to 6 ('normal')
on the first bring-up of each CPU if its initial value is 0, based
on the observation that 0 may mean 'not initialized' just as well as
'performance' in that case.
While at it, move the MSR_IA32_ENERGY_PERF_BIAS handling code into
a separate file and document it in Documentation/admin-guide.
Fixes: abe48b108247 (x86, intel, power: Initialize MSR_IA32_ENERGY_PERF_BIAS)
Fixes: b51ef52df71c (x86/cpu: Restore MSR_IA32_ENERGY_PERF_BIAS after resume)
Reported-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Acked-by: Borislav Petkov <bp@suse.de>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
2019-03-22 06:18:01 +08:00
|
|
|
.. kernel-doc:: arch/x86/kernel/cpu/intel_epb.c
|
|
|
|
:doc: overview
|
2019-03-22 06:20:17 +08:00
|
|
|
|
|
|
|
Intel Performance and Energy Bias Attribute in ``sysfs``
|
|
|
|
========================================================
|
|
|
|
|
|
|
|
The Intel Performance and Energy Bias Hint (EPB) value for a given (logical) CPU
|
|
|
|
can be checked or updated through a ``sysfs`` attribute (file) under
|
|
|
|
:file:`/sys/devices/system/cpu/cpu<N>/power/`, where the CPU number ``<N>``
|
|
|
|
is allocated at the system initialization time:
|
|
|
|
|
|
|
|
``energy_perf_bias``
|
|
|
|
Shows the current EPB value for the CPU in a sliding scale 0 - 15, where
|
|
|
|
a value of 0 corresponds to a hint preference for highest performance
|
|
|
|
and a value of 15 corresponds to the maximum energy savings.
|
|
|
|
|
|
|
|
In order to update the EPB value for the CPU, this attribute can be
|
|
|
|
written to, either with a number in the 0 - 15 sliding scale above, or
|
|
|
|
with one of the strings: "performance", "balance-performance", "normal",
|
|
|
|
"balance-power", "power" that represent values reflected by their
|
|
|
|
meaning.
|
|
|
|
|
|
|
|
This attribute is present for all online CPUs supporting the EPB
|
|
|
|
feature.
|
|
|
|
|
|
|
|
Note that while the EPB interface to the processor is defined at the logical CPU
|
|
|
|
level, the physical register backing it may be shared by multiple CPUs (for
|
|
|
|
example, SMT siblings or cores in one package). For this reason, updating the
|
|
|
|
EPB value for one CPU may cause the EPB values for other CPUs to change.
|