📜 ⬆️ ⬇️

The policy of controlling the frequency of the processor "ondemand" and iowait in Ubuntu

In modern versions of Ubuntu, the ondemand frequency control policy is enabled by default. This thing is very useful in terms of energy saving, since it sets the frequency of the processor to the lowest possible when the load on the processor is small.

However, I recently noticed that it has one drawback: “ondemand” takes the load on the processor caused by I / O operations as “idle”. What does it mean? This means that when I load the processor with I / O operations, the frequency of the processor often remains at a reduced level, which creates problems if your system suffers from the infamous Linux bug with iowait.

There are two ways to deal with this “ondemand” behavior.
')
The first option is to turn off the power saving mode of the processor. For example, correcting the script that includes it. It hides under the quite logical name "ondemand" and is located in /etc/init.d . If you fix the line in this file

 echo -n ondemand > $CPUFREQ 


on

 echo -n performance > $CPUFREQ 


, the processor will constantly operate at maximum frequency.

The second option is to enable for “ondemand” a mode in which it will not ignore iowait. This is controlled by the parameter in /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy . To do this, I wrote a small init script:

  #! /bin/sh ### BEGIN INIT INFO # Provides: io-is-busy # Required-Start: $ondemand # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: # Short-Description: makes "ondemand" frequency governor to respect iowait load ### END INIT INFO case "$1" in start) start-stop-daemon --start --background --exec /etc/init.d/io-is-busy -- background ;; background) sleep 65 # waiting till ondemand finish its' work echo 1 > /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy ;; restart|reload|force-reload) echo "Error: argument '$1' not supported" >&2 exit 3 ;; stop) echo 0 > /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy ;; *) echo "Usage: $0 start|stop" >&2 exit 3 ;; esac 


After this, the script is saved to the /etc/init.d/io-is-busy file, made executable, and written to the system with the command sudo update-rc.d io-is-busy defaults 99 99 .

Everything. Now, when the CPU load is increased by I / O operations, the frequency automatically rises to the maximum, as I wanted.

Source: https://habr.com/ru/post/110547/


All Articles