Change cpu governor linux

CPU frequency scaling

CPU frequency scaling enables the operating system to scale the CPU frequency up or down in order to save power. CPU frequencies can be scaled automatically depending on the system load, in response to ACPI events, or manually by userspace programs.

CPU frequency scaling is implemented in the Linux kernel, the infrastructure is called cpufreq. Since kernel 3.4 the necessary modules are loaded automatically. For older kernels or CPUs, the recommended ondemand governor is enabled by default, whereas for newer kernels or CPUs, the schedutil governor is enabled by default. However, userspace tools like cpupower, acpid, Laptop Mode Tools, or GUI tools provided for your desktop environment, may still be used for advanced configuration.

Contents

Userspace tools

thermald

thermald is a Linux daemon used to prevent the overheating of Intel CPUs. This daemon monitors temperature and applies compensation using available cooling methods.

By default, it monitors CPU temperature using available CPU digital temperature sensors and maintains CPU temperature under control, before HW takes aggressive correction action. If there is a skin temperature sensor in thermal sysfs, then it tries to keep skin temperature under 45C.

The associated systemd unit is thermald.service , which should be started and enabled.

i7z is an i7 (and now i3, i5, i7, i9) CPU reporting tool for Linux. It can be launched from a Terminal with the command i7z or as GUI with i7z-gui .

cpupower

cpupower is a set of userspace utilities designed to assist with CPU frequency scaling. The package is not required to use scaling, but is highly recommended because it provides useful command-line utilities and a systemd service to change the governor at boot.

The configuration file for cpupower is located in /etc/default/cpupower . This configuration file is read by a bash script in /usr/lib/systemd/scripts/cpupower which is activated by systemd with cpupower.service . You may want to enable cpupower.service to start at boot.

cpupower-gui

cpupower-gui AUR is a graphical utility designed to assist with CPU frequency scaling. The GUI is based on GTK and is meant to provide the same options as cpupower. cpupower-gui can change the maximum/minimum CPU frequency and governor for each core. The application handles privilege granting through polkit and allows any logged-in user in the wheel user group to change the frequency and governor.

Читайте также:  Linux все для написания скриптов

turbostat

turbostat can display the frequency, power consumption, idle status and other statistics of the modern Intel and AMD CPUs.

CPU frequency driver

cpupower requires modules to know the limits of the native CPU:

Module Description
intel_pstate This driver implements a scaling driver with an internal governor for Intel Core (Sandy Bridge and newer) processors.
intel_cpufreq Starting with kernel 5.7, the intel_pstate scaling driver selects «passive mode» aka intel_cpufreq for CPUs that do not support hardware-managed P-states (HWP), i.e. Intel Core i 5th generation or older.
acpi-cpufreq CPUFreq driver which utilizes the ACPI Processor Performance States. This driver also supports the Intel Enhanced SpeedStep (previously supported by the deprecated speedstep-centrino module).
speedstep-lib CPUFreq driver for Intel SpeedStep-enabled processors (mostly Atoms and older Pentiums)
powernow-k8 CPUFreq driver for K8/K10 Athlon 64/Opteron/Phenom processors. Since Linux 3.7 ‘acpi-cpufreq’ will automatically be used for more modern AMD CPUs.
pcc-cpufreq This driver supports Processor Clocking Control interface by Hewlett-Packard and Microsoft Corporation which is useful on some ProLiant servers.
p4-clockmod CPUFreq driver for Intel Pentium 4/Xeon/Celeron processors which lowers the CPU temperature by skipping clocks. (You probably want to use a SpeedStep driver instead.)

To see a full list of available modules, run:

Load the appropriate module (see Kernel modules for details). Once the appropriate cpufreq driver is loaded, detailed information about the CPU(s) can be displayed by running

Setting maximum and minimum frequencies

In some cases, it may be necessary to manually set maximum and minimum frequencies.

To set the maximum clock frequency ( clock_freq is a clock frequency with units: GHz, MHz):

To set the minimum clock frequency:

To set the CPU to run at a specified frequency:

Alternatively, you can set the frequency manually:

The available values can be found in /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_frequencies or similar. [1]

Источник

Arch Linux

You are not logged in.

