Difference between revisions of "Linux Dynamic Frequency Scaling"
(→To know whether the driver is working) |
(→Links) |
||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
==Introduction== | ==Introduction== | ||
− | Dynamic Frequency Scaling aka DFS is | + | Dynamic Frequency Scaling aka DFS is available on [[APF27]], [[APF51]], [[APF28]], [[APF6]] and [[OPOS6UL]] based systems. It allows you to control CPU speed according to module activity. |
− | You need to | + | ==Linux configuration== |
+ | You need to have a kernel with the CPUfreq drivers built-in (done by default when available): | ||
<pre class="host"> | <pre class="host"> | ||
$ make linux-menuconfig | $ make linux-menuconfig | ||
</pre> | </pre> | ||
− | |||
<pre class="config"> | <pre class="config"> | ||
CPU Power Management ---> | CPU Power Management ---> | ||
Line 25: | Line 23: | ||
</pre> | </pre> | ||
− | frequency scaling handling is done in ''arch/arm/plat-mxc/cpufreq.c'' or ''arch/arm/mach-mx2/cpufreq_imx27.c'' | + | In old Linux kernels (before device tree), frequency scaling handling is done in ''arch/arm/plat-mxc/cpufreq.c'' or ''arch/arm/mach-mx2/cpufreq_imx27.c'' |
==To know whether the driver is working== | ==To know whether the driver is working== | ||
{| border="1" cellpadding="10" cellspacing="0" summary="DFS check depending on kernel version" class="wikitable" | {| border="1" cellpadding="10" cellspacing="0" summary="DFS check depending on kernel version" class="wikitable" | ||
|- style="background:#efefef;" align="center" | |- style="background:#efefef;" align="center" | ||
− | ! APF27 / APF28 / APF51 || APF6 | + | ! APF27 / APF28 / APF51 || APF6 / OPOS6UL |
|--- | |--- | ||
|<pre class="apf"> | |<pre class="apf"> | ||
Line 45: | Line 43: | ||
# ls | # ls | ||
</pre> | </pre> | ||
+ | {{Note|[[APF6]] may have up to 4 CPU cores so you may end up with ''cpu0'', ''cpu1'', ''cpu2'', ''cpu3'' in ''/sys/devices/system/cpu/''}} | ||
* identify the current governor: | * identify the current governor: | ||
<pre class="apf"> | <pre class="apf"> | ||
Line 53: | Line 52: | ||
<pre class="apf"> | <pre class="apf"> | ||
# cat scaling_available_governors | # cat scaling_available_governors | ||
− | conservative ondemand userspace powersave performance | + | conservative ondemand userspace powersave interactive performance |
</pre> | </pre> | ||
* change governor: | * change governor: | ||
<pre class="apf"> | <pre class="apf"> | ||
# echo powersave > scaling_governor | # echo powersave > scaling_governor | ||
− | |||
− | |||
− | |||
− | |||
</pre> | </pre> | ||
* To know current CPU frequency (here 160MHz): | * To know current CPU frequency (here 160MHz): | ||
Line 74: | Line 69: | ||
800000 585 | 800000 585 | ||
</pre> | </pre> | ||
+ | * change frequency manually (here 133MHz). '''Requires userspace governor !''' : | ||
+ | <pre class="apf"> | ||
+ | # echo 133000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed | ||
+ | </pre> | ||
+ | |||
==Effect on current consumption== | ==Effect on current consumption== | ||
When there is little activity, the CPU frequency has nearly no visible effect on the current consumed. | When there is little activity, the CPU frequency has nearly no visible effect on the current consumed. | ||
Line 79: | Line 79: | ||
This is caused by the "doze mode" : when all processes are sleeping, the kernel turns off the CPU clock until the next IO or timer event. | This is caused by the "doze mode" : when all processes are sleeping, the kernel turns off the CPU clock until the next IO or timer event. | ||
− | When there is a 100% CPU activity, the effect of the CPU frequency can be observed with a | + | When there is a 100% CPU activity, the effect of the CPU frequency can be observed with a ampmeter. |
The % CPU activity per process can be checked with the '''top''' command, which is supported by Busybox (but it may be necessary to configure and rebuild busybox to have it) | The % CPU activity per process can be checked with the '''top''' command, which is supported by Busybox (but it may be necessary to configure and rebuild busybox to have it) | ||
− | {{Note| If you make current measurements using a development board like APF27dev or APF51dev, take care of making all the measurement with the '''same supply voltage'''. | + | {{Note| If you make current measurements using a development board like [[APF27dev]] or [[APF51dev]], take care of making all the measurement with the '''same supply voltage'''. |
Unlike linear regulators, the switching regulator of the board reduces the current consumed when the input voltage is increased (to keep the power constant)}} | Unlike linear regulators, the switching regulator of the board reduces the current consumed when the input voltage is increased (to keep the power constant)}} | ||
Line 88: | Line 88: | ||
==Links== | ==Links== | ||
+ | * https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/tree/Documentation/cpu-freq/governors.txt?h=v4.9.52 | ||
* http://lxr.linux.no/linux+v2.6.37/Documentation/cpu-freq/user-guide.txt | * http://lxr.linux.no/linux+v2.6.37/Documentation/cpu-freq/user-guide.txt | ||
[[Category:Power Management]] | [[Category:Power Management]] |
Latest revision as of 09:52, 3 October 2017
Contents
Introduction
Dynamic Frequency Scaling aka DFS is available on APF27, APF51, APF28, APF6 and OPOS6UL based systems. It allows you to control CPU speed according to module activity.
Linux configuration
You need to have a kernel with the CPUfreq drivers built-in (done by default when available):
$ make linux-menuconfig
CPU Power Management ---> [*] CPU Frequency scaling [*] Enable CPUfreq debugging <*> CPU frequency translation statistics [ ] CPU frequency translation statistics details Default CPUFreq governor (performance) ---> -*- 'performance' governor <*> 'powersave' governor <*> 'userspace' governor for userspace frequency scaling <*> 'ondemand' cpufreq policy governor <*> 'conservative' cpufreq governor <*> CPUfreq driver for i.MX CPUs or <*> i.MX27 frequency driver
In old Linux kernels (before device tree), frequency scaling handling is done in arch/arm/plat-mxc/cpufreq.c or arch/arm/mach-mx2/cpufreq_imx27.c
To know whether the driver is working
APF27 / APF28 / APF51 | APF6 / OPOS6UL |
---|---|
# dmesg | grep freq i.MXC CPU frequency driver |
Should be activated/working by default :-) |
Usage (sysfs)
- all is here:
# cd /sys/devices/system/cpu/cpu0/cpufreq/ # ls
Note: APF6 may have up to 4 CPU cores so you may end up with cpu0, cpu1, cpu2, cpu3 in /sys/devices/system/cpu/ |
- identify the current governor:
# cat scaling_governor performance
- list available governors:
# cat scaling_available_governors conservative ondemand userspace powersave interactive performance
- change governor:
# echo powersave > scaling_governor
- To know current CPU frequency (here 160MHz):
# cat cpuinfo_cur_freq 160000
- To know how much time CPU has spent in its different state (here 160MHz and 800MHz):
# cat stats/time_in_state 160000 243595 800000 585
- change frequency manually (here 133MHz). Requires userspace governor ! :
# echo 133000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
Effect on current consumption
When there is little activity, the CPU frequency has nearly no visible effect on the current consumed.
This is caused by the "doze mode" : when all processes are sleeping, the kernel turns off the CPU clock until the next IO or timer event.
When there is a 100% CPU activity, the effect of the CPU frequency can be observed with a ampmeter.
The % CPU activity per process can be checked with the top command, which is supported by Busybox (but it may be necessary to configure and rebuild busybox to have it)
Note: If you make current measurements using a development board like APF27dev or APF51dev, take care of making all the measurement with the same supply voltage.
Unlike linear regulators, the switching regulator of the board reduces the current consumed when the input voltage is increased (to keep the power constant) |
- To Be Continued...