12
  • How can I upper limit my CPU frequency by a value?

  • cpufreq offers fixing the frequency to a constant value, instead of letting it vary in a range.

  • It also offers conservative, on demand, powersave, and performance. I don't know what they mean. but they don't limit the frequency either. What do the four settings mean actually? In other words, what are their policies?

2
  • what CPU do you have? From your description it sounds as though you are using the acpi cpufreq driver, please confirm. Do "cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_driver" Feb 21, 2015 at 0:18
  • T400's intel core duo. Yes, acpi-cpufreq.
    – Tim
    Feb 21, 2015 at 0:33

2 Answers 2

18

Question 2: This answer is for the acpi-cpufreq CPU frequency scaling driver driver:

The way to check which CPU frequency driver you are using is to do:

cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_driver

The conservative mode has a slower load-versus-CPU-frequency response curve, meaning it takes a little more load on the CPU to before the CPU frequency climbs.

The ondemand mode has a faster load-versus-CPU-frequency response curve, meaning it takes a little less load on the CPU before the CPU frequency climbs.

The driver uses hysteresis, so the increasing and decreasing load versus CPU frequency curves are not the same.

The powersave mode locks the requested p-state at the lowest value for the processor. The result is the CPU is always at the lowest clock frequency.

performance mode locks the target pstate at the highest value for the processor. However, note that some processors can back-off under no load by themselves. For simplicity, just think of it as the CPU always being at the highest frequency.

Question 1: Yes, you can limit the upper frequency.

First get a list of the available frequencies (example from my computer):

doug@s15:~/temp$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
3401000 3400000 3300000 3100000 3000000 2900000 2800000 2600000 2500000 2400000 2200000 2100000 2000000 1900000 1700000 1600000

Then decide what you want the maximum frequency to be, noting that it must be from the list. Then set it:

echo 2600000 | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq

And repeat for all CPUs.

A script version might be preferred, run as sudo:

#! /bin/bash
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq
for file in /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq; do echo "2900000" > $file; done
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq
9
  • thanks! what does "cpu frequency response curve." mean? What does " a slower load verses cpu frequency response curve" mean? Does powersave == always lowest freq, and performance == always highest freq?
    – Tim
    Feb 21, 2015 at 0:35
  • Thanks. Is there some way to upper limit GPU freq or fix it to a different GPU freq?
    – Tim
    Feb 21, 2015 at 3:29
  • I am a server guy, and don't know anything about GPU stuff. Perhaps start a new question for it. Feb 21, 2015 at 3:31
  • scaling_available_frequencies does not exist. (Ubuntu 20.04). The other files do. So I don't know what frequencies I can choose from.
    – CPBL
    Jul 29, 2020 at 0:53
  • @CPBL : If scaling_available_frequencies exist or not is a function of the CPU frequency scaling driver. The answer was written for the acpi-cpufreq driver, which apparently you are not using. Jul 29, 2020 at 2:36
3

A oneliner temporary solution which may help in some cases;

for i in {0..3}; do sudo cpufreq-set -c ${i} -g powersave --min 500Mhz --max 2600Mhz; done

Feel free to adapt the max number of CPU cores (here = 3) to yours.

Or even better, with the -r flag:

sudo cpufreq-set -r -g performance --min 500Mhz --max 2600Mhz

From the man:

-r --related
    modify all hardware-related CPUs at the same time

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .