Reuse cpuidle cooling for non DT/ARM
Subsystems (3)
cover Reuse cpuidle cooling for non DT/ARM
This patchset reused existing cpuidle cooling implementation and develops a new driver which can be used in non DT/ARM platforms.
This has added advantage for per cpu idle injection instead of a global one using Intel powerclamp driver.
Srinivas Pandruvada (3):
thermal/drivers/cpuidle_cooling: Reorganize cpuidle cooling driver
powercap: idle_inject: Export symbols thermal/drivers/cpuidle_cooling: cpuidle cooling driver for non DT/ARM
drivers/powercap/idle_inject.c | 4 + drivers/thermal/Kconfig | 18 ++- drivers/thermal/Makefile | 3 + drivers/thermal/cpuidle_cooling.c | 141 +------------------- drivers/thermal/cpuidle_cooling_core.c | 148 +++++++++++++++++++++ drivers/thermal/cpuidle_cooling_core.h | 24 ++++ drivers/thermal/cpuidle_cooling_generic.c | 155 ++++++++++++++++++++++ 7 files changed, 353 insertions(+), 140 deletions(-) create mode 100644 drivers/thermal/cpuidle_cooling_core.c create mode 100644 drivers/thermal/cpuidle_cooling_core.h create mode 100644 drivers/thermal/cpuidle_cooling_generic.c
Signature · 1 line
2.30.2
RFC PATCH 1/3 thermal/drivers/cpuidle_cooling: Reorganize cpuidle cooling driver
Reorganize cpuidle cooling driver, so that it can be reused for non DT/ARM implementations.
No functional changes are expected.
To reorganize:
- Split cpuidle cooling driver into two parts, one common and on DT specific
- The common part is moved to cpuidle_cooling_core.c
- The DT specific part is left in cpuidle_cooling.c
- cpuidle_cooling_device structure is moved to a header file
- Created interface cpuidle_cooling_get_ops() to get cdev callbacks
While here, fixed some checkpatch warnings.
--- drivers/thermal/Kconfig | 6 +- drivers/thermal/Makefile | 1 + drivers/thermal/cpuidle_cooling.c | 141 +---------------------- drivers/thermal/cpuidle_cooling_core.c | 148 +++++++++++++++++++++++++ drivers/thermal/cpuidle_cooling_core.h | 24 ++++ 5 files changed, 180 insertions(+), 140 deletions(-) create mode 100644 drivers/thermal/cpuidle_cooling_core.c create mode 100644 drivers/thermal/cpuidle_cooling_core.h
drivers/thermal/Kconfig +5 -1
@@ -167,6 +167,10 @@ config CPU_THERMAL cooling device available, this option allows to use the CPU as a cooling device. +config CPU_IDLE_THERMAL_CORE + bool + depends on IDLE_INJECT + if CPU_THERMAL config CPU_FREQ_THERMAL
@@ -182,7 +186,7 @@ config CPU_FREQ_THERMAL config CPU_IDLE_THERMAL bool "CPU idle cooling device" - depends on IDLE_INJECT + select CPU_IDLE_THERMAL_CORE help This implements the CPU cooling mechanism through idle injection. This will throttle the CPU by injecting
drivers/thermal/Makefile +1 -0
@@ -23,6 +23,7 @@ thermal_sys-$(CONFIG_THERMAL_GOV_POWER_ALLOCATOR) += gov_power_allocator.o # cpufreq cooling thermal_sys-$(CONFIG_CPU_FREQ_THERMAL) += cpufreq_cooling.o +thermal_sys-$(CONFIG_CPU_IDLE_THERMAL_CORE) += cpuidle_cooling_core.o thermal_sys-$(CONFIG_CPU_IDLE_THERMAL) += cpuidle_cooling.o # devfreq cooling
drivers/thermal/cpuidle_cooling.c +2 -139
159 lines not on this page · raw message
drivers/thermal/cpuidle_cooling_core.c new file +148 -0
148 lines not on this page · raw message
drivers/thermal/cpuidle_cooling_core.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (C) 2019 Linaro Limited. +* +* Author: Daniel Lezcano <[email protected]> +* +*/ + +#ifndef _CPUIDLE_COOLING_CORE_H +#define _CPUIDLE_COOLING_CORE_H + +/** +* struct cpuidle_cooling_device - data for the idle cooling device +* @ii_dev: an atomic to keep track of the last task exiting the idle cycle +* @state: a normalized integer giving the state of the cooling device +*/ +struct cpuidle_cooling_device { +struct idle_inject_device *ii_dev; +unsigned long state; +}; + +struct thermal_cooling_device_ops *cpuidle_cooling_get_ops (void ); + +#endif
Signature · 1 line
2.30.2
RFC PATCH 2/3 powercap: idle_inject: Export symbols
In reply to Srinivas PandruvadaExport symbols for interfaces used in other files. In this way the caller can be a module.
--- drivers/powercap/idle_inject.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/powercap/idle_inject.c +4 -0
@@ -159,6 +159,7 @@ void idle_inject_set_duration(struct idle_inject_device *ii_dev,WRITE_ONCE (ii_dev->idle_duration_us, idle_duration_us); } } +EXPORT_SYMBOL_GPL (idle_inject_set_duration);/** * idle_inject_get_duration - idle and run duration retrieval helper
@@ -182,6 +183,7 @@ void idle_inject_set_latency(struct idle_inject_device *ii_dev, {WRITE_ONCE (ii_dev->latency_us, latency_us); } +EXPORT_SYMBOL (idle_inject_set_latency);/** * idle_inject_start - start idle injections
@@ -334,6 +336,7 @@ struct idle_inject_device *idle_inject_register(struct cpumask *cpumask)return NULL ; } +EXPORT_SYMBOL_GPL (idle_inject_register);/** * idle_inject_unregister - unregister idle injection control device
@@ -354,6 +357,7 @@ void idle_inject_unregister(struct idle_inject_device *ii_dev)kfree (ii_dev); } +EXPORT_SYMBOL_GPL (idle_inject_unregister);static struct smp_hotplug_thread idle_inject_threads = { .store = &idle_inject_thread.tsk,
Signature · 1 line
2.30.2
RFC PATCH 3/3 thermal/drivers/cpuidle_cooling: cpuidle cooling driver for non DT/ARM
In reply to Srinivas PandruvadaThis driver has same functionality as existing cpuidle_cooling driver. This uses idle injection to cool a CPU. This driver reuses all the code from the existing driver, except the DT specific function.
Each CPU is registered as a cooling device, with type = idle-x, where x is the cpu number.
It registers two module parameters:idle_duration_us : To change default idle duration idle_latency_us : To change default latency
The meaning of these parameters is same as in the existing code. It is described in the header of file drivers/powercap/idle_inject.c.
--- drivers/thermal/Kconfig | 12 ++ drivers/thermal/Makefile | 2 + drivers/thermal/cpuidle_cooling_generic.c | 155 ++++++++++++++++++++++ 3 files changed, 169 insertions(+) create mode 100644 drivers/thermal/cpuidle_cooling_generic.c
drivers/thermal/Kconfig +12 -0
@@ -193,6 +193,18 @@ config CPU_IDLE_THERMAL idle cycle. endif +config CPU_IDLE_THERMAL_GENERIC + tristate "CPU idle cooling device" + depends on !CPU_THERMAL + select CPU_IDLE_THERMAL_CORE + help + This implements the CPU cooling mechanism through + idle injection. This will throttle the CPU by injecting + idle cycle. + + This driver can also be built as a module. If so, the module will + be called cpuidle_cooling_generic. + config DEVFREQ_THERMAL bool "Generic device cooling support" depends on PM_DEVFREQ
drivers/thermal/Makefile +2 -0
@@ -26,6 +26,8 @@ thermal_sys-$(CONFIG_CPU_FREQ_THERMAL) += cpufreq_cooling.o thermal_sys-$(CONFIG_CPU_IDLE_THERMAL_CORE) += cpuidle_cooling_core.o thermal_sys-$(CONFIG_CPU_IDLE_THERMAL) += cpuidle_cooling.o +obj-$(CONFIG_CPU_IDLE_THERMAL_GENERIC) += cpuidle_cooling_generic.o + # devfreq cooling thermal_sys-$(CONFIG_DEVFREQ_THERMAL) += devfreq_cooling.o
drivers/thermal/cpuidle_cooling_generic.c new file +155 -0
155 lines not on this page · raw message
Signature · 1 line
2.30.2
kernel test robot
build botRe: [RFC PATCH 3/3] thermal/drivers/cpuidle_cooling: cpuidle cooling driver for non DT/ARM
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]
Hi Srinivas,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on pm/linux-next]
[also build test ERROR on linus/master v5.14-rc7 next-20210823] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Srinivas-Pandruvada/Reuse-cpuidle-cooling-for-non-DT-ARM/20210824-131908 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next config: mips-randconfig-p001-20210824 (attached as .config) compiler: mipsel-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/c61d8d9d2a308863b1b618e2ff1ff6187af26d96
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Srinivas-Pandruvada/Reuse-cpuidle-cooling-for-non-DT-ARM/20210824-131908 git checkout c61d8d9d2a308863b1b618e2ff1ff6187af26d96
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=mips SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
mipsel-linux-ld: drivers/thermal/cpuidle_cooling_core.o: in function `cpuidle_cooling_set_cur_state':
cpuidle_cooling_core.c:(.text+0xc0): undefined reference to `idle_inject_get_duration'
>> mipsel-linux-ld: cpuidle_cooling_core.c:(.text+0xe8): undefined reference to `idle_inject_set_duration' mipsel-linux-ld: cpuidle_cooling_core.c:(.text+0x12c): undefined reference to `idle_inject_set_duration' >> mipsel-linux-ld: cpuidle_cooling_core.c:(.text+0x13c): undefined reference to `idle_inject_stop' >> mipsel-linux-ld: cpuidle_cooling_core.c:(.text+0x14c): undefined reference to `idle_inject_start' mipsel-linux-ld: drivers/thermal/cpuidle_cooling_generic.o: in function `cpuidle_cooling_register.isra.0': >> cpuidle_cooling_generic.c:(.text+0x104): undefined reference to `idle_inject_register' >> mipsel-linux-ld: cpuidle_cooling_generic.c:(.text+0x120): undefined reference to `idle_inject_set_duration' >> mipsel-linux-ld: cpuidle_cooling_generic.c:(.text+0x130): undefined reference to `idle_inject_set_latency' >> mipsel-linux-ld: cpuidle_cooling_generic.c:(.text+0x238): undefined reference to `idle_inject_unregister' mipsel-linux-ld: drivers/thermal/cpuidle_cooling_generic.o: in function `cpuidle_cooling_exit': >> cpuidle_cooling_generic.c:(.exit.text+0xa4): undefined reference to `idle_inject_unregister'
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for CPU_IDLE_THERMAL_CORE Depends on THERMAL && IDLE_INJECT
Selected by
- CPU_IDLE_THERMAL_GENERIC && THERMAL && !CPU_THERMAL
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org