<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.somlabs.com/index.php?action=history&amp;feed=atom&amp;title=How_to_scale_CPU_frequency_with_DVFS_framework</id>
	<title>How to scale CPU frequency with DVFS framework - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.somlabs.com/index.php?action=history&amp;feed=atom&amp;title=How_to_scale_CPU_frequency_with_DVFS_framework"/>
	<link rel="alternate" type="text/html" href="https://wiki.somlabs.com/index.php?title=How_to_scale_CPU_frequency_with_DVFS_framework&amp;action=history"/>
	<updated>2026-04-28T06:44:16Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.3</generator>
	<entry>
		<id>https://wiki.somlabs.com/index.php?title=How_to_scale_CPU_frequency_with_DVFS_framework&amp;diff=850&amp;oldid=prev</id>
		<title>Pawelzbysinski at 16:05, 19 May 2018</title>
		<link rel="alternate" type="text/html" href="https://wiki.somlabs.com/index.php?title=How_to_scale_CPU_frequency_with_DVFS_framework&amp;diff=850&amp;oldid=prev"/>
		<updated>2018-05-19T16:05:07Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://wiki.somlabs.com/index.php?title=How_to_scale_CPU_frequency_with_DVFS_framework&amp;amp;diff=850&amp;amp;oldid=849&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Pawelzbysinski</name></author>
	</entry>
	<entry>
		<id>https://wiki.somlabs.com/index.php?title=How_to_scale_CPU_frequency_with_DVFS_framework&amp;diff=849&amp;oldid=prev</id>
		<title>Pawelzbysinski: Created page with &quot;{{PageHeader|How to scale CPU frequency with DVFS framework}} __FORCETOC__ == Intoduction == CPU frequency scaling enables the operating system to scale the CPU frequency in o...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.somlabs.com/index.php?title=How_to_scale_CPU_frequency_with_DVFS_framework&amp;diff=849&amp;oldid=prev"/>
		<updated>2018-05-19T15:14:25Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{PageHeader|How to scale CPU frequency with DVFS framework}} __FORCETOC__ == Intoduction == CPU frequency scaling enables the operating system to scale the CPU frequency in o...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{PageHeader|How to scale CPU frequency with DVFS framework}}&lt;br /&gt;
__FORCETOC__&lt;br /&gt;
== Intoduction ==&lt;br /&gt;
CPU frequency scaling enables the operating system to scale the CPU frequency in order to minimize power usage (saving power when the full performance of the CPU is not needed). CPU frequency scaling is implemented in the Linux kernel as a &amp;#039;&amp;#039;&amp;#039;Dynamic Voltage and Frequency Scaling&amp;#039;&amp;#039;&amp;#039; (DVFS) framework. DVFS allows to set min/max CPU frequency and choose a &amp;#039;&amp;#039;scaling governor&amp;#039;&amp;#039; that governs it. &lt;br /&gt;
&lt;br /&gt;
== Dynamic Frequency Scaling – Linux configuration and sysfs interface ==&lt;br /&gt;
To enable dynamic frequency scaling, we need to have a kernel with the &amp;#039;&amp;#039;CPUfreq&amp;#039;&amp;#039; drivers built-in (done by default when available):&lt;br /&gt;
&lt;br /&gt;
 CPU Power Management  ---&amp;gt;&lt;br /&gt;
    CPU Frequency scaling  ---&amp;gt;&lt;br /&gt;
        [*] CPU Frequency scaling&lt;br /&gt;
        &amp;lt;*&amp;gt;   CPU frequency translation statistics&lt;br /&gt;
        [ ]     CPU frequency translation statistics details&lt;br /&gt;
        &amp;lt;nowiki&amp;gt;*** CPU frequency scaling drivers ***&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
        &amp;lt; &amp;gt;   Generic DT based cpufreq driver&lt;br /&gt;
        &amp;lt;*&amp;gt;   Freescale i.MX6 cpufreq support&lt;br /&gt;
        &amp;lt;*&amp;gt;   Freescale i.MX7 cpufreq support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;#039;&amp;#039;SoMLabs&amp;#039;&amp;#039; modules supports DVFS feature by default, there is no need to perform manual kernel recompilation.&lt;br /&gt;