#1 2020-06-18 07:46:00

[SOLVED] How do I change CPU governor to perfomance?

Hi there! I can change CPU governor with cpupower-gui. But how do I change it permanently?

Last edited by DuckerMan (2020-08-01 15:03:18)

#2 2020-06-18 07:49:57

Re: [SOLVED] How do I change CPU governor to perfomance?

#3 2020-06-18 08:19:47

Re: [SOLVED] How do I change CPU governor to perfomance?

#4 2020-06-18 08:36:36

Re: [SOLVED] How do I change CPU governor to perfomance?

And the output of the commands you are told to look at? And did you actually read the sentence? Did you adjust the config file? It won’t do anything if you don’t specify your wanted configuration.

Last edited by V1del (2020-06-18 08:37:15)

#5 2020-06-18 08:46:19

Re: [SOLVED] How do I change CPU governor to perfomance?

And the output of the commands you are told to look at? And did you actually read the sentence? Did you adjust the config file? It won’t do anything if you don’t specify your wanted configuration.

Yep, I’ve changed governor in config file.

#6 2020-06-18 13:27:28

Re: [SOLVED] How do I change CPU governor to perfomance?

Did you enable the service in systemd? Did you set the governor. powersave, performance, whatever?

Читайте также:  Windows 10 от izual

UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things. — Doug Gwyn

#7 2020-06-18 13:45:58

Re: [SOLVED] How do I change CPU governor to perfomance?

Did you enable the service in systemd? Did you set the governor. powersave, performance, whatever?

When I’m tryinn to enable cpupower.service, I get error:

And yes, I’ve set perfomance governor.

#8 2020-06-18 14:04:59

Re: [SOLVED] How do I change CPU governor to perfomance?

Post the config file. Did you try running the command normally on your terminal and it does work?

#9 2020-06-19 06:09:12

Re: [SOLVED] How do I change CPU governor to perfomance?

Post the config file. Did you try running the command normally on your terminal and it does work?

I don’t know how to run command.

#10 2020-06-19 08:47:03

Re: [SOLVED] How do I change CPU governor to perfomance?

I don’t know how to run command.

will show you an Exec= line. There’s the command you want to test manually.

However studied and stilted your rant, it can never hide the base and primitve emotion that inspired it.
There’s no objectivity.

#11 2020-06-20 16:36:43

Re: [SOLVED] How do I change CPU governor to perfomance?

Just wondering if commenting out both min_freq and max_freq lines in /etc/default/cpupower and letting the system handle min/max (which is generally the best idea) will make the service start OK?
For instance, you haven’t posted your CPU model, so we don’t know what your min/max values are and if you are entering an incorrect value, or there could be a bug.

will show you which governors you can use on your system, which depend on which kernel modules are in use and doesn’t always match the larger possible list of governors that are shown in /etc/default/cpupower

Источник

Частота процессора в Linux

Если вы уже пытались настраивать частоту Linux, то, наверное уже заметили, что частота процессора сама меняется в зависимости от нагрузки на систему. Операционная система устанавливает лимит минимальной и максимальной частоты, и когда нагрузки нет частота автоматически опускается до минимальной, а при появлении нагрузки подымается назад.

Конечно, в интерфейсе BIOS можно зафиксировать частоту на одном уровне, но в этом нет смысла. С точки зрения баланса производительности и энергопотребления лучше оставить всё как есть. Но правила изменения частоты можно настроить. Для этого используются политики CPU Governor. В этой статье мы рассмотрим как узнать частоту процессора Linux, а также как настроить её изменение.

Как узнать частоту процессора Linux

Узнать текущую частоту процессора можно вместе с другой информацией о нём с помощью утилиты lscpu:

Здесь же выводится максимальная и минимальная частота. Текущую частоту для каждого ядра по отдельности вы можете посмотреть в файле /proc/cpuinfo:

Так можно вывести информацию обо всех ядрах на одном экране:

cat /proc/cpuinfo | grep «cpu MHz»

Утилита lshw тоже выводит текущую и максимальную частоту в секции cpu:

Ну и hwinfo выводит нужную нам информацию. Правда, прежде надо её установить:

sudo apt install hwinfo

