Linux – Process priority and cpu speed

cpucpu-frequencyefficiencylinuxpriority

In some devices the cpu speed is dynamic, being faster when there is more load.

I was wondering if it is possible to set nice level or priority of a process so that it does not influence an increase in cpu speed when it is running flat out.

i.e.
Process is running flat out, but only using spare cpu cycles as low priority. But also not causing an increase in cpu speed.

When cpu is off process stops.
When cpu is slow process may have some cpu, maybe most of it.
When cpu is fast, because another process is running at 90%, process gets the remaining 10% of fast cpu.
Then other process stops, so low priority process gets 100% of cpu, but the frequency controller does not see this low priority process and drops the frequency.

Best Answer

You can use the ondemand cpu-freq governor, as long as you set the ignore_nice_load parameter to 1.

From Documentation/cpu-freq/governors.txt, ondemand section:

ignore_nice_load: this parameter takes a value of '0' or '1'. When set to '0' (its default), all processes are counted towards the 'cpu utilisation' value. When set to '1', the processes that are run with a 'nice' value will not count (and thus be ignored) in the overall usage calculation. This is useful if you are running a CPU intensive calculation on your laptop that you do not care how long it takes to complete as you can 'nice' it and prevent it from taking part in the deciding process of whether to increase your CPU frequency.

Related Question