&lt;br /&gt;
DVFS framework exports information to userspace through sysfs interface:&lt;br /&gt;
&lt;br /&gt;
 root@somlabs:/# &amp;#039;&amp;#039;&amp;#039;ls -l /sys/devices/system/cpu/cpu0/cpufreq/&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 total 0&lt;br /&gt;
 -r--r--r-- 1 root root 4096 Apr 24 06:54 affected_cpus&lt;br /&gt;
 -r-------- 1 root root 4096 Apr 24 06:54 cpuinfo_cur_freq&lt;br /&gt;
 -r--r--r-- 1 root root 4096 Apr 24 06:54 cpuinfo_max_freq&lt;br /&gt;
 -r--r--r-- 1 root root 4096 Apr 24 06:54 cpuinfo_min_freq&lt;br /&gt;
 -r--r--r-- 1 root root 4096 Apr 24 06:54 cpuinfo_transition_latency&lt;br /&gt;
 -r--r--r-- 1 root root 4096 Apr 24 06:54 related_cpus&lt;br /&gt;
 -r--r--r-- 1 root root 4096 Apr 24 06:54 scaling_available_frequencies&lt;br /&gt;
 -r--r--r-- 1 root root 4096 Apr 24 06:54 scaling_available_governors&lt;br /&gt;
 -r--r--r-- 1 root root 4096 Apr 24 06:54 scaling_cur_freq&lt;br /&gt;
 -r--r--r-- 1 root root 4096 Apr 24 06:54 scaling_driver&lt;br /&gt;
 -rw-r--r-- 1 root root 4096 Apr 24 06:54 scaling_governor&lt;br /&gt;
 -rw-r--r-- 1 root root 4096 Apr 24 06:54 scaling_max_freq&lt;br /&gt;
 -rw-r--r-- 1 root root 4096 Apr 24 06:54 scaling_min_freq&lt;br /&gt;
 -rw-r--r-- 1 root root 4096 Apr 24 06:54 scaling_setspeed&lt;br /&gt;
 drwxr-xr-x 2 root root    0 Apr 24 06:54 stats&lt;br /&gt;