hwinfo —short —cpu

Читайте также:  Настройка производительности windows 10 приложение

Если вы хотите отслеживать как меняется частота со временем используйте hwinfo в сочетании с утилитой watch:

watch hwinfo —short —cpu

Теперь вы знаете как посмотреть частоту процессора Linux, перейдём к управлению.

Управление частотой в Linux

Для управления частотой в операционной системе Linux используются политики CPU Governor. Они определяют как быстро будет изменятся частота при изменении нагрузки. Существует четыре политики:

  • powersave — процессор работает на минимальной частоте;
  • performance — процессор работает на максимальной частоте;
  • ondemand — динамическое изменение частоты, при появлении нагрузки резко устанавливается самая высокая частота, а при снижении нагрузки частота медленно снижается;
  • conservative — аналогично ondemand, только частота меняется более плавно;
  • userspace — использовать частоту заданную пользователем;
  • schedutil — изменение частоты на основе планировщика.

Самый выгодный в данном случае режим — это ondemand, частота повышается при необходимости и опускается если она не нужна. Чтобы посмотреть текущую политику управления частотой вам понадобится утилита cpupower, которую можно установить, установив этот пакет:

sudo apt install linux-tools-generic

Затем посмотрите информацию о процессоре:

Как видите, сейчас для управления частотой используется политика ondemand. Для установки политики используйте команду frequency-set и опцию -g. Например, для performance:

sudo cpupower frequency-set -g performance

Теперь частота гораздо выше, а используемая политика performance. Для того чтобы вручную менять частоту установите политику userspace:

sudo cpupower frequency-set -g userspace

Для установки максимальной частоты используйте опцию -u:

sudo cpupower frequency-set -u 3600Mhz

Для установки минимальной частоты — опцию -d:

sudo cpupower frequency-set -d 2300Mhz

А для изменения текущей частоты процессора — опцию -f:

sudo cpupower frequency-set -f 3500Mhz

Частота всё-равно будет немного колебаться, но эти колебания будут в пределах выбранного диапазона.

Все эти изменения сбрасываются после перезагрузки, поэтому если вы хотите чтобы всё сохранялось, придется создать скрипт с нужными командами и добавить его в автозагрузку.

Если вы любите пользоваться графическим интерфейсом вместо команд, вам понравится утилита cpupower-gui. Она позволяет настроить все необходимые параметры в графическом интерфейсе. Для её установки выполните:

sudo apt install cpupower-gui

Для установки самой последней версии выполните такие команды:

echo ‘deb http://download.opensuse.org/repositories/home:/erigas:/cpupower-gui/xUbuntu_20.04/ /’ | sudo tee /etc/apt/sources.list.d/home:erigas:cpupower-gui.list
curl -fsSL https://download.opensuse.org/repositories/home:erigas:cpupower-gui/xUbuntu_20.04/Release.key | gpg —dearmor | sudo tee /etc/apt/trusted.gpg.d/home:erigas:cpupower-gui.gpg > /dev/null
sudo apt update
sudo apt install cpupower-gui

После завершения установки вы сможете найти программу в главном меню. Её окно выглядит вот так:

Утилита позволяет настроить максимальную и минимальную частоту, а также политику для каждого ядра по отдельности или для всех ядер вместе. Просто выберите нужные значения и нажмите кнопку Apply.

В отличие от консольных команд утилита позволяет устанавливать необходимые вам значения профиля и частоты при старте программы. Для этого в программе есть два профиля Balanced и Performance. Первый использует политику Powersave, а второй — Performance. Для того чтобы выбрать профиль по умолчанию надо отредактировать конфигурационный файл /etc/cpupower_gui.conf:

sudo vi /etc/cpupower_gui.conf

Измените значение параметра Profile на нужное и этот профиль будет выбираться по умолчанию при старте программы, останется только добавить её в автозагрузку. Кроме этих двух профилей можно создавать свои в папке /etc/cpupower_gui.d/. В этой папке уже лежит пример профиля, но рассматривать этот процесс подробнее мы не будем.

Выводы

В этой небольшой статье мы рассмотрели как меняется частота процессора Linux, как её настроить и зачем это необходимо.

Источник

Оцените статью