Lock CPU frequency

Lock CPU frequency

To lock the CPU frequency in Ubuntu, you can use the cpufrequtils package to set a specific CPU frequency scaling governor and frequency range. Here's an example of how to lock the CPU frequency to a specific level:

Install the cpufrequtils package by running the following command in a terminal:

sudo apt-get install cpufrequtils
```

To check the available CPU frequency scaling governors and frequency ranges, you can run the following command:

cpufreq-info

This will display information about the available frequency scaling governors and frequency ranges.

To lock the CPU frequency to a specific level, you can create a new file in the /etc/default directory called cpufrequtils with the following contents:

GOVERNOR="userspace"
MIN_SPEED="1000000"
MAX_SPEED="1000000"

In this example, we're setting the CPU frequency scaling governor to "userspace" and specifying a minimum and maximum frequency of 1GHz (1000000 Hz).

You can create this file using the following command:

echo 'GOVERNOR="userspace"' | sudo tee /etc/default/cpufrequtils
echo 'MIN_SPEED="1000000"' | sudo tee -a /etc/default/cpufrequtils
echo 'MAX_SPEED="1000000"' | sudo tee -a /etc/default/cpufrequtils

After creating the cpufrequtils file, you can restart the cpufrequtils service to apply the changes:

sudo systemctl restart cpufrequtils.service

This will lock the CPU frequency to a specific level of 1GHz.

Keep in mind that locking the CPU frequency to a specific level may not be necessary or desirable for all workloads, and may actually reduce performance for some applications that require dynamic frequency scaling. It's important to carefully monitor your system and test different frequency configurations to determine the optimal setting for your specific use case.