powercap/dtpm: Add the DTPM framework
Subsystems (5)
v5 cover powercap/dtpm: Add the DTPM framework
The density of components greatly increased the last decade bringing a numerous number of heating sources which are monitored by more than 20 sensors on recent SoC. The skin temperature, which is the case temperature of the device, must stay below approximately 45°C in order to comply with the legal requirements.
The skin temperature is managed as a whole by an user space daemon, which is catching the current application profile, to allocate a power budget to the different components where the resulting heating effect will comply with the skin temperature constraint.
This technique is called the Dynamic Thermal Power Management.
The Linux kernel does not provide any unified interface to act on the power of the different devices. Currently, the thermal framework is changed to export artificially the performance states of different devices via the cooling device software component with opaque values. This change is done regardless of the in-kernel logic to mitigate the temperature. The user space daemon uses all the available knobs to act on the power limit and those differ from one platform to another.
This series provides a Dynamic Thermal Power Management framework to provide an unified way to act on the power of the devices.
Changelog:
V5:
- Fixed typos in documentation
- Added a dtpm NULL pointer check in the dtpm_register() function
V4:
- Changed fine grain spinlocks by global tree mutex lock
- Dropped tested by tag from Lukasz
- Fixed rollback routine in dtpm_cpu
- Checked freq_qos_request_active() when releasing the dtpm_cpu node
V3:
- Fixed power-limit computation in addition with the hotplugging
- Improved the encapsulation
- Added specific ops for the leaves of the tree
- Simplified API and self-encapsulation
- Fixed documentation and generated it to check the content
V2:
- Fixed indentation
- Fixed typos in comments
- Fixed missing kfree for dtpm_cpu
- Capitalize letters in the Kconfig description
- Reduced name description
- Stringified section name
- Added more debug traces in the code
- Removed duplicate initialization in the dtpm cpu
Daniel Lezcano (4):
units: Add Watt units
Documentation/powercap/dtpm: Add documentation for dtpm powercap/drivers/dtpm: Add API for dynamic thermal power management powercap/drivers/dtpm: Add CPU energy model based support
Documentation/power/index.rst | 1 + Documentation/power/powercap/dtpm.rst | 212 ++++++++++++ drivers/powercap/Kconfig | 13 + drivers/powercap/Makefile | 2 + drivers/powercap/dtpm.c | 473 ++++++++++++++++++++++++++ drivers/powercap/dtpm_cpu.c | 257 ++++++++++++++ include/asm-generic/vmlinux.lds.h | 11 + include/linux/cpuhotplug.h | 1 + include/linux/dtpm.h | 77 +++++ include/linux/units.h | 4 + 10 files changed, 1051 insertions(+) create mode 100644 Documentation/power/powercap/dtpm.rst create mode 100644 drivers/powercap/dtpm.c create mode 100644 drivers/powercap/dtpm_cpu.c create mode 100644 include/linux/dtpm.h
--
2.17.1
PATCH v5 1/4 units: Add Watt units
As there are the temperature units, let's add the Watt macros definition.
--- include/linux/units.h | 4 ++++ 1 file changed, 4 insertions(+)
include/linux/units.h +4 -0
@@ -4,6 +4,10 @@#include <linux/kernel.h> +#define MILLIWATT_PER_WATT 1000L +#define MICROWATT_PER_MILLIWATT 1000L +#define MICROWATT_PER_WATT 1000000L +#define ABSOLUTE_ZERO_MILLICELSIUS -273150static inline long milli_kelvin_to_millicelsius (long t)
Signature · 1 line
2.17.1
PATCH v5 2/4 Documentation/powercap/dtpm: Add documentation for dtpm
In reply to Daniel LezcanoThe dynamic thermal and power management is a technique to dynamically adjust the power consumption of different devices in order to ensure a global thermal constraint.
An userspace daemon is usually monitoring the temperature and the power to take immediate action on the device.
The DTPM framework provides an unified API to userspace to act on the power.
Document this framework.
--- Documentation/power/index.rst | 1 + Documentation/power/powercap/dtpm.rst | 212 ++++++++++++++++++++++++++ 2 files changed, 213 insertions(+) create mode 100644 Documentation/power/powercap/dtpm.rst
Documentation/power/index.rst +1 -0
@@ -30,6 +30,7 @@ Power Management userland-swsusp powercap/powercap + powercap/dtpm regulator/consumer regulator/design
Documentation/power/powercap/dtpm.rst new file +212 -0
212 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v5 3/4 powercap/drivers/dtpm: Add API for dynamic thermal power management
In reply to Daniel LezcanoOn the embedded world, the complexity of the SoC leads to an increasing number of hotspots which need to be monitored and mitigated as a whole in order to prevent the temperature to go above the normative and legally stated 'skin temperature'.
Another aspect is to sustain the performance for a given power budget, for example virtual reality where the user can feel dizziness if the GPU performance is capped while a big CPU is processing something else. Or reduce the battery charging because the dissipated power is too high compared with the power consumed by other devices.
The userspace is the most adequate place to dynamically act on the different devices by limiting their power given an application
profile: it has the knowledge of the platform.
These userspace daemons are in charge of the Dynamic Thermal Power Management (DTPM).
Nowadays, the dtpm daemons are abusing the thermal framework as they act on the cooling device state to force a specific and arbitrary state without taking care of the governor decisions. Given the closed loop of some governors that can confuse the logic or directly enter in a decision conflict.
As the number of cooling device support is limited today to the CPU and the GPU, the dtpm daemons have little control on the power dissipation of the system. The out of tree solutions are hacking around here and there in the drivers, in the frameworks to have control on the devices. The common solution is to declare them as cooling devices.
There is no unification of the power limitation unit, opaque states are used.
This patch provides a way to create a hierarchy of constraints using the powercap framework. The devices which are registered as power limit-able devices are represented in this hierarchy as a tree. They are linked together with intermediate nodes which are just there to propagate the constraint to the children.
The leaves of the tree are the real devices, the intermediate nodes are virtual, aggregating the children constraints and power characteristics.
Each node have a weight on a 2^10 basis, in order to reflect the percentage of power distribution of the children's node. This percentage is used to dispatch the power limit to the children.
The weight is computed against the max power of the siblings.
This simple approach allows to do a fair distribution of the power limit.
--- drivers/powercap/Kconfig | 6 + drivers/powercap/Makefile | 1 + drivers/powercap/dtpm.c | 473 ++++++++++++++++++++++++++++++ include/asm-generic/vmlinux.lds.h | 11 + include/linux/dtpm.h | 75 +++++ 5 files changed, 566 insertions(+) create mode 100644 drivers/powercap/dtpm.c create mode 100644 include/linux/dtpm.h
drivers/powercap/Kconfig +6 -0
@@ -43,4 +43,10 @@ config IDLE_INJECT CPUs for power capping. Idle period can be injected synchronously on a set of specified CPUs or alternatively on a per CPU basis. + +config DTPM + bool "Power capping for Dynamic Thermal Power Management" + help + This enables support for the power capping for the dynamic + thermal power management userspace engine. endif
drivers/powercap/Makefile +1 -0
@@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_DTPM) += dtpm.o obj-$(CONFIG_POWERCAP) += powercap_sys.o obj-$(CONFIG_INTEL_RAPL_CORE) += intel_rapl_common.o obj-$(CONFIG_INTEL_RAPL) += intel_rapl_msr.o
drivers/powercap/dtpm.c new file +473 -0
473 lines not on this page · raw message
include/asm-generic/vmlinux.lds.h +11 -0
@@ -316,6 +316,16 @@#define THERMAL_TABLE (name)#endif +#ifdef CONFIG_DTPM +#define DTPM_TABLE () \ + . = ALIGN(8); \ + __dtpm_table = .; \ + KEEP(*(__dtpm_table)) \ + __dtpm_table_end = .; +#else +#define DTPM_TABLE () +#endif +#define KERNEL_DTB () \ STRUCT_ALIGN(); \ __dtb_start = .; \
@@ -733,6 +743,7 @@ ACPI_PROBE_TABLE(irqchip) \ ACPI_PROBE_TABLE(timer) \ THERMAL_TABLE(governor) \ + DTPM_TABLE() \ EARLYCON_TABLE() \ LSM_TABLE() \ EARLY_LSM_TABLE() \
include/linux/dtpm.h new file +75 -0
75 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v5 4/4 powercap/drivers/dtpm: Add CPU energy model based support
In reply to Daniel LezcanoWith the powercap dtpm controller, we are able to plug devices with power limitation features in the tree.
The following patch introduces the CPU power limitation based on the energy model and the performance states.
The power limitation is done at the performance domain level. If some CPUs are unplugged, the corresponding power will be subtracted from the performance domain total power.
It is up to the platform to initialize the dtpm tree and add the CPU.
Here is an example to create a simple tree with one root node called "pkg" and the CPU's performance domains.
static int dtpm_register_pkg(struct dtpm_descr *descr)
{
struct dtpm *pkg;
int ret;
pkg = dtpm_alloc(NULL);
if (!pkg)
return -ENOMEM;
ret = dtpm_register(descr->name, pkg, descr->parent);
if (ret)
return ret;
return dtpm_register_cpu(pkg);
}static struct dtpm_descr descr = {
.name = "pkg",
.init = dtpm_register_pkg,
};DTPM_DECLARE(descr);
--- drivers/powercap/Kconfig | 7 + drivers/powercap/Makefile | 1 + drivers/powercap/dtpm_cpu.c | 257 ++++++++++++++++++++++++++++++++++++ include/linux/cpuhotplug.h | 1 + include/linux/dtpm.h | 2 + 5 files changed, 268 insertions(+) create mode 100644 drivers/powercap/dtpm_cpu.c
drivers/powercap/Kconfig +7 -0
@@ -49,4 +49,11 @@ config DTPM help This enables support for the power capping for the dynamic thermal power management userspace engine. + +config DTPM_CPU + bool "Add CPU power capping based on the energy model" + depends on DTPM && ENERGY_MODEL + help + This enables support for CPU power limitation based on + energy model. endif
drivers/powercap/Makefile +1 -0
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_DTPM) += dtpm.o +obj-$(CONFIG_DTPM_CPU) += dtpm_cpu.o obj-$(CONFIG_POWERCAP) += powercap_sys.o obj-$(CONFIG_INTEL_RAPL_CORE) += intel_rapl_common.o obj-$(CONFIG_INTEL_RAPL) += intel_rapl_msr.o
drivers/powercap/dtpm_cpu.c new file +257 -0
257 lines not on this page · raw message
include/linux/cpuhotplug.h +1 -0
@@ -192,6 +192,7 @@ enum cpuhp_state {CPUHP_AP_ONLINE_DYN_END =CPUHP_AP_ONLINE_DYN +30 ,CPUHP_AP_X86_HPET_ONLINE ,CPUHP_AP_X86_KVM_CLK_ONLINE , +CPUHP_AP_DTPM_CPU_ONLINE ,CPUHP_AP_ACTIVE , CPUHP_ONLINE, };
include/linux/dtpm.h +2 -0
@@ -72,4 +72,6 @@ void dtpm_unregister(struct dtpm *dtpm);int dtpm_register (const char *name,struct dtpm *dtpm,struct dtpm *parent); +int dtpm_register_cpu (struct dtpm *parent); +#endif
Signature · 1 line
2.17.1
Hi Rafael,
I believe I took into account all the comments, do you think it is possible to merge this series ?
Quoted 80 lines · Daniel Lezcano
The density of components greatly increased the last decade bringing a numerous number of heating sources which are monitored by more than 20 sensors on recent SoC. The skin temperature, which is the case temperature of the device, must stay below approximately 45°C in order to comply with the legal requirements.
The skin temperature is managed as a whole by an user space daemon, which is catching the current application profile, to allocate a power budget to the different components where the resulting heating effect will comply with the skin temperature constraint.
This technique is called the Dynamic Thermal Power Management.
The Linux kernel does not provide any unified interface to act on the power of the different devices. Currently, the thermal framework is changed to export artificially the performance states of different devices via the cooling device software component with opaque values. This change is done regardless of the in-kernel logic to mitigate the temperature. The user space daemon uses all the available knobs to act on the power limit and those differ from one platform to another.
This series provides a Dynamic Thermal Power Management framework to provide an unified way to act on the power of the devices.
Changelog:
V5:
- Fixed typos in documentation
- Added a dtpm NULL pointer check in thedtpm_register()function
V4:
- Changed fine grain spinlocks by global tree mutex lock
- Dropped tested by tag from Lukasz
- Fixed rollback routine indtpm_cpu
- Checkedfreq_qos_request_active()when releasing thedtpm_cpunode
V3:
- Fixed power-limit computation in addition with the hotplugging
- Improved the encapsulation
- Added specific ops for the leaves of the tree
- Simplified API and self-encapsulation
- Fixed documentation and generated it to check the content
V2:
- Fixed indentation
- Fixed typos in comments
- Fixed missing kfree fordtpm_cpu
- Capitalize letters in theKconfigdescription
- Reduced name description
- Stringified section name
- Added more debug traces in the code
- Removed duplicate initialization in the dtpm cpuDaniel Lezcano (4):
units: Add Watt units
Documentation/powercap/dtpm: Add documentation for dtpm powercap/drivers/dtpm: Add API for dynamic thermal power management powercap/drivers/dtpm: Add CPU energy model based supportDocumentation/power/index.rst | 1 + Documentation/power/powercap/dtpm.rst | 212 ++++++++++++ drivers/powercap/Kconfig | 13 + drivers/powercap/Makefile | 2 + drivers/powercap/dtpm.c | 473 ++++++++++++++++++++++++++ drivers/powercap/dtpm_cpu.c | 257 ++++++++++++++ include/asm-generic/vmlinux.lds.h | 11 + include/linux/cpuhotplug.h | 1 + include/linux/dtpm.h | 77 +++++ include/linux/units.h | 4 + 10 files changed, 1051 insertions(+) create mode 100644 Documentation/power/powercap/dtpm.rst create mode 100644 drivers/powercap/dtpm.c create mode 100644 drivers/powercap/dtpm_cpu.c create mode 100644 include/linux/dtpm.hCc Thara Gopinath <[email protected]>Cc Lina Iyer <[email protected]>Cc Ram Chandrasekar <[email protected]>Cc Zhang Rui <[email protected]>Cc Lukasz Luba <[email protected]>--
2.17.1
Signature · 5 lines
<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
Rafael J. Wysocki
maintainerQuoted 6 lines · Daniel Lezcano
Hi Rafael,
I believe I took into account all the comments, do you think it is possible to merge this series ?
It should be, unless more changes are requested.
I will be taking care of it next week and, if all goes well, it should be possible to push it during the second half of the merge window.
Thanks!
Quoted 7 lines · Rafael J. Wysocki
Quoted 4 lines · Daniel Lezcano
Hi Rafael,
Quoted 7 lines
Quoted 2 lines
I believe I took into account all the comments, do you think it is possible to merge this series ?
It should be, unless more changes are requested.
I will be taking care of it next week and, if all goes well, it should be possible to push it during the second half of the merge window.
Applied as 5.11-rc material now, sorry for the delay.
Thanks!
Quoted 11 lines · Rafael J. Wysocki
Quoted 10 lines · Rafael J. Wysocki
Quoted 6 lines · Daniel Lezcano
Hi Rafael,
I believe I took into account all the comments, do you think it is possible to merge this series ?
Quoted 6 lines
Quoted 4 lines
It should be, unless more changes are requested.
I will be taking care of it next week and, if all goes well, it should be possible to push it during the second half of the merge window.
Applied as 5.11-rc material now, sorry for the delay.
No problem, thank you for taking care of the series.
I did not want to add another entry in the MAINTAINER file as you are the maintainer of the powercap framework and that is fine.
However the get_maintainer script (and default cccmd) does not return me as part of the maintainer/author of the dtpm or idle_inject. I would like to be at least Cc'ed to review the changes related to those files to make sure they stay aligned with the direction we are taking.
Is it possible to be automatically Cc'ed for the proposed changes in these files ?
Signature · 5 lines
<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
Hi!
Quoted 5 lines
The density of components greatly increased the last decade bringing a numerous number of heating sources which are monitored by more than 20 sensors on recent SoC. The skin temperature, which is the case temperature of the device, must stay below approximately 45°C in order to comply with the legal requirements.
What kind of device is that?
Does that mean that running fsck is now "illegal" because temperature will not be managed during that time?
Pavel
Signature · 1 line
http://www.livejournal.com/~pavelmachek
Quoted 9 lines · Pavel Machek
Hi!
Quoted 5 lines
The density of components greatly increased the last decade bringing a numerous number of heating sources which are monitored by more than 20 sensors on recent SoC. The skin temperature, which is the case temperature of the device, must stay below approximately 45°C in order to comply with the legal requirements.
What kind of device is that?
Any complex embedded devices like a phone, a laptop or a tablet with components like NPU, CPU, GPU, GPS, DSPs, Camera, ...
Quoted 2 lines
Does that mean that running fsck is now "illegal" because temperature will not be managed during that time?
The heating effect of the different devices will be conducted through a common dissipation device.
The 'skin' temperature or 'case' temperature has a dedicated sensor in the path of this dissipation device. So the temperature will increase slower at this sensor level because of a higher thermal capacity.
The 'skin' temperature will be the result of the different components running at the same time (eg. GPS + CPU + GPU + DSPs).
In the case of fsck, the system is in degraded mode, thus the application using these components are not supposed to run and the 'skin' temperature should stay below.
If you are interested, here you can find some background to explain the 'skin' temperature [1] and the spreading of the heat [2].
Hope that helps
-- Daniel
[1] https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4188373/
[2]
https://nanoheat.stanford.edu/sites/default/files/publications/Electronics%20Cooling%20Article.pdf
Signature · 5 lines
<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