pm_qos: Rename freq to interval constraint
Subsystems (8)
RFC PATCH 1/2 pm_qos: Rename freq to interval constraint
The frequency pm_qos relies on a couple of values, the min and max frequencies. However more pm_qos will be added with the same logic of a couple of min and max. Instead of writing new set of constraints as well as type, etc... let's rename freq_* to a more generic name interval_*
That way, new qos interval based can be added easily.
--- drivers/base/power/qos.c | 4 +-- drivers/powercap/dtpm_cpu.c | 2 +- drivers/thermal/cpufreq_cooling.c | 2 +- include/linux/cpufreq.h | 6 ++-- include/linux/pm_qos.h | 55 ++++++++++++++++--------------- kernel/power/qos.c | 53 +++++++++++++++-------------- 6 files changed, 61 insertions(+), 61 deletions(-)
drivers/base/power/qos.c +2 -2
@@ -285,14 +285,14 @@ void dev_pm_qos_constraints_destroy(struct device *dev)memset (req,0 ,sizeof (*req)); } - c = &qos->freq.min_freq; + c = &qos->freq.min;plist_for_each_entry_safe (req, tmp, &c->list, data.freq.pnode) {apply_constraint (req,PM_QOS_REMOVE_REQ ,PM_QOS_MIN_FREQUENCY_DEFAULT_VALUE );memset (req,0 ,sizeof (*req)); } - c = &qos->freq.max_freq; + c = &qos->freq.max;plist_for_each_entry_safe (req, tmp, &c->list, data.freq.pnode) {apply_constraint (req,PM_QOS_REMOVE_REQ ,PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE );
drivers/powercap/dtpm_cpu.c +1 -1
@@ -28,7 +28,7 @@struct dtpm_cpu {struct dtpm dtpm; -struct freq_qos_request qos_req; +struct interval_qos_request qos_req;int cpu; };
drivers/thermal/cpufreq_cooling.c +1 -1
@@ -77,7 +77,7 @@ struct cpufreq_cooling_device {#ifndef CONFIG_SMP struct time_in_idle *idle_time;#endif -struct freq_qos_request qos_req; +struct interval_qos_request qos_req; };#ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR
include/linux/cpufreq.h +3 -3
@@ -80,9 +80,9 @@ struct cpufreq_policy {struct work_struct update;/* if update_policy() needs to be * called, but you're in IRQ context */ -struct freq_constraints constraints; -struct freq_qos_request *min_freq_req; -struct freq_qos_request *max_freq_req; +struct interval_constraints constraints; +struct interval_qos_request *min_freq_req; +struct interval_qos_request *max_freq_req;struct cpufreq_frequency_table *freq_table;enum cpufreq_table_sorting freq_table_sorted;
include/linux/pm_qos.h +28 -27
96 lines not on this page · raw message
kernel/power/qos.c +26 -27
154 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 2/2 PM: QoS: Add a performance QoS
Currently cpufreq and devfreq are using the freq QoS to aggregate the requests for frequency minimum and maximum limits.
However, there are new devices wanting to act not on a frequency limit but on a performance index limit. Those need also to export to userspace the knob to act on their performance limits.
This change provides a performance limiter QoS based on a minimum / maximum performance values. At init time, the limits of the interval are 0 / 1024. It is up to the backend to convert the 1024 to the maximum performance state. So if the performance must be limited to 50%, it should set to maximum limit to 512 where the backend will end up by converting (max performance index / 2). The same applies for the minimum. Obviously, the min can not be greater than the max.
There are a couple of things making this change a RFC:
1. With the example above, if there is a odd number like 5 for the number of performance indexes and we ask for 512 (so 50%), what would be the performance index computed? (5/2=2 or 5/2=3)? (I would say the minimum otherwise we end up with a performance limit greater than what we actually asked for).
2. The conversion from 1024 to a performance index will inevatibly end up to a state above or below the percentage given. Shall it be reflected in the value set? eg. We want to apply a performance limit to be 33% maximum. So it is, 1024 x 0.333333 = 314. If there are 20 performance indexes, that will be (20 x 314) / 1024 = 6.13, so index
6. Shall we convert this index back to the requested performance limit to (6.13 x 1024) / 20 = 307 ? (So requested is 314 but it is actually 307).
The end goal is to make the freq QoS and perf QoS to co-exist together in the next changes in the different backends. A change of one of the QoS impacts the other. For instance if there are 5 performance states and we set a performance limit to 80%, then the maximum state will 4.
For the long term, when those can co-exist, then we can implement a cooling device based on the performance Qos which will be generic for all devices using this QoS. That will imply the CPUs, the GPUs and any devfreq devices. So devfreq and cpufreq cooling devices can be merged into a single performance cooling device which will be generic for all devices with a performance limit QoS.
In a similar way, in the future, a power QoS could be added also and a power based cooling device. So any device with the energy model can become a cooling device and the power computation part in the cooling devices will move to the back ends. We will end up with a generic power cooling device compatible with all power capable devices.
--- drivers/base/power/power.h | 2 + drivers/base/power/qos.c | 158 +++++++++++++++++++++++++- drivers/base/power/sysfs.c | 92 +++++++++++++++ include/linux/cpufreq.h | 2 + include/linux/pm_qos.h | 42 +++++++ kernel/power/qos.c | 225 +++++++++++++++++++++++++++++++++++++ 6 files changed, 517 insertions(+), 4 deletions(-)
drivers/base/power/power.h +2 -0
@@ -78,6 +78,8 @@ extern int pm_qos_sysfs_add_flags(struct device *dev);extern void pm_qos_sysfs_remove_flags (struct device *dev);extern int pm_qos_sysfs_add_latency_tolerance (struct device *dev);extern void pm_qos_sysfs_remove_latency_tolerance (struct device *dev); +extern int pm_qos_sysfs_add_perf_limit (struct device *dev); +extern void pm_qos_sysfs_remove_perf_limit (struct device *dev);extern int dpm_sysfs_change_owner (struct device *dev,kuid_t kuid,kgid_t kgid);#else /* CONFIG_PM */
drivers/base/power/qos.c +154 -4
210 lines not on this page · raw message
drivers/base/power/sysfs.c +92 -0
110 lines not on this page · raw message
include/linux/cpufreq.h +2 -0
@@ -83,6 +83,8 @@ struct cpufreq_policy {struct interval_constraints constraints;struct interval_qos_request *min_freq_req;struct interval_qos_request *max_freq_req; +struct interval_qos_request *min_perf_req; +struct interval_qos_request *max_perf_req;struct cpufreq_frequency_table *freq_table;enum cpufreq_table_sorting freq_table_sorted;
include/linux/pm_qos.h +42 -0
92 lines not on this page · raw message
kernel/power/qos.c +225 -0
228 lines not on this page · raw message
Signature · 1 line
2.34.1
kernel test robot
build botRe: [RFC PATCH 2/2] PM: QoS: Add a performance QoS
kernel test robot noticed the following build errors:
Hi Daniel,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on rafael-pm/linux-next]
[also build test ERROR on rafael-pm/acpi-bus rafael-pm/thermal linus/master rafael-pm/devprop v6.7-rc4 next-20231205] [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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Daniel-Lezcano/PM-QoS-Add-a-performance-QoS/20231202-031119 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next patch link: https://lore.kernel.org/r/20231201190757.144741-2-daniel.lezcano%40linaro.org patch subject: [RFC PATCH 2/2] PM: QoS: Add a performance QoS config: parisc-randconfig-001-20231203 (https://download.01.org/0day-ci/archive/20231205/[email protected]/config) compiler: hppa-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231205/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
hppa-linux-ld: drivers/ufs/core/ufs-sysfs.o: in function `dev_pm_qos_hide_perf_limit':
>> (.text.dev_pm_qos_hide_perf_limit+0x0): multiple definition of `dev_pm_qos_hide_perf_limit'; drivers/ufs/core/ufshcd.o:(.text.dev_pm_qos_hide_perf_limit+0x0): first defined here hppa-linux-ld: drivers/ufs/core/ufs-mcq.o: in function `dev_pm_qos_hide_perf_limit': >> (.text.dev_pm_qos_hide_perf_limit+0x0): multiple definition of `dev_pm_qos_hide_perf_limit'; drivers/ufs/core/ufshcd.o:(.text.dev_pm_qos_hide_perf_limit+0x0): first defined here hppa-linux-ld: drivers/ufs/core/ufs-debugfs.o: in function `dev_pm_qos_hide_perf_limit': >> (.text.dev_pm_qos_hide_perf_limit+0x0): multiple definition of `dev_pm_qos_hide_perf_limit'; drivers/ufs/core/ufshcd.o:(.text.dev_pm_qos_hide_perf_limit+0x0): first defined here hppa-linux-ld: drivers/ufs/core/ufs_bsg.o: in function `dev_pm_qos_hide_perf_limit': >> (.text.dev_pm_qos_hide_perf_limit+0x0): multiple definition of `dev_pm_qos_hide_perf_limit'; drivers/ufs/core/ufshcd.o:(.text.dev_pm_qos_hide_perf_limit+0x0): first defined here
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [RFC PATCH 2/2] PM: QoS: Add a performance QoS
In reply to Daniel Lezcanokernel test robot noticed the following build errors:
Hi Daniel,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on rafael-pm/linux-next]
[also build test ERROR on rafael-pm/acpi-bus rafael-pm/thermal linus/master rafael-pm/devprop v6.7-rc4 next-20231205] [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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Daniel-Lezcano/PM-QoS-Add-a-performance-QoS/20231202-031119 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next patch link: https://lore.kernel.org/r/20231201190757.144741-2-daniel.lezcano%40linaro.org patch subject: [RFC PATCH 2/2] PM: QoS: Add a performance QoS config: powerpc-randconfig-002-20231203 (https://download.01.org/0day-ci/archive/20231205/[email protected]/config) compiler: powerpc-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231205/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
powerpc-linux-ld: sound/aoa/core/alsa.o: in function `dev_pm_qos_hide_perf_limit':
>> alsa.c:(.text+0x230): multiple definition of `dev_pm_qos_hide_perf_limit'; sound/aoa/core/core.o:core.c:(.text+0x690): first defined here
powerpc-linux-ld: sound/aoa/core/gpio-pmf.o: in function `dev_pm_qos_hide_perf_limit':
gpio-pmf.c:(.text+0xef4): multiple definition of `dev_pm_qos_hide_perf_limit'; sound/aoa/core/core.o:core.c:(.text+0x690): first defined here
powerpc-linux-ld: sound/aoa/core/gpio-feature.o: in function `dev_pm_qos_hide_perf_limit':
gpio-feature.c:(.text+0x1ad0): multiple definition of `dev_pm_qos_hide_perf_limit'; sound/aoa/core/core.o:core.c:(.text+0x690): first defined here
--
powerpc-linux-ld: sound/aoa/soundbus/sysfs.o: in function `dev_pm_qos_hide_perf_limit':
>> sysfs.c:(.text+0x170): multiple definition of `dev_pm_qos_hide_perf_limit'; sound/aoa/soundbus/core.o:core.c:(.text+0x6d0): first defined here
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Daniel,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on rafael-pm/linux-next]
[also build test ERROR on rafael-pm/acpi-bus rafael-pm/thermal linus/master rafael-pm/devprop v6.7-rc4 next-20231205] [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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Daniel-Lezcano/PM-QoS-Add-a-performance-QoS/20231202-031119 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next patch link: https://lore.kernel.org/r/20231201190757.144741-1-daniel.lezcano%40linaro.org patch subject: [RFC PATCH 1/2] pm_qos: Rename freq to interval constraint config: i386-buildonly-randconfig-001-20231203 (https://download.01.org/0day-ci/archive/20231205/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231205/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from drivers/cpufreq/intel_pstate.c:45:
include/acpi/processor.h:240:33: error: field 'perflib_req' has incomplete type
240 | struct freq_qos_request perflib_req;
| ^~~~~~~~~~~
include/acpi/processor.h:241:33: error: field 'thermal_req' has incomplete type
241 | struct freq_qos_request thermal_req;
| ^~~~~~~~~~~
drivers/cpufreq/intel_pstate.c:1323:37: warning: 'enum freq_qos_req_type' declared inside parameter list will not be visible outside of this definition or declaration
1323 | static void update_qos_request(enum freq_qos_req_type type)
| ^~~~~~~~~~~~~~~~~
drivers/cpufreq/intel_pstate.c:1323:55: error: parameter 1 ('type') has incomplete type
1323 | static void update_qos_request(enum freq_qos_req_type type)
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~
drivers/cpufreq/intel_pstate.c:1323:13: error: function declaration isn't a prototype [-Werror=strict-prototypes]
1323 | static void update_qos_request(enum freq_qos_req_type type)
| ^~~~~~~~~~~~~~~~~~
drivers/cpufreq/intel_pstate.c: In function 'update_qos_request':
drivers/cpufreq/intel_pstate.c:1349:28: error: increment of pointer to an incomplete type 'struct freq_qos_request'
1349 | req++;
| ^~
drivers/cpufreq/intel_pstate.c:1355:45: error: passing argument 1 of 'freq_qos_update_request' from incompatible pointer type [-Werror=incompatible-pointer-types]
1355 | if (freq_qos_update_request(req, freq) < 0)
| ^~~
| |
| struct freq_qos_request *
In file included from include/linux/cpufreq.h:19,
from drivers/cpufreq/intel_pstate.c:21:
include/linux/pm_qos.h:308:58: note: expected 'struct interval_qos_request *' but argument is of type 'struct freq_qos_request *'
308 | int freq_qos_update_request(struct interval_qos_request *req, s32 new_value);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
drivers/cpufreq/intel_pstate.c: In function 'intel_cpufreq_cpu_init':
>> drivers/cpufreq/intel_pstate.c:3004:32: error: invalid application of 'sizeof' to incomplete type 'struct freq_qos_request'
3004 | req = kcalloc(2, sizeof(*req), GFP_KERNEL);
| ^
drivers/cpufreq/intel_pstate.c:3029:58: error: passing argument 2 of 'freq_qos_add_request' from incompatible pointer type [-Werror=incompatible-pointer-types]
3029 | ret = freq_qos_add_request(&policy->constraints, req, FREQ_QOS_MIN,
| ^~~
| |
| struct freq_qos_request *
include/linux/pm_qos.h:306:55: note: expected 'struct interval_qos_request *' but argument is of type 'struct freq_qos_request *'
306 | struct interval_qos_request *req,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
drivers/cpufreq/intel_pstate.c:3038:62: error: invalid use of undefined type 'struct freq_qos_request'
3038 | ret = freq_qos_add_request(&policy->constraints, req + 1, FREQ_QOS_MAX,
| ^
drivers/cpufreq/intel_pstate.c:3038:62: error: passing argument 2 of 'freq_qos_add_request' from incompatible pointer type [-Werror=incompatible-pointer-types]
3038 | ret = freq_qos_add_request(&policy->constraints, req + 1, FREQ_QOS_MAX,
| ~~~~^~~
| |
| struct freq_qos_request *
include/linux/pm_qos.h:306:55: note: expected 'struct interval_qos_request *' but argument is of type 'struct freq_qos_request *'
306 | struct interval_qos_request *req,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
drivers/cpufreq/intel_pstate.c:3050:33: error: passing argument 1 of 'freq_qos_remove_request' from incompatible pointer type [-Werror=incompatible-pointer-types]
3050 | freq_qos_remove_request(req);
| ^~~
| |
| struct freq_qos_request *
include/linux/pm_qos.h:309:58: note: expected 'struct interval_qos_request *' but argument is of type 'struct freq_qos_request *'
309 | int freq_qos_remove_request(struct interval_qos_request *req);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
drivers/cpufreq/intel_pstate.c: In function 'intel_cpufreq_cpu_exit':
drivers/cpufreq/intel_pstate.c:3065:37: error: invalid use of undefined type 'struct freq_qos_request'
3065 | freq_qos_remove_request(req + 1);
| ^
drivers/cpufreq/intel_pstate.c:3065:37: error: passing argument 1 of 'freq_qos_remove_request' from incompatible pointer type [-Werror=incompatible-pointer-types]
3065 | freq_qos_remove_request(req + 1);
| ~~~~^~~
| |
| struct freq_qos_request *
include/linux/pm_qos.h:309:58: note: expected 'struct interval_qos_request *' but argument is of type 'struct freq_qos_request *'
309 | int freq_qos_remove_request(struct interval_qos_request *req);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
drivers/cpufreq/intel_pstate.c:3066:33: error: passing argument 1 of 'freq_qos_remove_request' from incompatible pointer type [-Werror=incompatible-pointer-types]
3066 | freq_qos_remove_request(req);
| ^~~
| |
| struct freq_qos_request *
include/linux/pm_qos.h:309:58: note: expected 'struct interval_qos_request *' but argument is of type 'struct freq_qos_request *'
309 | int freq_qos_remove_request(struct interval_qos_request *req);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~cc1: some warnings being treated as errors
vim +3004 drivers/cpufreq/intel_pstate.c
a365ab6b9dfbaf8 Rafael J. Wysocki 2020-12-14 2984
001c76f05b01cc8 Rafael J. Wysocki 2016-11-17 2985 static int intel_cpufreq_cpu_init(struct cpufreq_policy *policy)
001c76f05b01cc8 Rafael J. Wysocki 2016-11-17 2986 {
3000ce3c52f8b8d Rafael J. Wysocki 2019-10-16 2987 struct freq_qos_request *req;
da5c504c7aae96d Viresh Kumar 2019-08-09 2988 struct cpudata *cpu;
da5c504c7aae96d Viresh Kumar 2019-08-09 2989 struct device *dev;
de5bcf404acee62 Rafael J. Wysocki 2021-03-16 2990 int ret, freq;
da5c504c7aae96d Viresh Kumar 2019-08-09 2991
da5c504c7aae96d Viresh Kumar 2019-08-09 2992 dev = get_cpu_device(policy->cpu);
da5c504c7aae96d Viresh Kumar 2019-08-09 2993 if (!dev)
da5c504c7aae96d Viresh Kumar 2019-08-09 2994 return -ENODEV;
001c76f05b01cc8 Rafael J. Wysocki 2016-11-17 2995
da5c504c7aae96d Viresh Kumar 2019-08-09 2996 ret = __intel_pstate_cpu_init(policy);
001c76f05b01cc8 Rafael J. Wysocki 2016-11-17 2997 if (ret)
001c76f05b01cc8 Rafael J. Wysocki 2016-11-17 2998 return ret;
001c76f05b01cc8 Rafael J. Wysocki 2016-11-17 2999
001c76f05b01cc8 Rafael J. Wysocki 2016-11-17 3000 policy->cpuinfo.transition_latency = INTEL_CPUFREQ_TRANSITION_LATENCY;
001c76f05b01cc8 Rafael J. Wysocki 2016-11-17 3001 /* This reflects the intel_pstate_get_cpu_pstates() setting. */
001c76f05b01cc8 Rafael J. Wysocki 2016-11-17 3002 policy->cur = policy->cpuinfo.min_freq;
001c76f05b01cc8 Rafael J. Wysocki 2016-11-17 3003
da5c504c7aae96d Viresh Kumar 2019-08-09 @3004 req = kcalloc(2, sizeof(*req), GFP_KERNEL);
da5c504c7aae96d Viresh Kumar 2019-08-09 3005 if (!req) {
da5c504c7aae96d Viresh Kumar 2019-08-09 3006 ret = -ENOMEM;
da5c504c7aae96d Viresh Kumar 2019-08-09 3007 goto pstate_exit;
da5c504c7aae96d Viresh Kumar 2019-08-09 3008 }
da5c504c7aae96d Viresh Kumar 2019-08-09 3009
da5c504c7aae96d Viresh Kumar 2019-08-09 3010 cpu = all_cpu_data[policy->cpu];
da5c504c7aae96d Viresh Kumar 2019-08-09 3011
f6ebbcf08f37b01 Rafael J. Wysocki 2020-08-06 3012 if (hwp_active) {
f6ebbcf08f37b01 Rafael J. Wysocki 2020-08-06 3013 u64 value;
f6ebbcf08f37b01 Rafael J. Wysocki 2020-08-06 3014
f6ebbcf08f37b01 Rafael J. Wysocki 2020-08-06 3015 policy->transition_delay_us = INTEL_CPUFREQ_TRANSITION_DELAY_HWP;
de5bcf404acee62 Rafael J. Wysocki 2021-03-16 3016
de5bcf404acee62 Rafael J. Wysocki 2021-03-16 3017 intel_pstate_get_hwp_cap(cpu);
de5bcf404acee62 Rafael J. Wysocki 2021-03-16 3018
f6ebbcf08f37b01 Rafael J. Wysocki 2020-08-06 3019 rdmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, &value);
f6ebbcf08f37b01 Rafael J. Wysocki 2020-08-06 3020 WRITE_ONCE(cpu->hwp_req_cached, value);
de5bcf404acee62 Rafael J. Wysocki 2021-03-16 3021
c27a0ccc3c715c5 Rafael J. Wysocki 2020-08-27 3022 cpu->epp_cached = intel_pstate_get_epp(cpu, value);
f6ebbcf08f37b01 Rafael J. Wysocki 2020-08-06 3023 } else {
f6ebbcf08f37b01 Rafael J. Wysocki 2020-08-06 3024 policy->transition_delay_us = INTEL_CPUFREQ_TRANSITION_DELAY;
f6ebbcf08f37b01 Rafael J. Wysocki 2020-08-06 3025 }
da5c504c7aae96d Viresh Kumar 2019-08-09 3026
de5bcf404acee62 Rafael J. Wysocki 2021-03-16 3027 freq = DIV_ROUND_UP(cpu->pstate.turbo_freq * global.min_perf_pct, 100);
da5c504c7aae96d Viresh Kumar 2019-08-09 3028
3000ce3c52f8b8d Rafael J. Wysocki 2019-10-16 3029 ret = freq_qos_add_request(&policy->constraints, req, FREQ_QOS_MIN,
de5bcf404acee62 Rafael J. Wysocki 2021-03-16 3030 freq);
da5c504c7aae96d Viresh Kumar 2019-08-09 3031 if (ret < 0) {
da5c504c7aae96d Viresh Kumar 2019-08-09 3032 dev_err(dev, "Failed to add min-freq constraint (%d)\n", ret);
da5c504c7aae96d Viresh Kumar 2019-08-09 3033 goto free_req;
da5c504c7aae96d Viresh Kumar 2019-08-09 3034 }
da5c504c7aae96d Viresh Kumar 2019-08-09 3035
de5bcf404acee62 Rafael J. Wysocki 2021-03-16 3036 freq = DIV_ROUND_UP(cpu->pstate.turbo_freq * global.max_perf_pct, 100);
de5bcf404acee62 Rafael J. Wysocki 2021-03-16 3037
3000ce3c52f8b8d Rafael J. Wysocki 2019-10-16 3038 ret = freq_qos_add_request(&policy->constraints, req + 1, FREQ_QOS_MAX,
de5bcf404acee62 Rafael J. Wysocki 2021-03-16 3039 freq);
da5c504c7aae96d Viresh Kumar 2019-08-09 3040 if (ret < 0) {
da5c504c7aae96d Viresh Kumar 2019-08-09 3041 dev_err(dev, "Failed to add max-freq constraint (%d)\n", ret);
da5c504c7aae96d Viresh Kumar 2019-08-09 3042 goto remove_min_req;
da5c504c7aae96d Viresh Kumar 2019-08-09 3043 }
da5c504c7aae96d Viresh Kumar 2019-08-09 3044
da5c504c7aae96d Viresh Kumar 2019-08-09 3045 policy->driver_data = req;
da5c504c7aae96d Viresh Kumar 2019-08-09 3046
001c76f05b01cc8 Rafael J. Wysocki 2016-11-17 3047 return 0;
da5c504c7aae96d Viresh Kumar 2019-08-09 3048
da5c504c7aae96d Viresh Kumar 2019-08-09 3049 remove_min_req:
3000ce3c52f8b8d Rafael J. Wysocki 2019-10-16 3050 freq_qos_remove_request(req);
da5c504c7aae96d Viresh Kumar 2019-08-09 3051 free_req:
da5c504c7aae96d Viresh Kumar 2019-08-09 3052 kfree(req);
da5c504c7aae96d Viresh Kumar 2019-08-09 3053 pstate_exit:
da5c504c7aae96d Viresh Kumar 2019-08-09 3054 intel_pstate_exit_perf_limits(policy);
da5c504c7aae96d Viresh Kumar 2019-08-09 3055
da5c504c7aae96d Viresh Kumar 2019-08-09 3056 return ret;
da5c504c7aae96d Viresh Kumar 2019-08-09 3057 }
da5c504c7aae96d Viresh Kumar 2019-08-09 3058 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Rafael J. Wysocki
maintainerQuoted 6 lines · Daniel Lezcano
The frequency
pm_qosrelies on a couple of values, the min and max frequencies. However morepm_qoswill be added with the same logic of a couple of min and max. Instead of writing new set of constraints as well as type, etc... let's rename freq_* to a more generic name interval_*
I'm fine with a rename if it helps, but I would rather call it range_* than interval_*.
Quoted 95 lines
That way, new qos interval based can be added easily.
Signed-off-by Daniel Lezcano <[email protected]>--- drivers/base/power/qos.c | 4 +-- drivers/powercap/dtpm_cpu.c | 2 +- drivers/thermal/cpufreq_cooling.c | 2 +- include/linux/cpufreq.h | 6 ++-- include/linux/pm_qos.h | 55 ++++++++++++++++--------------- kernel/power/qos.c | 53 +++++++++++++++-------------- 6 files changed, 61 insertions(+), 61 deletions(-)drivers/base/power/qos.c +2
-2@@ -285,14 +285,14 @@ void dev_pm_qos_constraints_destroy(struct device *dev)memset (req,0 ,sizeof (*req)); } - c = &qos->freq.min_freq; + c = &qos->freq.min;plist_for_each_entry_safe (req, tmp, &c->list, data.freq.pnode) {apply_constraint (req,PM_QOS_REMOVE_REQ ,PM_QOS_MIN_FREQUENCY_DEFAULT_VALUE );memset (req,0 ,sizeof (*req)); } - c = &qos->freq.max_freq; + c = &qos->freq.max;plist_for_each_entry_safe (req, tmp, &c->list, data.freq.pnode) {apply_constraint (req,PM_QOS_REMOVE_REQ ,PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE );drivers/powercap/dtpm_cpu.c +1
-1@@ -28,7 +28,7 @@struct dtpm_cpu {struct dtpm dtpm; -struct freq_qos_request qos_req; +struct interval_qos_request qos_req;int cpu; };drivers/thermal/cpufreq_cooling.c +1
-1@@ -77,7 +77,7 @@ struct cpufreq_cooling_device {#ifndef CONFIG_SMP struct time_in_idle *idle_time;#endif -struct freq_qos_request qos_req; +struct interval_qos_request qos_req; };#ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR include/linux/cpufreq.h +3
-3@@ -80,9 +80,9 @@ struct cpufreq_policy {struct work_struct update;/* if update_policy() needs to be * called, but you're in IRQ context */ -struct freq_constraints constraints; -struct freq_qos_request *min_freq_req; -struct freq_qos_request *max_freq_req; +struct interval_constraints constraints; +struct interval_qos_request *min_freq_req; +struct interval_qos_request *max_freq_req;struct cpufreq_frequency_table *freq_table;enum cpufreq_table_sorting freq_table_sorted;include/linux/pm_qos.h +4
-3@@ -77,25 +77,26 @@ struct pm_qos_flags {#define FREQ_QOS_MIN_DEFAULT_VALUE 0#define FREQ_QOS_MAX_DEFAULT_VALUE S32_MAX -enum freq_qos_req_type { -FREQ_QOS_MIN =1 , +enum interval_qos_req_type { +INTERVAL_QOS_MIN =1 , +INTERVAL_QOS_MAX , +FREQ_QOS_MIN ,FREQ_QOS_MAX , }; -struct freq_constraints {
include/linux/pm_qos.h struct pm_qos_flags { · line 92
Quoted 10 lines
include/linux/pm_qos.h +5
-4-struct pm_qos_constraints min_freq; -struct blocking_notifier_head min_freq_notifiers; -struct pm_qos_constraints max_freq; -struct blocking_notifier_head max_freq_notifiers; +struct interval_constraints { +struct pm_qos_constraints min; +struct blocking_notifier_head min_notifiers; +struct pm_qos_constraints max; +struct blocking_notifier_head max_notifiers; };
Also I would rename min_freq and max_freq to lower_bound and upper_bound, respectively, because this is less likely to get confused with other things with the same name.
So the above would be
+struct range_constraints {
+ struct pm_qos_constraints lower_bound; + struct blocking_notifier_head lower_bound_notifiers; + struct pm_qos_constraints upper_bound; + struct blocking_notifier_head upper_bound_notifiers;
};