powercap/drivers/idle_inject: Add an idle injection framework
PATCH v10 1/1 powercap/drivers/idle_inject: Add an idle injection framework
Initially, the cpu_cooling device for ARM was changed by adding a new policy inserting idle cycles. The intel_powerclamp driver does a similar action.
Instead of implementing idle injections privately in the cpu_cooling device, move the idle injection code in a dedicated framework and give the opportunity to other frameworks to make use of it.
The framework relies on the smpboot kthreads which handles via its main loop the common code for hotplugging and [un]parking.
This code was previously tested with the cpu cooling device and went through several iterations. It results now in split code and API exported in the header file. It was tested with the cpu cooling device with success.
---
V10:
- Remove set_freezable (Rafael J. Wysocki)
- Reduce the prefixed names 'injection' by 'inject" (Rafael J. Wysocki)
- Rename 'idle_injection_wakeup_fn()' to 'idle_inject_timer_fn()' (Rafael J. Wysocki)
- Shorten label 'out_rollback_per_cpu' to 'out_rollback' (Rafael J. Wysocki)
V9:
- Unconditionnally reset the should_run flag for all kthreads belonging to the cpumask and remove the park() callback (Viresh Kumar)
- Fix up the typos in the comments (Viresh Kumar)
V8:
- Rollback only what was modified
- Add the park() callback to reset the should_run flag
V7:
- Replace count approach by htimer_forward and restart (Peter Zijlstra)
- Wait for task inactive when stopping the idle injections
- Changed the comments and description
V6:
- Move count to wake up function (Viresh Kumar)
- Split atomic/non-atomic context to wake up tasks
- Add the park callback to handle unplug/inject race
- Replace atomic by READ_ONCE and WRITE_ONCE (Peter Zijlstra)
V5:
- Move init_completion in the init function (Viresh Kumar)
- Increment task count in the wakeup function (Viresh Kumar)
- Remove rollback at init time (Viresh Kumar)
V4:
- Wait for completion when stopping (Viresh Kumar)
- Check init already done and rollback (Viresh Kumar)
V3:
- Fixed typos (Viresh Kumar)
- Removed extra blank line (Viresh Kumar)
- Added full stop (Viresh Kumar)
- Fixed Return kerneldoc format (Viresh Kumar)
- Fixed multiple kthreads initialization (Viresh Kumar)
- Fixed rollbacking the actions in the unregister function (Viresh Kumar)
- Make idle injection kthreads name hardcoded
- Kthreads are created in the initcall process
V2: Fixed checkpatch warnings
--- drivers/powercap/Kconfig | 10 ++ drivers/powercap/Makefile | 1 + drivers/powercap/idle_inject.c | 359 +++++++++++++++++++++++++++++++++++++++++ include/linux/idle_inject.h | 29 ++++ 4 files changed, 399 insertions(+) create mode 100644 drivers/powercap/idle_inject.c create mode 100644 include/linux/idle_inject.h
drivers/powercap/Kconfig +10 -0
@@ -29,4 +29,14 @@ config INTEL_RAPL controller, CPU core (Power Plance 0), graphics uncore (Power Plane 1), etc. +config IDLE_INJECT + bool "Idle injection framework" + depends on CPU_IDLE + default n + help + This enables support for the idle injection framework. It + provides a way to force idle periods on a set of specified + CPUs for power capping. Idle period can be injected + synchronously on a set of specified CPUs or alternatively + on a per CPU basis. endif
drivers/powercap/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-$(CONFIG_POWERCAP) += powercap_sys.o obj-$(CONFIG_INTEL_RAPL) += intel_rapl.o +obj-$(CONFIG_IDLE_INJECT) += idle_inject.o
drivers/powercap/idle_inject.c new file +359 -0
359 lines not on this page · raw message
include/linux/idle_inject.h new file +29 -0
@@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2018 Linaro Ltd +* +* Author: Daniel Lezcano <[email protected]> +* +*/ +#ifndef __IDLE_INJECT_H__ +#define __IDLE_INJECT_H__ + +/* private idle injection device structure */ +struct idle_inject_device ; + +struct idle_inject_device *idle_inject_register (struct cpumask *cpumask); + +void idle_inject_unregister (struct idle_inject_device *ii_dev); + +int idle_inject_start (struct idle_inject_device *ii_dev); + +void idle_inject_stop (struct idle_inject_device *ii_dev); + +void idle_inject_set_duration (struct idle_inject_device *ii_dev, +unsigned int run_duration_ms, +unsigned int idle_duration_ms); + +void idle_inject_get_duration (struct idle_inject_device *ii_dev, +unsigned int *run_duration_ms, +unsigned int *idle_duration_ms); +#endif /* __IDLE_INJECT_H__ */
Signature · 1 line
2.7.4
Quoted 27 lines · Daniel Lezcano
Initially, the
cpu_coolingdevice for ARM was changed by adding a new policy inserting idle cycles. Theintel_powerclampdriver does a similar action.Instead of implementing idle injections privately in the
cpu_coolingdevice, move the idle injection code in a dedicated framework and give the opportunity to other frameworks to make use of it.The framework relies on the smpboot kthreads which handles via its main loop the common code for hotplugging and [un]parking.
This code was previously tested with the cpu cooling device and went through several iterations. It results now in split code and API exported in the header file. It was tested with the cpu cooling device with success.
Signed-off-by Daniel Lezcano <[email protected]>Cc Viresh Kumar <[email protected]>Cc Eduardo Valentin <[email protected]>Cc Javi Merino <[email protected]>Cc Leo Yan <[email protected]>Cc Kevin Wangtao <[email protected]>Cc Vincent Guittot <[email protected]>Cc Rui Zhang <[email protected]>Cc Daniel Thompson <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Andrea Parri <[email protected]>
Quoted 7 lines
---
V10:
- Removeset_freezable(Rafael J. Wysocki)
- Reduce the prefixed names 'injection' by 'inject" (Rafael J. Wysocki)
- Rename 'idle_injection_wakeup_fn()' to 'idle_inject_timer_fn()' (Rafael J. Wysocki)
- Shorten label 'out_rollback_per_cpu' to 'out_rollback' (Rafael J. Wysocki)
Signature · 1 line
viresh
Quoted 30 lines · CEST Viresh Kumar
Quoted 29 lines · Daniel Lezcano
Initially, the
cpu_coolingdevice for ARM was changed by adding a new policy inserting idle cycles. Theintel_powerclampdriver does a similar action.Instead of implementing idle injections privately in the
cpu_coolingdevice, move the idle injection code in a dedicated framework and give the opportunity to other frameworks to make use of it.The framework relies on the smpboot kthreads which handles via its main loop the common code for hotplugging and [un]parking.
This code was previously tested with the cpu cooling device and went through several iterations. It results now in split code and API exported in the header file. It was tested with the cpu cooling device with success.
Signed-off-by Daniel Lezcano <[email protected]>Cc Viresh Kumar <[email protected]>Cc Eduardo Valentin <[email protected]>Cc Javi Merino <[email protected]>Cc Leo Yan <[email protected]>Cc Kevin Wangtao <[email protected]>Cc Vincent Guittot <[email protected]>Cc Rui Zhang <[email protected]>Cc Daniel Thompson <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Andrea Parri <[email protected]>---
Quoted 7 lines
Quoted 5 lines
V10:
- Removeset_freezable(Rafael J. Wysocki)
- Reduce the prefixed names 'injection' by 'inject" (Rafael J. Wysocki)
- Rename 'idle_injection_wakeup_fn()' to 'idle_inject_timer_fn()' (Rafael J. Wysocki)
- Shorten label 'out_rollback_per_cpu' to 'out_rollback' (Rafael J. Wysocki)Reviewed-by Viresh Kumar <[email protected]>
I've applied the patch, but I've rewrittent all of the comments in it.
Daniel, please check the result in linux-next and let me know if you see any problems.
Thanks,
Rafael
Quoted 37 lines · Rafael J. Wysocki
Quoted 36 lines · CEST Viresh Kumar
Quoted 34 lines · Daniel Lezcano
Initially, the
cpu_coolingdevice for ARM was changed by adding a new policy inserting idle cycles. Theintel_powerclampdriver does a similar action.Instead of implementing idle injections privately in the
cpu_coolingdevice, move the idle injection code in a dedicated framework and give the opportunity to other frameworks to make use of it.The framework relies on the smpboot kthreads which handles via its main loop the common code for hotplugging and [un]parking.
This code was previously tested with the cpu cooling device and went through several iterations. It results now in split code and API exported in the header file. It was tested with the cpu cooling device with success.
Signed-off-by Daniel Lezcano <[email protected]>Cc Viresh Kumar <[email protected]>Cc Eduardo Valentin <[email protected]>Cc Javi Merino <[email protected]>Cc Leo Yan <[email protected]>Cc Kevin Wangtao <[email protected]>Cc Vincent Guittot <[email protected]>Cc Rui Zhang <[email protected]>Cc Daniel Thompson <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Andrea Parri <[email protected]>---
V10:
- Removeset_freezable(Rafael J. Wysocki)
- Reduce the prefixed names 'injection' by 'inject" (Rafael J. Wysocki)
- Rename 'idle_injection_wakeup_fn()' to 'idle_inject_timer_fn()' (Rafael J. Wysocki)
- Shorten label 'out_rollback_per_cpu' to 'out_rollback' (Rafael J. Wysocki)
Quoted 6 lines
Quoted 1 line
Reviewed-by Viresh Kumar <[email protected]>I've applied the patch, but I've rewrittent all of the comments in it.
Daniel, please check the result in linux-next and let me know if you see any problems.
I went through the comments and I don't see any problems. Thanks for taking care of making them more clear.
-- Daniel
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
Quoted 27 lines · Daniel Lezcano
Initially, the
cpu_coolingdevice for ARM was changed by adding a new policy inserting idle cycles. Theintel_powerclampdriver does a similar action.Instead of implementing idle injections privately in the
cpu_coolingdevice, move the idle injection code in a dedicated framework and give the opportunity to other frameworks to make use of it.The framework relies on the smpboot kthreads which handles via its main loop the common code for hotplugging and [un]parking.
This code was previously tested with the cpu cooling device and went through several iterations. It results now in split code and API exported in the header file. It was tested with the cpu cooling device with success.
Signed-off-by Daniel Lezcano <[email protected]>Cc Viresh Kumar <[email protected]>Cc Eduardo Valentin <[email protected]>Cc Javi Merino <[email protected]>Cc Leo Yan <[email protected]>Cc Kevin Wangtao <[email protected]>Cc Vincent Guittot <[email protected]>Cc Rui Zhang <[email protected]>Cc Daniel Thompson <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Andrea Parri <[email protected]>
Quoted 7 lines
---
V10:
- Removeset_freezable(Rafael J. Wysocki)
- Reduce the prefixed names 'injection' by 'inject" (Rafael J. Wysocki)
- Rename 'idle_injection_wakeup_fn()' to 'idle_inject_timer_fn()' (Rafael J. Wysocki)
- Shorten label 'out_rollback_per_cpu' to 'out_rollback' (Rafael J. Wysocki)
According to these changes I updated :
https://git.linaro.org/people/daniel.lezcano/linux.git
thermal/idle-inject-v4
-- Daniel
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