Setting of CPU Governor under Linux
This article shows how to change and read out the CPU-Governor under Linux. The CPU Governor specifies the frequency range within which a processor core may operate. If you want to have, for example, maximum performance for all CPU cores at the same time, you can achieve this via changing the CPU-Governor. Important: The changing of the CPU Scaling Governor may have a negative influence on the electricity consumption of your server, as the automatic regulation of the CPU (energy saving modes) can be completely deactivated.
Available Scaling Governor
root@pveneo:~# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors conservative ondemand userspace powersave performance schedutil
Active Scaling Governor
root@pveneo:~# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor performance
Setting of Scaling Governor
If you want to set a Scaling Governor other than the one currently active, you can do so with an echo command.
echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
Important: With the specification of cpu*, in the above command, the Governor is reset on all available CPU cores.
Verification of CPU frequency
With watch 'cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq', you can observe live whether the CPU frequency changes automatically after setting the Scaling Governor.
Persistent configuration
The change of the above described process is not reboot-proof. With a Cronjob, which is executed when the system starts up, however, you can have the CPU Governor reset automatically. However, a kernel parameter available since kernel 5.9 would be better: cpufreq.default_governor=<WERT>, which is set as follows:
## For legacy systems with Grub that edit Grub files root@pveneo:~# nano /etc/default/grub ## For Systemd UEFI systems with systemd-Boot that edit cmdline root@pveneo:~# nano /etc/kernel/cmdline ## add Kernel parameters (example: Grub) GRUB_CMDLINE_LINUX_DEFAULT="quiet cpufreq.default_governor=powersave" ## Grub Update root@pveneo:~# update-grub Generating grub configuration file ... Found linux image: /boot/vmlinuz-6.5.13-1-pve Found initrd image: /boot/initrd.img-6.5.13-1-pve Found linux image: /boot/vmlinuz-6.5.11-8-pve Found memtest86+ 64bit EFI image: /boot/memtest86+x64.efi Adding boot menu entry for UEFI Firmware Settings ... done ## For systemdboot proxmox-boot-tool refresh update-initramfs -u ## restart server root@pveneo:~# reboot ## Verify if parameter is active root@pveneo:~# cat /proc/cmdline BOOT_IMAGE=/boot/vmlinuz-6.5.13-1-pve root=/dev/mapper/pve-root ro quiet cpufreq.default_governor=powersave
You can also validate the function of the kernel parameter by re-reading the Scaling Governor immediately after the reboot.
root@pveneo:~# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor powersave
|
Author: Jonas Sterr Jonas Sterr has been working for Thomas-Krenn for several years. Originally employed as a trainee in technical support and then in hosting (formerly Filoo), Mr. Sterr now mainly deals with the topics of storage (SDS / Huawei / Netapp), virtualization (VMware, Proxmox, HyperV) and network (switches, firewalls) in product management at Thomas-Krenn.AG in Freyung.
|
|
Translator: Alina Ranzinger Alina has been working at Thomas-Krenn.AG since 2024. After her training as multilingual business assistant, she got her job as assistant of the Product Management and is responsible for the translation of texts and for the organisation of the department.
|