&lt;br /&gt;
For dynamic frequency scaling, the most important part of interface is:&lt;br /&gt;
&lt;br /&gt;
{| &lt;br /&gt;
|-&lt;br /&gt;
| scaling_available_frequencies&lt;br /&gt;
| list of available frequencies [kHz]&lt;br /&gt;
|-&lt;br /&gt;
| scaling_available_governors&lt;br /&gt;
| this file shows the CPUfreq governors available in this kernel&lt;br /&gt;
|-&lt;br /&gt;
| scaling_cur_freq&lt;br /&gt;
| current frequency of the CPU as determined by the governor and cpufreq core [kHz]&lt;br /&gt;
|-&lt;br /&gt;
| scaling_governor&lt;br /&gt;
| show the current governor. By &amp;quot;echoing&amp;quot; the name of another governor you can change it&lt;br /&gt;
|-&lt;br /&gt;
| scaling_min_freq&lt;br /&gt;
scaling_max_freq&lt;br /&gt;
| show the current &amp;quot;policy limits&amp;quot; (in kHz). By “echoing” new values into these files, you can change these limits&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
source: &amp;#039;&amp;#039;www.kernel.org/doc/Documentation/cpu-freq/user-guide.txt&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Frequency Scaling How-To ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To get list of supported frequencies for iMX6 ULL SoC:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;root@somlabs:/# &amp;#039;&amp;#039;&amp;#039;cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies&amp;#039;&amp;#039;&amp;#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
198000 396000 528000 792000&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To ask for the current frequency type:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;root@somlabs:/# &amp;#039;&amp;#039;&amp;#039;cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq&amp;#039;&amp;#039;&amp;#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
198000&lt;br /&gt;
&lt;br /&gt;
Now let’s perform simple stress test, to check whether the CPU frequency scaling works corectly:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
root@somlabs:/# &amp;#039;&amp;#039;&amp;#039;dd if=/dev/zero of=/dev/null &amp;amp;&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
root@somlabs:/# &amp;#039;&amp;#039;&amp;#039;cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
792000&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To show the current &amp;quot;policy limits&amp;quot; (lower and upper frequency limits):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
root@somlabs:/# &amp;#039;&amp;#039;&amp;#039;cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
198000&lt;br /&gt;
&lt;br /&gt;
root@somlabs:/# &amp;#039;&amp;#039;&amp;#039;cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
792000&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By “echoing” new values into &amp;lt;tt&amp;gt;scaling_min_freq&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;scaling_max_freq&amp;lt;/tt&amp;gt; files, you can change these limits. For example you can decrease the maximum frequency to 528 MHz:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;root@somlabs:/# &amp;#039;&amp;#039;&amp;#039;echo 528000 &amp;gt; /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq&amp;#039;&amp;#039;&amp;#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Scaling Governors ==&lt;br /&gt;
The strategy of frequency scaling is controlled by the &amp;quot;governor&amp;quot; which continuosly monitors the system perfomance requirements. The “scaling governor” decides, what CPU frequency is used at each time.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Linux offers different CPU scaling governors. Let’s list all available governors with the following command:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
root@somlabs:/# &amp;#039;&amp;#039;&amp;#039;cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
interactive conservative userspace powersave ondemand performance&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;border-spacing:0;margin:auto;width:17.006cm;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border-top:0.05pt solid #000000;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;&amp;quot; | userspace&lt;br /&gt;
| style=&amp;quot;border:0.05pt solid #000000;padding:0.097cm;&amp;quot; | allows the user or any userspace&lt;br /&gt;
&lt;br /&gt;
program running with UID &amp;quot;root&amp;quot;, to set the CPU to a specific frequency by making a sysfs file &amp;#039;&amp;#039;scaling_setspeed&amp;#039;&amp;#039; available in the CPU-device directory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;&amp;quot; | powersave&lt;br /&gt;
| style=&amp;quot;border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;&amp;quot; | sets the CPU statically to the lowest frequency within the borders of &amp;#039;&amp;#039;scaling_min_freq&amp;#039;&amp;#039; and &amp;#039;&amp;#039;scaling_max_freq&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;&amp;quot; | ondemand&lt;br /&gt;
| style=&amp;quot;border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;&amp;quot; | sets the CPU frequency depending on the current system load&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;&amp;quot; | performance&lt;br /&gt;
| style=&amp;quot;border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;&amp;quot; | sets the CPU statically to the highest frequency within the borders of &amp;#039;&amp;#039;scaling_min_freq&amp;#039;&amp;#039; and &amp;#039;&amp;#039;scaling_max_freq&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;&amp;quot; | interactive&lt;br /&gt;
| style=&amp;quot;border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;&amp;quot; | designed for latency-sensitive,&lt;br /&gt;
&lt;br /&gt;
interactive workloads; this governor&lt;br /&gt;
&lt;br /&gt;
sets the CPU speed dependin on&lt;br /&gt;
&lt;br /&gt;
usage, similar to &amp;quot;ondemand&amp;quot; and&lt;br /&gt;
&lt;br /&gt;
&amp;quot;conservative&amp;quot; governors; however,&lt;br /&gt;
&lt;br /&gt;
the governor is more aggressive about&lt;br /&gt;
&lt;br /&gt;
scaling the CPU speed up in&lt;br /&gt;
&lt;br /&gt;
response to CPU-intensive activity&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;&amp;quot; | conservative&lt;br /&gt;
| style=&amp;quot;border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;&amp;quot; | much like the &amp;quot;ondemand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
governor, sets the CPU depending on&lt;br /&gt;
&lt;br /&gt;
the current usage. It differs in&lt;br /&gt;
&lt;br /&gt;
behaviour in that it gracefully&lt;br /&gt;
&lt;br /&gt;
increases and decreases the CPU&lt;br /&gt;
&lt;br /&gt;
speed rather than jumping to max&lt;br /&gt;
&lt;br /&gt;
speed the moment there is any load&lt;br /&gt;
&lt;br /&gt;
on the CPU. This behaviour more&lt;br /&gt;
&lt;br /&gt;
suitable in a battery powered&lt;br /&gt;
&lt;br /&gt;
environment&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
(source: &amp;#039;&amp;#039;www.kernel.org/doc/Documentation/cpu-freq/governors.txt&amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In case of &amp;#039;&amp;#039;SoMLabs&amp;#039;&amp;#039; modules, default governor is &amp;#039;&amp;#039;ondemand&amp;#039;&amp;#039;. The default governor (and list of available governors) can be configured through &amp;#039;&amp;#039;make menuconfig&amp;#039;&amp;#039; tool:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CPU Power Management  ---&amp;gt;&lt;br /&gt;
    CPU Frequency scaling  ---&amp;gt;&lt;br /&gt;
        Default CPUFreq governor (ondemand)  --→&lt;br /&gt;
    -*-   &amp;#039;performance&amp;#039; governor&lt;br /&gt;
    &amp;lt;*&amp;gt;   &amp;#039;powersave&amp;#039; governor  &lt;br /&gt;
    &amp;lt;*&amp;gt;   &amp;#039;userspace&amp;#039; governor for userspace frequency scaling&lt;br /&gt;
    -*-   &amp;#039;ondemand&amp;#039; cpufreq policy governor&lt;br /&gt;
    &amp;lt;*&amp;gt;   &amp;#039;interactive&amp;#039; cpufreq policy governor&lt;br /&gt;
    &amp;lt;*&amp;gt;   &amp;#039;conservative&amp;#039; cpufreq governor &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To switch over to another governor (for example &amp;#039;&amp;#039;powersave&amp;#039;&amp;#039;):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
root@somlabs:/# &amp;#039;&amp;#039;&amp;#039;echo powersave &amp;gt; /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
powersave&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In order to ask for the current governor:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
root@somlabs:/# &amp;#039;&amp;#039;&amp;#039;cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
powersave&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To find out more about the governors, please visit:&lt;br /&gt;
&lt;br /&gt;
[http://www.kernel.org/doc/Documentation/cpu-freq/governors.txt www.kernel.org/doc/Documentation/cpu-freq/governors.txt]&lt;/div&gt;</summary>
		<author><name>Pawelzbysinski</name></author>
	</entry>
</feed>