Well, what is it for? Maybe you want to save resources. In my case, I use this setting to reduce CPU heat. The maximum frequency on my processor is 2.3 GHz. The minimum allowable frequency is 2.0 GHz. Therefore, I made every core of my processor work within the 2 GHz range. Everything works as before. I don’t feel the difference in speed at all.
We can change our processor settings on the fly!
No reboot required!
Utilities are not required!
Utilities that control the speed of the processor – abstractions that are needed to simplify.
How many cores does your processor have?
We can change the settings for each of our cores! … Individually!
Now where are our settings located? Let’s get a look. Use these commands:
cd /sys/devices/system/cpu/ ls -a ... . .. cpu0 cpu1 cpu2 cpu3 cpufreq cpuidle hotplug isolated kernel_max microcode modalias offline online possible power present smt uevent vulnerabilities
I have a four core processor. Therefore, I have four directories: cpu0, cpu1, cpu2, cpu3. As you guessed, these are the directories for each of the cores. Their numbering starts from zero. So, if you have 2 cores, your directories will be called cpu0, cpu1.
There is a lot of information here. There is even about thermal throttling. This thing reduces the performance of your processor when it starts to overheat, thereby protecting it.
We can read about all information files in the technical documentation of the Linux kernel.
Information about the processor, as well as about each of the cores can be viewed through this command:
You can see the real-time frequency of the processor cores by this command.
cat /proc/cpuinfo | grep -i mhz ... cpu MHz : 1999.788 cpu MHz : 1999.759 cpu MHz : 1999.830 cpu MHz : 1999.759
Try to enter it several times and you will see it.
Now, how can we change the frequency of the cores? Let’s go here:
This is our first core. Let’s see what is in this directory.
ls -a ... . affected_cpus cpuinfo_max_freq cpuinfo_transition_latency related_cpus scaling_available_governors scaling_driver scaling_max_freq scaling_setspeed .. bios_limit cpuinfo_min_freq freqdomain_cpus scaling_available_frequencies scaling_cur_freq scaling_governor scaling_min_freq stats
Let’s first see what frequencies we can set for the first core (and for all the others):
cat scaling_available_frequencies ... 2333000 2000000
This means that my cores support only these frequencies. So, I can choose from two.
There are also these two files that act as limits:
cat cpuinfo_max_freq ... 2333000 _____________________ cat cpuinfo_min_freq ... 2000000
This command allows us to view the frequency on the core in real time:
cat scaling_cur_freq ... 1999835
These files allow us to set our core frequency:
Attention! Here we can choose the options that are in the file scaling_available_frequencies. If you enter something else, it will not work.
Also there is a file:
Probably the Linux kernel takes this information straight from BIOS. So, if you are interested in CPU overclocking, this may be what you need.
Now let’s change the frequency of our core!
echo 2000000 | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq echo 2000000 | sudo tee /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq echo 2000000 | sudo tee /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq echo 2000000 | sudo tee /sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq
This command allows me to set the frequency for all four cores.
Attention! These configuration files are in RAM, so after a reboot, our configuration will disappear!
Therefore, you need to make sure that every time the system boots, this setting takes effect.
How to make settings work on every boot
So, there are many ways, but I did it that way.
- I wrote a script:
#!/bin/sh -e echo 2000000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq echo 2000000 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq echo 2000000 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq echo 2000000 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq exit 0
2. Then i named it as frequencies and put it here:
3. Then i launched crontab -e as root(it is important):
sudo crontab -e
4. And put there this line:
And it works.